DEV Community

Discussion on: Open Discussion: What Tips Do You Have For Writing Clean Code?

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️
  1. Don't be lazy about typing. Abbreviations harm readability.
  2. Don't encode data in your control flow. switch/case is evil.
  3. Don't implement what you need right now. Think in abstracts.
Collapse
 
mephi profile image
mephi

I don't get the problem with switch case. Can you provide an example?

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

switch/case is often abused to express data that should be a map as control flow instead. Then people wonder why their code is so hard to extend.

Thread Thread
 
mephi profile image
mephi

Ok... but if I don't use Python, I can't put everything in a map.

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Yes, you can? What programming language doesn't support maps these days?