Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Implementation patterns

Implementation patterns

Summary of values, principles and some patterns from the book "Implementation Patterns"

Emma

May 18, 2012
Tweet

More Decks by Emma

Other Decks in Programming

Transcript

  1. Structured using a basic set of state and control flow

    contepts Most programs follow a small set of laws
  2. Readers need to understand in detail and in concept Most

    programs follow a small set of laws
  3. How to structure iteration... Example ...the loop should be easy

    to read, easy to write, easy to modify and eficient.
  4. Communication Values Code communicates well when the reader can understand

    it, modify it or use it Do you think of others when you program?
  5. Simplicity Values Eliminating excess complexity enables those reading, using and

    modifying programs to understand them more quickly Simplicity is in the eye of the beholder
  6. Flexibility Values Programs should be flexible, but only in ways

    they change Flexibility can come at the cost of increased complexity
  7. Local Consequences Principles Structure the code so changes have local

    consecuences Keeping the cost of making changes low is a primary motivation
  8. Minimize Repetition Principles When you have the same code in

    several places, when you change one copy your change is no longer local Duplication is not evil, it just raises the cost of making changes
  9. Login and Data together Principles Put logic and the data

    it operates in the same method if possible, or in the same object or at least in the same package Logic and data are likely to have to change at the same time
  10. Simmetry Principles Simmetry is where the same idea is expressed

    the same way eveywhere it appers in the code Let's see an example!
  11. Declarative Expression Principles For those parts of a program that

    are more like simple facts, whithout sequence or conditionals, it is easier to read code that is simply declarative It requires that you follow the thread of execution
  12. Rate of Change Principles Put logic or data that changes

    at the same rate together and separate logic or data that changes at different rates These rates of change are a form of temporal simmetry
  13. Class Reducing the number of clases in an system is

    an improvement... ...as long as the remaining classes do not become bloated.
  14. Class Simple Superclass Name Some of the most important names

    to choose well Names should be short and punchy, however sometimes you need several words Try to pick a strong metaphor: DrawingObject vs Figure
  15. Class Qualified Subclass Name The names of subclass have two

    jobs. They need to communicate what class they are like and thoy they are different. Prepend one or more modifiers to the superclass name to form a subclass name
  16. Class Abstract interface Every layer of interface has costs:It is

    one more thing to learn, understand, document, debug, organize, browse and name. Pay for interfaces only where you will need the flexibility they create. Maximizing the number of interfaces doesn't minimize the cost of software
  17. Class Interface Two styles of naming depend on how you

    are thinking of the interfaces: File - ActualFile, ConcreteFile, FileImpl (sufix and abbreviation!) IFile - File
  18. Class Abstract class They support change in the implementation and

    change of the interface. An interface says: "Here's how to access this kind of funcionality" A superclass says: "Here's one way to implement this functionality"