Ranter
Join devRant
Do all the things like
				++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
				Sign Up
			Pipeless API
				From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
				Learn More
			Comments
		- 
				
				
sariel78954yI take one look at 300 lines of if-else-if blocks and pull a blame.
If the dev is still around I make a point to bring it up on standup and make them rewrite the whole thing in a switch block.
Nobody wants to maintain that pasta bullshit. - 
				
				Switch and If/Else-If debates? Pardon my annoying remark, but for extendable solution, it's not even a workaround.
 - 
				
				
asgs109214yUse a map. Easy to trace and runs in O(1) (thought not a great optimization for smaller set) - 
				
				I prefer Haskell's guards, Rust's & Scala's match... hell, even Kotlin's when expression and PHP 8.0's match expression.
For one simple reason: In most languages, neither switch/case nor if/else are actually expressions.
Branching logic shouldn't be statements, it should be an expression. The branches should be exhaustive and type-compatible.
Messing around with variable assignments inside/outside logic branches increases the chance of bugs.
					 
Related Rants
- 
						
							
MattiaPiola17Selfrant: I suck. I suck at programming. I suck at python. I suck at debugging. - 
						
							
burningcandle7You are a consultant and wrote some easy scripts by copying code snippets together? Good for you! It makes y... - 
						
							
itsron1433A minute silence for those who thought DevOps and BlackOps are related. Amen. 

Telling my kids this was suicide squad
joke/meme
stop the cap
amateur