DevLOVE Beautiful Development - 第一幕 陽の巻

7,364 views

Published on

Published in: Technology
1 Comment
19 Likes
Statistics
Notes
No Downloads
Views
Total views
7,364
On SlideShare
0
From Embeds
0
Number of Embeds
238
Actions
Shares
0
Downloads
53
Comments
1
Likes
19
Embeds 0
No embeds

No notes for slide

DevLOVE Beautiful Development - 第一幕 陽の巻

  1. 1. DDD Pt.IIBuilding Blocks ~DDD ~ ( ) - tricreo.jp / Jiemamy Project - jiemamy.org 2011.04.09 @
  2. 2. • (@daisuke_m)• Jiemamy / java-ja• Apache Mahout• Java / OO / DDD•
  3. 3. works• @IT — Jiemamy• • Java • Java• Java: The Good Parts ( )• DDD ( )
  4. 4. DDD http://d.hatena.ne.jp/daisuke-m/20110407/1302156870• Jiemamy Project••• DDD•• Jiemamy version 0.3• baseunits library (timeandmoney)
  5. 5. Jiemamy• ER • Eclipse (UI ) • DB , SQL ( ) • SQL… • XML I/O, DDD ( )
  6. 6. Agenda• DDD overview• Isolating the Domain• Model• LifeCycle
  7. 7. §0 DDD overview• DDD • GoF • PoEAA
  8. 8. DDD PATTERNS• STRATEGY • OPEN HOST SERVICE• COMPOSITE • CORE DOMAIN• BOUNDED CONTEXT • GENERIC SUBDOMAINS• CONTINUOUS INTEGRATION • DOMAIN VISION STATEMENT• CONTEXT MAP • HIGHLIGHTED CORE• SHARED KERNEL • COHESIVE MECHANISMS• CUSTOMER/SUPPLIER DEVELOPMENT TEAMS • SUGGESTED CORE• CONFORMIST • ABSTRACT CORE• ANTICORRUPTION LAYER • EVOLVING ORDER• SEPARATE WAYS • SYSTEM METAPHOR• OPEN HOST SERVICE • RESPONSIVILITY LAYERS• PUBLISHED LANGUAGE • KNOWLEDGE LEVEL• INTEGRATION • PLUGGABLE COMPONENT FRAMEWORK
  9. 9. DDD PATTERNS• UBIQUITOUS LANGUAGE • FACTRIES• MODEL-DRIVEN DESIGN • REPOSITORIES• HANDS-ON MODELERS • SPECIFICATION• LAYERED ARCHITECTURE • INTENTION-REVEALING INTERFACES• THE SMART UI "ANTI-PATTERN" • SIDE-EFFECT-FREE FUNCTION• ENTITIES• VALUE OBJECTS • ASSERTIONS• SERVICES • CONCEPTUAL CONTOURS• MODULES • STANDALONE CLASSES• AGGREGATES • CLOSURE OF OPERATIONS
  10. 10. ••••( )
  11. 11. • • •
  12. 12. Domain or Not••• HISTORY••••
  13. 13. • UI• DB•• DB
  14. 14. ••••
  15. 15. • →• →• ® • •• ® • •
  16. 16. •••
  17. 17. •• •• Model Driven Design ( ) •
  18. 18. Model or Not• LibHTTP • User• Search • File• FacebookLogin • String• Translation • StringBuilder• FoobarLogic • YearMonth
  19. 19. §1•• • • UI
  20. 20. LAYERED ARCHITECTURE•• ;•
  21. 21. Jiemamy DiagramEditor TableView DbObjectEditPart maven-jiemamy-plugin UI jiemamy eclipse plugin ExecuteMojo Application jiemamy-diagram JmDiagram JmNode / JmConnection SqlStatement jiemamy-sql Domain Token JmTable / JmView JmColumn jiemamy-core JmForeignKeyConstraint woodstoxSqlExecutor / UUIDProvider XMLInputFactory Infrastructure XMLValidationSchema jiemamy-commons apache commons
  22. 22. THE SMART UI "ANTI-PATTERN"• DDD• •• light MDD
  23. 23. UI DBUser#save(); → DBtoString() ! "<span>...</span>"
  24. 24. §2••• 3 • ENTITY (E) • VALUE OBJECT (VO) • SERVICE
  25. 25. • •• • Table knows Columns / Column knows Table • Emp knows Dept / Dept knows Emps
  26. 26. class Emp { class Dept { String name; String name; Dept dept; List<Emp> members;} } Dept tech = new Dept(" "); Emp kato = new Emp(" "); kato.setDept(tech); tech.addMember(kato);
  27. 27. • Declaration & Reference• Repository
  28. 28. ENTITY (E)••• vs• (SE) vs ( )
  29. 29. • 31 32 31 (File / DB) 32 (On Memory)•• Serialize / Deserialize clone…
  30. 30. ENTITY• Table • Order• Column • Customer• ForeignKey• Employee• Department
  31. 31. ENTITY••• ID• equals hashCode ID
  32. 32. • ENTITY• ID• • •
  33. 33. EColumn col = ...; // ← ENTITYtableFoo.addColumn(col);tableBar.addColumn(col);// somethingtableFoo.getColumn(...).setName("AAA");tableBar
  34. 34. • ID• (v0.2)•
  35. 35. VALUE OBJECT (VO)••• new String("foo") vs new String("foo")• man.getName(): String• equals hashCode property
  36. 36. VALUE OBJECT• Integer• BigDecimal• String• Color• Date / TimePoint• Status (OPEN / PROGRESS / CLOSED)
  37. 37. VALUE OBJ.••• Immutable • Flyweight
  38. 38. SERVICE• E VO• E VO Service • E VO •
  39. 39. SERVICE•• (UL)•• →
  40. 40. • E / VO• E / VO• E / VO • Transaction Script •
  41. 41. • Infrastructure Service ( ) • E-mail •• Application Service • Excel export •• Domain Service ••
  42. 42. MODULE••
  43. 43. Java package•• 1•
  44. 44. MVC• com.example.foobar •com.example.foobar • model • foo • FooModel • FooModel • BarModel • FooView • view UL • FooController • FooView • bar • BarView • BarModel • controller • BarView • FooController • BarController • BarController
  45. 45. MVC• com.example.foobar •com.example.foobar • model • foo • FooModel • FooModel • BarModel • FooView • view UL • FooController • FooView • bar • BarView • BarModel • controller • BarView • FooController • BarController • BarController
  46. 46. §3 LifeCycle• Object • new GC • INSERT DELETE•
  47. 47. §3 LifeCycle
  48. 48. E• LifeCycle Object LifeCycle• User• JVM
  49. 49. AGGREGATE•• …
  50. 50. •• Table• Column Entity• Column Table• ObjColumn → Table
  51. 51. FACTORY••• new• Object Object•
  52. 52. • Obj.• Object LifeCycle• • Object
  53. 53. Obj.• • Obj. • Obj.• Factory Obj.
  54. 54. REPOSITORY• • • • • Repository
  55. 55. • Entity LifeCycle• LC Entity• new • On Memory Collection • Database
  56. 56. Repos. Collection• DB• Repository Collection• store / delete / find (resolve) ...
  57. 57. Declaration & ReferenceCREATE TABLE FOOBAR ( FOO INTEGER, BAR VARCHAR(32), Decl. = Entity PRIMARY KEY (FOO), FOREIGN KEY (BAR) Ref. = VO (ID) REFERECE BAZ (QUX)); Table has-a Column(s) and ... PrimaryKey has-a ColumnReference
  58. 58. • /• ENTITY / VO / SERVICE• FACTORY / REPOSITRY• DDD

×