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:
Vivaldi is a very unique browser. It's the only chromium based browser that has its own powerful and fully customizable UI. It even supports CSS like firefox based browsers do. If someone wants a powerhouse chromium based browser, Vivaldi is actually his only option. All other chromium based browsers just tweak the vanilla chromium UI. It also comes from an ethical company that has proved its ethics all these years. Something very rare in the chromium world... (all other companies which develop chromium based browsers own an ad company, Chrome, Edge, Brave, Opera etc).
While I agree that in some instances you should be wary of the government, shouldn't we also be wary of corporations that have the money, reach and power of many governments?
Having good regulations is essential for population protection (from corps trying to make more money than the other guy). At least we can vote in and out governments, but these days your choice of consumer tech is now only a few very large players. And we also know "consumers" are idiots and need protecting, it's literally the government's job to deliver those services.
Good news, and about time too, but with Office 2019 perpetual licence no longer being able to edit files, is this completely stuffing up the entire suite, or removing the ability to edit files from within OneDrive? Sounds stupid to have a kill switch like that, and they could totally fine a way to update the certificate if that's the reason behind it..
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