DEV Community

Discussion on: Writing Beautiful Code

Collapse
 
mrtnrdl profile image
Martin Riedel

For me it worked best if i treated the code i write not as something i write for a computer to execute. I treat code as a sort of documentation for other humans that might end up maintaining whatever i wrote.

In that regard, i value your first point a lot. A good suite of tests has proven to be invaluable (for me) when i had to add/refactore something in code i either didn't write or wrote more than 2 days ago - because i may or may not have any memories about that ;)

Collapse
 
marcus profile image
Marcus M

Regarding 1st paragraph: That is an great way to write your code. I'll try to do the same, but sometimes end up with long function names.

How do you handle this?
Are you for or against abbreviations?

Collapse
 
mrtnrdl profile image
Martin Riedel

When there is an 'and' or 'or' or something like this in the function name, i'll split it in two. Because obviously there are multiple concerns handled there.
If they are only long, i'm fine with that. Most of the time, one of my colleagues has a shorter suggestion in the review anyway :)

I'm not a huge fan of abbreviations - it hugely depends on the business domain and whether or not these abbreviations are kinda well known or not.

Collapse
 
restoreddev profile image
Andrew Davis

Unit tests are the best!