I have been programming for over 15 years now. I consider myself a very good programmer, but I understand (like all of us) there are things that I need to work on. One of these things is code repetition when dealing with conditions. I will give a generic sample:
Microsoft wants to end printer driver headaches with Windows Ready Print by Usama Jawad
A few days ago, Microsoft released Windows 11 Experimental build 26300.8553, bringing a ton of enhancements such as Start menu customization, search improvements, Taskbar polish, and other minor UI tweaks. Another relatively major enhancement snuck deep within the change log was related to upgrades to the Windows printing experience. Now, Microsoft has shared more details about these benefits.
For starters, Microsoft has renamed its Modern Print Platform to Windows Ready Print. The company believes that this name highlights its shift in strategy, which now focuses on modernizing, securing, and streamlining the printing experience for Windows devices.
Some of the upgrades present in Windows Ready Print have already been seeded to customers and partners. This includes ending support for third-party printer drivers via Windows Update and transitioning towards the Internet Printing Protocol (IPP) and the native Windows IPP printer driver.
In line with these changes, new printer installations will default to Windows Ready Print on eligible devices starting from July 2026. However, Microsoft recognizes that not all environments will be able to migrate to this platform immediately, so it will allow users to choose between installing the printer via Windows Ready Print or the traditional OEM process. Users will be able to toggle this configuration through Settings > Bluetooth & Devices > Printers & Scanners > Printer preferences.
This control applies only to new printer installations, and its functionality can also be modified via Group Policy as follows:
Launch Group Policy Editor
Navigate to Local Computer Policy -> Administrative Templates -> Printers
Find and select 'Configure Windows Ready Print driver ranking' -> double click to open it
Select 'Enabled' (if you wish to enable Windows Ready Print driver selection) or 'Disabled' (if you wish to explicitly disable Windows Ready Print driver selection).
Select Apply
Select OK
Similarly, if you set up Windows protected print mode through the same setting in Windows 11, it will also default to using Windows Ready Print exclusively. Microsoft hopes that these improvements will help eradicate dependency on OEM-specific driver installation processes and simplify printer installations. We'll likely find out more about other tangible benefits in the coming months.
Question
xWhiplash
Hello,
I have been programming for over 15 years now. I consider myself a very good programmer, but I understand (like all of us) there are things that I need to work on. One of these things is code repetition when dealing with conditions. I will give a generic sample:
if(condition1) { //perform some logic if(condition2) { //perform some logic if(condition3) { //Perform logic } else { //MethodA(param) } } else { //MethodA(param) } } else { //MethodA() }Now, I cannot make it easy by doing the following:
if(condition1 && condition2) { } else { }I cannot do this since I need to perform some logic if condition1 is true and before I test condition2.
Is there a way to structure if...else blocks to where if you need to call a method in each else blocks, you are not repeating yourself?
Link to comment
https://www.neowin.net/forum/topic/1226783-avoid-code-repetition-in-conditions/Share on other sites
80 answers to this question
Recommended Posts