Some rules that an applications programmer shall follow for keeping his code clean

23 May

computer ip address checker

A clean code

  1. contains classes that
    • are named with noun
    • are minimal, expressive, simple
    • do one thing well i.e. should have one, and only one reason to change
      (SRP:Single Responsability Principle)
    • are simple and direct
    • can be read like well-written prose
    • are literate
    • always look like they were written by someone who cares
  2. contains names that
    • are meaninful, intension-revealing
    • avoid disinformation
    • make meaninful distinction
    • are pronounceable
    • are searchable
    • are not encoded
    • don’t mappe mental
  3. contains methods that
    • are named with verbs or verb phrases
    • are minimal
    • do one thing
    • have one level of abstraction
    • respect the stepdown rule
    • have descriptive names
    • have the minimal number of arguments (zero is ideal)
    • have no side effects i.e. do only one thing at a time
    • don’t repeat themselves i.e. avoid duplication
  4. contains comments that
    • are legal
    • are informative
    • explain intents
    • clarify
    • amplificate
    • are not redundant
    • are not mandated/delegated
    • are not like a journal
    • don’t noise
    • don’t replace a function or a variable
    • don’t signal closing braces
    • don’t maskt out code
    • don’t contain HTML tags
    • don’t describe short functions
  5. respects the three laws of TDD: Test Driven Development
    • you may not write production code until you have written a failing unit test
    • you may not write more of a unit test than is sufficient to fail, and not compiling is failing
    • you may not write more production code than is sufficient to pass the currently failing test
  6. picks one word per concept i.e. avoid using synonyms
  7. doesn’t pun i.e. avoids using the same word for two purposes
  8. uses solution domain names because only programmers will read it
  9. adds meaninful context
  10. does’nt add gratuitous context
  11. is well-formatted
  12. handles errors i.e. prefers exeptions to returning error codes
Source: SlideShare


© Djomo Mungwe

Advertisements

2 Responses to “Some rules that an applications programmer shall follow for keeping his code clean

  1. djomomoungoue May 23, 2013 at 12:21 #

    wow I find this really useful for programmers which aim to be professional

  2. justanotherhumanoid June 1, 2013 at 14:12 #

    Reblogged this on justanotherhumanoid.

Comments are closed.

%d bloggers like this: