3 ms·
Reminds me of these YouTube videos filled with bad advice for newbies. For example, "Why I never code with ELSE statements, and YOU shouldn't either". It sounds
by lopatin 5y ago
Reminds me of these YouTube videos filled with bad advice for newbies. For example, "Why I never code with ELSE statements, and YOU shouldn't either". It sounds profound to a newbie, but it's all just disingenuous dogmatic click bait.
- ehutch79 5y agoI know you're kidding, but there are legit videos saying you should never use If statements
- lopatin 5y agoI wish I was kidding, but that sounds even worse! - https://www.youtube.com/watch?v=kzuCnivRoEw https://www.youtube.com/watch?v=kzuCnivRoEw - https://www.youtube.com/watch?v=_ougvb8mT7k https://www.youtube.com/watch?v=_ougvb8mT7k - https://www.youtube.com/watch?v=EumXak7TyQ0 https://www.youtube.com/watch?v=EumXak7TyQ0
- deanCommie 5y agoExcept...these are right. Minimizing nesting, and setting up validation failures as exit-early conditions from functions to have the main function body focused on the happy path are absolutely valid principles of clean code. Obviously there are always exceptions, but as a principle you could do a lot worse.
- LAC-Tech 5y agoFWIW I rarely use else statements and prefer early returns. Might be trauma from dealing with legacy code where you'd need an ultra wide monitor to get the end of the indentation.