O SlideShare utiliza cookies para otimizar a funcionalidade e o desempenho do site, assim como para apresentar publicidade mais relevante aos nossos usuários. Se você continuar a navegar o site, você aceita o uso de cookies. Leia nosso Contrato do Usuário e nossa Política de Privacidade.
O SlideShare utiliza cookies para otimizar a funcionalidade e o desempenho do site, assim como para apresentar publicidade mais relevante aos nossos usuários. Se você continuar a utilizar o site, você aceita o uso de cookies. Leia nossa Política de Privacidade e nosso Contrato do Usuário para obter mais detalhes.
Where did it all start?● Christopher Alexander (1936 -)● Chemistry & Physics, Trinity, Cambridge, 1957● Ph.D. Architecture, Harvard (1st ever awarded)● Professor Architecture, Berkley, 1963● “Notes on the synthesis of form”, 1964● First Gold Medal Research, American Institute of Architects, 1972● “A Pattern Language”, 1977
Alexandrian Form● Picture – archetypical example● Introductory paragraph - context● Headline (in bold) – essence of problem● Body – background, motivation, variations● Solution (in bold)● Diagram (of solution)● [Smaller] related patterns
The Hillside Group● Promotes patterns in software community● Formed 1993 by Ward Cunningham, Ralph Johnson, Ken Auer, Hal Hildebrand, Grady Booch, Kent Beck and Jim Coplien● Cunningham invented Wiki to discuss patterns● Sponsors PLoP conferences & books● Hillside Group: www.hillside.net● WikiWikiWeb: www.c2.com
Canonical [GoF] Form● Name● Alias(es) [Also known as]● Context [Applicability]● Problem [Intent]● Forces [Motivation]● Solution [Participants, Structure, Collaborations, Implementation]● Example (optional) [Sample code]● Resulting context [Consequences]● Rationale (optional)● Known uses● Related patterns
Pattern Languages● Structured method of describing good design practices within a field of expertise● A network of patterns that call upon one another● Help the designer move from problem to problem in a logical way● Allow for many different paths through the design process
Pattern Sequences● Pattern languages are played out as sequences● Sequences show paths through a language● Commonly illustrated through stories● Give rise to common design fragments● Can be shown diagrammatically, or as a list
And so, back to Singleton● “Ensure a class has only one instance, and provide a global point of access to it.” – GoF, 1995● “[Singleton] invariably causes problems with coupling and execution, and is more than a little overused” – Henney, 2005● “How do you provide global variables in languages without global variables? Dont. Your programs will thank you for taking the time to think about design instead.” – Kent Beck, 2003
An AlternativeYou have this system... ● You try globals... well, probably you dont: the one thing you learned in school was no globals. ● You try for SINGLETON, it is in the book, it is good... but then you find you have these nasty ripples... then someone tells you its a bad thing and its obvious to you. ● So you try passing parameters: they overwhelm you. ● You refactor a bit (à la Fowler) and before you know it youve got ENCAPSULATED CONTEXT. ● You carry on down this path, you get more mileage here, but over time it starts to look like Footes BIG BALL OF MUD.The solution is to reduce the coupling, improve the cohesion, but how? Allan Kelly, 2005
Context Encapsulation Pattern Language“Context Encapsulation: Three Stories, a Language and Some Sequences” Kevlin Henney, 2006http://www.two-sdg.demon.co.uk/curbralan/papers/europlop/ContextEncapsulation.pdf