Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Keep this in mind

Coding Maxims

numbered for ease of reference, not for ranking

  1. code is debt (and bad code is an unhedged call option)

    • cant have 0-days or bugs if I dont write any code
    • our users dont care about the code
    • every line of code has costs (your time, readability, maintainability, complexity)
      • its like owning a house with lots of rooms. its nice when your friends come over once a month, but you pay rent every day
    • dont add features unless you're sure it is necessary
    • dont optimize prematurely

  3. keep it simple (especially at first)

  4. be consistent

  5. be predictable (aka no magic)

  6. no magic numbers/strings — use constants instead

  7. a good repro is 90% of a bugfix

  8. code is written once, but is read many times

  9. ship early, ship often

  10. first code, then ship, then measure, then optimize

  11. remember the 80/20 rule, and the 90/90 rule

  12. first you don't know the rules, then you learn the rules, then you break the rules

See also:


This comment has been minimized.

Copy link

@nrjohnstone nrjohnstone commented Sep 22, 2017

DRY is a dangerous mantra when applied without thinking... If your crossing architectural boundaries, and you think that it's "DRY" to share your dto from one boundary to another all the way down to your persistence layer because, if you don't, your repeating yourself, then your going to be asking for a world of pain in terms of coupling between layers ... DRY within a bounded context / specific scope is the only way to apply this principal...

The rest of your principles are well written and unfortunately I don't see enough like them in other places.


This comment has been minimized.

Copy link

@kauffj kauffj commented Nov 21, 2017

  1. I propose these be numbered.
  2. I propose "no magic numbers/strings — use constants instead" be modified (or a new rule added) to cover that strings are only for messages for people (e.g. to be displayed, for log files, etc.). If you are doing a comparison against a string, especially in more than one place, that is a strong sign it should be a constant. I think magic strings/numbers specifically refers to input that triggers hidden or non-standard behavior, which is a bad idea even if you are using constants.

This comment has been minimized.

Copy link

@rchasman rchasman commented May 5, 2018

Great Maxims Lyoshenka

I love DRY as much as the next guy but when you are moving fast, I think sometimes it’s okay to save things to factor out later. What do you think about the Sandi Metz saying “duplication is far cheaper than the wrong abstraction”.?

Thanks for the Maxims!.


This comment has been minimized.

Copy link
Owner Author

@lyoshenka lyoshenka commented Jun 7, 2018

@rchasman he's probably right. As the last maxim says, "first you don't know the rules, then you learn the rules, then you break the rules".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment