Upload
varokas
View
59
Download
1
Embed Size (px)
Citation preview
EMERGENT DESIGNVarokas Panusuwan
DESIGN PATTERNWhat is it?
PATTERNS
Scott BainThe Pattern is in the problem
Dont solve the problem, discover the problem.
Christopher Alexander, ArchitectDesign: the process of inventing things which display new physical order, organization, form, in response to function.
ForceForceForceForceForceForceForceForceDesign
ForceForceForceForceForceForceForceForceDesign
ForceForceForceForceForceForceForceForceDesign
DESIGN PATTERNLanguage for designNoobs vs Pro talks
COMMONALITYVARIABILITYANALYSIS
5 Each
Browser: "As a URLReader, I can read HTML either from File location (file:///) or over internet (http://)"
Browser: "As a Renderer, I want to show image as "loading..." until the image is loaded
PROGRAMMING BY INTENTIONGoogle Example
PATTERNS DISCOVERY PRACTICESDont worry about creational pattern yet.
ECHO HELLO WORLDA program read input from keyboard or scannerA program sends the output to either printer or screen
DOMElement are the things that can be shown on screenelement can contain each otherA browser can call render() and the element should render itself and everything inside
SWING BORDERComponent can have bordersBorders can be stacked on top of each otherMany kinds of borderImage borderPlain borderDotted borderWhen render() the component draw itself and the border
ENCRYPTIONAn encryption module can encrypt a plain string to encrypted stringMany standards : DES, AES, BlowfishSome encryption standards are composite of others e.g. 3 DES = DES(DES(DES(text)))DESAES = DES(AES(text))
500 100 50 20 10
CREATIONAL PATTERNSWhat can exist in the world?
FACTORYFew possible configurationDefined statically in code
BUILDERMany possible configurationSome rules coded inUse in runtime to set up other objects
DESIGN TOOLSCVARedundancyCouplingEncapsulation
COUPLINGAccidentalIntentional
ENCAPSULATIONswitch (input) { case A : doAlgoA(); case B : doAlgoB();}AlgoProgram
AlgoAAlgoB
LEVELSConceptualSpecificationImplementationhttp://www.syntropy.co.uk/papers/modelingwithpurpose.pdf
UNFIT PATTERNSHandlersDecorators
EMERGENT DESIGNAt LastWhat is it?
StarbucksCreate a software for cashier and baristaA program accepts order from user (cashier as them)example:What kind of coffeeWhat size etcA program compute cost based on the orderA program shows the barista what to doexample:Put in 2x coffeePut in milkput in iceshakedone
Starbucks (v1)
Select Size of cup (S,M,L)put coffee(S) Cup -> Coffee(M) Cup -> Coffee x 2(L) Cup -> Coffee x 3
Starbucks (v2) Select Coffee Type (Hot/Cold)Select Size of cup (S,M,L)Make CoffeeHot :: Cup -> Coffee (S,M,L)Cold :: Cup -> Coffee (S,M,L) -> Ice (always x 1)-- redraw this(keep v1) --
Starbucks (v3)Select Coffee Type (Hot/Cold)AmericanoEspressoLatte Select Size (S,M,L)Make CoffeeCoffee Americano = Coffee + WaterLatte = Coffee + MilkEspresso = Coffee + (nothing)Hot :: Cup-> Coffee (S,M,L) Cold :: Cup -> Coffee (S,M,L) -> Ice (always x 1)-- redraw this (keep v1&v2) --
`What is the differences between requirement and design?