Slide 1

Slide 1 text

Implementation Patterns

Slide 2

Slide 2 text

Are read more often than written Most programs follow a small set of laws

Slide 3

Slide 3 text

There is no such thing as "done" Most programs follow a small set of laws

Slide 4

Slide 4 text

Structured using a basic set of state and control flow contepts Most programs follow a small set of laws

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Patterns are based on them Patterns help you write code Patterns work together

Slide 7

Slide 7 text

How to structure iteration... Example ...the loop should be easy to read, easy to write, easy to modify and eficient.

Slide 8

Slide 8 text

Values Principles Patterns

Slide 9

Slide 9 text

Communication Values Code communicates well when the reader can understand it, modify it or use it Do you think of others when you program?

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

Flexibility Values Programs should be flexible, but only in ways they change Flexibility can come at the cost of increased complexity

Slide 12

Slide 12 text

Values Principles Patterns

Slide 13

Slide 13 text

Local Consequences Principles Structure the code so changes have local consecuences Keeping the cost of making changes low is a primary motivation

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Simmetry Principles Simmetry is where the same idea is expressed the same way eveywhere it appers in the code Let's see an example!

Slide 17

Slide 17 text

Simmetry Principles

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

Declarative Expression Principles

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Rate of Change Principles

Slide 22

Slide 22 text

Values Principles Patterns

Slide 23

Slide 23 text

Class State Behaviour Methods

Slide 24

Slide 24 text

Class Classes are relatively expensive design. A class should do something significant.

Slide 25

Slide 25 text

Class Reducing the number of clases in an system is an improvement... ...as long as the remaining classes do not become bloated.

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Class Interface Two styles of naming depend on how you are thinking of the interfaces: File - ActualFile, ConcreteFile, FileImpl (sufix and abbreviation!) IFile - File

Slide 30

Slide 30 text

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"

Slide 31

Slide 31 text

Class Value object Draw the boundary between the world of state and the world of value