4. Use Evolutionary Design & Reference Architecture Treat your code as a book Always check-in with better quality (!= software rot) Adhere to Clean Code Use Coding Guidelines Prevent duplication The Golden Rules
5. Don't forget YAGNI Don't make assumptions on legacy code Use TDD or BDD Consider using DDD if applicable Refactor aggressively Design towards patterns More Golden Rules
8. Breaks a complex domain into small chunks Uses highly expressive models (typically UML sketches) Intimately involves business Understandable by everyone Promotes a loosely coupled design Provides guidelines for large organizations Domain Driven Design
9. Ubiquitous Language One common unambiguous language Includes concepts and verbs Ensures collaborate understanding of the domain Originates from business Maintain a glossary (incl. translations) Apply to everything; code, tests, UI When refactoring, refactor everything Domain Driven Design
10. Entity Has identity in domain Identity never changes Enforces business rules on its properties Is not directly accessible Often has a functional identifier Domain Driven Design
11. Value Object No identity, just lightweight data Immutable Behaves like a primitive type Often reusable Examples: TimeFrame, ISBN, PostalCode, Email, Address Domain Driven Design
12. Aggregate Closely related entities and value objects Has global identity Only accessed through its Aggregate Root entity Ensures integrity of all entities Typically loaded and saved as one unit Loaded using a repository and (often) created using a factory Deleting the root, deletes everything in the aggregate Domain Driven Design
13. Domain Services Stateless Often the entry point into the model Enforce rules on multiple aggregates Implemented as methods or Commands Domain Driven Design
14. Strategic Design Bounded Contexts Context Maps Shared Kernel Customer/supplier development teams Conformist Anti-corruption layer Separate Ways Domain Driven Design
15. Unit Tests Fast in-memory tests Independent of any resources Integration Tests Access databases, files, services, I/O End-2-End Tests Full tests including all related systems Automated Testing
16. Small and focused Intention revealing Repeatable Have no side-effects Independent Have a clear name Tests should be...
17. It is important not to show what is not important Use Object Mother or Test Data Builder Signal the importance of variables using 'a', 'the', 'someâ Start small Test what you know now (and assemble the rest) Guidelines for testing
18. Isolate The Ugly Stuff Use Dependency Injection Prefer state-based tests Test one condition Guidelines for testing
19. Is a design process Great for quality tests Tests are your first users Can be your documentation If TDD hurts => you're doing it wrong Red-Green-Refactor Better for state-based tests Test Driven Development 28 May 2009 Dennis Doomen
20. Design Effects More client control More interfaces/factories More focused Less coupling Problems UI Persistent Data False sense of security Losing the overview More code to maintain Test Driven Development
21. Stubs are stand-ins with fixed values Mocks can be used for expectations Frameworks: Rhino Mocks, NMock, MOQ, TypeMock (commercial) Guidelines Don't mock chatty interfaces Don't have more than 2-3 mocks per test Only mock your nearest neigbors Mocking 28 May 2009 Dennis Doomen
22. Karl Seguin wrote: Refusing Getting too excited Testing everything! Integration testing Discover mocking Mocking everything Becoming effective Phases of automated testing 28 May 2009 Dennis Doomen
23. Safe Delete Encapsulate Field Use Base Type where Possible Replace Constructor with Factory Method Convert Extension Method to Plain Static (vv) Convert Method to Property (vv) Convert Property to Auto-Property Extract Class from Parameters Rename Member / Type Rename / Move Namespace Extract Interface / Method / Superclass Pull Up & Down Introduce Field, Variable or Parameter Move To File (in Folder) Change Signature Refactoring
25. Flows naturally from user storiesAs a...I want...so that into Given...when...then More behavior oriented âTDD Done Rightâ Great for exploring the Ubiquitous Language using exploratory specs Seems easier to start with More intention revealing Difficult to implement with MSTest No single framework (yet) Behavior Driven Development
28. The Kitchen Reference Architecture Dennis Doomen Application Shell Silverlight 4 Views (XAML + C#) DI MVVM Support View Models Commands Controller Kitchen Context Application Services Unity for SL DTOs WCF RIA Services Enterprise Library Kitchen Service Domain Model Domain Events Domain Services Translation Policy Injection Validation Logging DI NHibernate(+ Fluent & LINQ) Service Agents Unit of Work Repositories AutoMapper Database Backoffice Systems
29. The Principle of Least Surprise Single Responsiblity Principle Open Closed Principle Liskov Substitution Principle Interface Seggregation Principle Dependency Inversion Principle Law of Demeter (a.k.a. Writing Shy Code) Command Query Separation Design Principles
31. Communicate design Solve common challenges Promote object-oriented design Promote loose coupling and reuse Go hand in hand with S.O.L.I.D. Purpose of Patterns
34. Gregg Irwin said: You use it without being aware You hear about it, read up on it, and tinker a bit You learn more and start using it explicitly, if naĂŻvely You get the fire and evangelize Something "clicks" You learn more and apply it "less naĂŻvely" and more implicitly Time passes and you see flaws You question the concept (often because you misapplied it) You either forget about it or add knowledge and experience You use it without being aware that you're using it Phases of Pattern Adoption
35. Only if the data and actions are available in all states! State Pattern
38. Used in WCSF Many interaction tests Requires a lot of mocking Strong view control Model View Presenter
39. Few interaction tests Many state-based tests Requires less mocking No view control Presentation Model
40. Microsoft variant of PM Easy data binding Bi-directional synchronization Model View View-Model
41. Responsibilities Hides access to the DB Behaves like a collection (implements ICollection<T>) Could support Transparent Persistency Lazy loading Automatic flushing Provides optimizations such as caching Provides exception shielding Repository Pattern
42. Recommendations Use an ORM such as NHibernate, Entity Framework or LLGenPro One repository per DDD aggregate root Use interfaces to allow faking/stubing Implement IQueryable (LINQ) Use Query Object or Specification patterns Repository Pattern
43. Responsibilities Encapsulate peculiars of external systems Reduces impact of changes Facilitate single sign-on Caching Resistant against temporary network problems Monitoring and tracing Service Agents
44. Recommendations Use interfaces to enable mocking/stubbing Use service agents for reporting servers and/of file I/O Use a workflow Service Agents
46. Smells Too many, output or flag arguments Inline Comments not related to a complex algorithm Dead Code Inconsistency (solve similar problems with similar solutions) Artificial Coupling Obscured Intent Misplaced Responsibility Clean Code
47. Guidelines Functions Names Should Say What They Do and Should Do One Thing and be short One Switch To Rule Them All (!) Be Precise Don' Mix Levels of Abstractions Always treat warnings as errors Clean Code
49. US01 - Als kok wil ik recepten kunnen bijhouden met titel, beschrijving, instructies, bereidingstijd, ingredienten en moeilijkheidsgraad. US02 - Als kok wil ik kunnen zien wat de kosten van een recept bij benadering zijn (op basis van de productprijzen) US03 - Als kok wil ik per eter een profiel kunnen bijhouden met naam, adres, telefoonummer en adresgegevens. US 04 - Als kok wil ik per eter kunnen aangeven of een eter allergisch is, dat product niet lust, of liever niet eet US05 - Als kok wil ik een boodschappenlijstje kunnen genereren o.b.v. een of meerdere recepten. User Stories Dennis Doomen
50. US06 - Als kok wil ik de boodschappen kunnen laten bestellen bij AH's Albert.nl US07 - Als kok wil ik dat de applicatie een willekeurig recept of weekmenu kan genereren, rekening houdend met de voorkeuren van mijn club/gezin US08 - Daarbij mogen gekochte recepten van de laatste 2 weken niet herhaald worden.??? US09 - Als kok wil ik mijn vrienden van Hyves, Facebook en mogelijk andere social networks kunnen importeren als profiel US10 - Als eter wil ik mijn waardering voor een recept kunnen opvoeren US11 - Als architect wil ik dat de applicatie op termijn met meerdere bestelservices moeten kunnen werken User Stories Dennis Doomen
51. US1 Als kok wil ik recepten kunnen bijhouden met titel, beschrijving, instructies, bereidingstijd, ingredienten en moeilijkheidsgraad.
68. US10 Als eter wil ik mijn waardering voor een recept kunnen opvoeren
69. US10 (onderdeel van US10 â als kok wil ik de mening van de eters over een recept kunnen bekijken)
70. The Kitchen Reference Architecture Dennis Doomen Application Shell Silverlight 4 Views (XAML + C#) DI MVVM Support View Models Commands Kitchen Context Application Services Unity for SL DTOs WCF RIA Services Unity Kitchen Service Domain Model Domain Events Domain Services Translation DI NHibernate(+ Fluent & LINQ) Service Agents Unit of Work Repositories AutoMapper Database AH, Hyves, Facebook
Hinweis der Redaktion
Orthogonality. Itâs a fancy word that just means being able to do or change or exercise one thing at a time. It also means being able to understand or learn about one thing at a time in a system. Reversibility. Technical or requirement decisions donât have to be locked in stone. Feedback. I think the best way to be successful building software is to assume that everything you do is wrong. We need rapid feedback cycles to find and correct our inevitable mistakes. Iteration. Your first idea is never your best idea. Your business partners will need to refine their vision. You need to be able to respond to both negative and positive feedback. Minimal Duplication. Less duplication means easier change, less chance of making silly errors, and quicker iteration to get to the best product
Refactor aggressively in areas that change often, but never refactor just 'because it doesn't look nice'
Refactor aggressively in areas that change often, but never refactor just 'because it doesn't look nice'
Flows naturally from user stories in the form of As A, I Want, So That into multple BDD scenarios in the form of Given, When, THenMore behavior oriented, thus better for interaction testsTDD Done RightLijktmakkelijkertezijnommeetebeginnenomdat het woord 'test' nietmeervoorkomtGeeft de intentiebeteraan door de verschillende 'should' conditiiesLastigom met MSTestteimplementerenMeerdere frameworks ommeetewerken, en nognieteentje die boven de rest uitsteekt
Flows naturally from user stories in the form of As A, I Want, So That into multple BDD scenarios in the form of Given, When, THenMore behavior oriented, thus better for interaction testsTDD Done RightLijktmakkelijkertezijnommeetebeginnenomdat het woord 'test' nietmeervoorkomtGeeft de intentiebeteraan door de verschillende 'should' conditiiesLastigom met MSTestteimplementerenMeerdere frameworks ommeetewerken, en nognieteentje die boven de rest uitsteekt
Flows naturally from user stories in the form of As A, I Want, So That into multple BDD scenarios in the form of Given, When, THenMore behavior oriented, thus better for interaction testsTDD Done RightLijktmakkelijkertezijnommeetebeginnenomdat het woord 'test' nietmeervoorkomtGeeft de intentiebeteraan door de verschillende 'should' conditiiesLastigom met MSTestteimplementerenMeerdere frameworks ommeetewerken, en nognieteentje die boven de rest uitsteekt
Repositories regelen toegang tot de database (vaak via een ORM) en gedragen zich als een object collectie (interface is gebaseerd op die van ICollection).Repositories worden altijd via een interface opgehaald (b.v. via een factory)De scope van de unit-of-work wordt door de BA bepaald en niet door de repositories Idealiter ondersteunt de repository eigenschappen van TransparentPersistency, b.v. lazylaoding van relaties tussen entiteiten en het automatisch flushen van alle wijzigingen binnen een unit-of-work. Verzorgt optimalisaties om de database te ontlasten, zoals b.v. first en second-levelcaches, query caching, e.t.c Zorgt dat technische database-specifieke fouten afgeschermd worden en vervangen door functionele fouten
De meeste ORMs ondersteunen alle gewenste functionaliteit. Ik gebruik Nhibernate en Nhibernate.LINQ Definieer 1 repository voor elke aggregatie root Laat toegang tot repositories altijd verlopen via een interface zodat de repository altijd gemocked kan worden Implementeer Iqueryable (b.v. Nhibernate.LINQ) zodat de aanroepende code LINQ queries kan uitvoeren zonder dat dit performanceproblemen veroorzaken. Gebruik Query Object pattern of Specification om een enorme lijst van FindXXX methodes met verschillende argumenten te voorkomen.
Een service agent zit tussen het domein model of BA en een extern systeem (of subsysteem) en schermt alle technische afhankelijkheden af. Doel? De impact van externe wijzigingen minimaliseren. Ook kan een SA de verschillen tussen interne en externe accounts transparant maken (mapping tussen accounts) zodat single sing-on mogelijk is. Biedt optimalisatie aan zoals caching, retries, auditing, logging, e.t.c. Verzorgt de monitoring en tracing van de interactie met de externe systemen, en kan bijvoorbeeld actief signaleren als bepaalde operaties opvallen lang duren.
Service Agents altijd via interfaces aanroepen om unittesten te kunnen schrijven zonder het externe systeem. Ook toegang tot files of networklocaties en reporting engines zijn âexternâ en moeten via service agents verlopen. Aangezien een service agents van nature long-running zijn, moeten die in principe altijd via een WF verlopen. Let op, in de praktijk gebeurt dit niet zo vaak.
Inconsistency (solve similar problems with similar solutions)
Inconsistency (solve similar problems with similar solutions)