Maxims for programmers

Some maxims I think are good to follow.

Asking if an array is empty, should use empty? instead of blank?.

No code is better than any code. Less code you maintain, the better.

Being consistent is easy to spot something went wrong when things are out of style.

Dont confuse yourself and your colleagues.

You can squeeze almost everything you want to do in Ruby into oneliners, but you probably want some abstractions to make the program read better.

To find something in an array, use find instead of finding yourself:

array.each { |element| return element if element == 3 }
array.find { |element| element == 3 }

find is more specific, concise, and use built-in tools.

Sometimes maxims are in conflict. Experiences will guide your way to pick which one. Team style will show you which and don’t forget to be consistent.