1 / 39

Implementing BabyUML Discipline of Programming Workshop

Learn how to implement the BabyUML discipline of programming workshop, which focuses on creating comprehensible programs using the divide and conquer approach with components. This workshop provides examples and explanations on how to frontload activities and ensure the correct structure of a network.

luciler
Download Presentation

Implementing BabyUML Discipline of Programming Workshop

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to Implement the BabyUMLDiscipline of Programming Workshop: How to do it. rOOts 2005 Trygve Reenskaug University of Oslo http://heim.ifi.uio.no/~trygvertrygver@ifi.uioi.no BabyUML workshop rOOts 2005

  2. Summary-1:Deal With Comprehensible Programs All Meaningful Programs All Comprehensible Programs All Programs Two ways of constructing asoftware design (C.A.R. Hoare) Make it 1) so simple that there are obviously no deficiencies 2) so complicated that there are no obvious deficiencies. BabyUML workshop rOOts 2005

  3. Summary-2:Divide and Conquer with Components «Component»ProductionControl Accounting MaterialsManagement «Port» «Component» sampleNet actA actC (2) (3) actD (2)<2203> actB (7) «Port» «Port» Design Manufacturing «Port» «Port» BabyUML workshop rOOts 2005

  4. Example:Activity Network Frontloading ActA ActB actA actC (2) (3) ActC actD (2) ActD actB (7) 1 2 3 4 5 6 7 8 9 week BabyUML workshop rOOts 2005

  5. First Example:Frontloading a simple network == newActivity:duration: (aString, anInteger) «SimpleComponent» «port» sampleNet <0321> «MasteredComponent» «port» sampleNet <0724> «DeclarativeComponent» « port» sampleNet <1931> «interface» newActivity: aString duration: anInteger addDependencyFrom: actName1 to: actName2 frontload: firstWeek activityNames activityDescriptor: actName provided required sampleNetTester test BabyUML workshop rOOts 2005

  6. NetworkTesterclass definition Object subclass: #NetworkTesterinstanceVariableNames: 'activitiesData simpleComponent maestroComponent declarativeComponent’ BabyUML workshop rOOts 2005

  7. NetworkTesterinitialize initialize super initialize. activitiesData := Set new. self createDictA. self createDictB. self createDictC. self createDictD. BabyUML workshop rOOts 2005

  8. NetworkTestercreateDictD == at:put: (’name’, ’actD’) createDictD | dict | dict := Dictionary new. dict at:'name'put:'actD'. dict at: 'duration' put: 2. dict at: 'successors' put: #(). dict at: 'predecessors' put: #('actC' 'actB'). dict at: 'earlyStart' put: 8. dict at: 'earlyFinish' put: 9. activitiesData add: dict. BabyUML workshop rOOts 2005

  9. NetworkTestertest self initialize. " Test SimpleComponent. “ simpleComponent := SimplePort new initialize. self runPort: simpleComponent. self checkPort: simpleComponent. " Test MaestroComponent. " maestroComponent := MaestroPort new initialize. self runPort: maestroComponent. self checkPort: simpleComponent. " Test DeclarativeComponent. " declarativeComponent := DeclarativePort new initialize. self runPort: declarativeComponent. self checkPort: simpleComponent. " Inspect. " self inspect. BabyUML workshop rOOts 2005

  10. NetworkTesterrunPort: port " Define activities. " activitiesData do: [:dict | port newActivity: (dict at: 'name') duration: (dict at: 'duration')]. " Define dependencies. " activitiesData do: [:actdict | (actdict at: #predecessors) do: [:predNam | port addDependencyFrom: predNam to: (dict at: 'name')]. ]. " Frontload. " port frontload: 1. BabyUML workshop rOOts 2005

  11. NetworkTestercheckPort: port port activityNames = (activitiesData collect: [:dict | dict at: 'name']) ifFalse: [self error]. activitiesData do: [:indict || outdict | outdict := port activityDescriptorFor: (indict at: 'name'). indict keys = outdict keys ifFalse: [self error: ‘different activities’] indict keys do: [:key | (indict at: key) = (outdict at: key) ifFalse: [self error: key]]. BabyUML workshop rOOts 2005

  12. Object structureNetworkTester BabyUML workshop rOOts 2005

  13. Test SimpleComponent «SimpleComponent» «port» sampleNet <0321> «MasteredComponent» «port» sampleNet <0724> «DeclarativeComponent» « port» sampleNet <1931> «interface» newActivity: aString duration: anInteger addDependencYFrom: actName1 to: actName2 frontload: firstWeek activityNames ActivityDescriptor: actName provided required sampleNetTester test BabyUML workshop rOOts 2005

  14. SimplePortclass + frontLoad: firstWeek Object subclass: #SimplePort instanceVariableNames: 'activities‘. frontload: firstWeek activities do: [:act | act resetFrontload]. (activities select: [:act | act predecessorsisEmpty]) do: [:act | act frontload: firstWeek] • What are activities? • What are their predecessors? • How does it frontload: ? BabyUML workshop rOOts 2005

  15. SimpleActivityfrontload: start earlyStart ifNil: [counter := 0. earlyStart := start] ifNotNil: [earlyStart := (start max: earlyStart)]. counter := counter+1. counter >= predecessors size ifTrue: [successors do: [:succ | succ frontload: self earlyFinish + 1]]. • What are activities? • What are predecessors and successors ? • Do all activities frontload the same way ? BabyUML workshop rOOts 2005

  16. SimpleActivityclass definition Object subclass:#SimpleActivity instanceVariableNames: 'name duration earlyStart predecessors successors counter' • What are activities? • What are predecessors and successors ? • Do all activities frontload the same way ? BabyUML workshop rOOts 2005

  17. SimpleActivitypredecessor: pred predecessor: pred (predecessors includes: pred) ifFalse: [predecessors add: pred. pred successor: self ]. • What are activities? - OK • What are predecessors and successors - OK • Do all activities frontload the same way ? • What about predecessors/successors integrity ? BabyUML workshop rOOts 2005

  18. The Simple Component <0321> port <2200> actA <2261> actB <2272> actC <2203> actD (2) (7) (3) (2) frontload (1) frontload (1) frontload (3) frontload (6) frontload (1) frontload (8) sampleNet «Component» members <2203> actD < 0321 > « port» name = ' actD' newActivity (name : String, duration : Integer) duration = 2 addDependency (from, to : String) earlyStart = 8 frontload (firstWeek : Integer) earlyFinish = 9 () : String [] {sorted} activityNames predecessors = { actB . ' actC .} activityDescriptor (name: String) : Dictionary successors { } frontload ( firstWeek : Integer) example- white5 BabyUML workshop rOOts 2005 firstWeek : Integer)

  19. The objects of theSimpleComponent test Bowl of noodles? BabyUML workshop rOOts 2005

  20. Test Mastered Component «SimpleComponent» «port» sampleNet <0321> «MasteredComponent» «port» sampleNet <0724> «DeclarativeComponent» « port» sampleNet <1931> «interface» newActivity: aString duration: anInteger addDependencYFrom: actName1 to: actName2 frontload: firstWeek activityNames ActivityDescriptor: actName provided required sampleNetTester test BabyUML workshop rOOts 2005

  21. The MasteredComponent BabyUML workshop rOOts 2005

  22. MaestroPortclass + essential methods Object subclass: #MaestroPort    instanceVariableNames: 'maestro publicSelectors' initialize super initialize.    maestro := MaestroMaestro new initialize.publicSelectors := #(activityDescriptorFor: activityNamesSorted addDependencyFrom:to: frontload: newActivity:duration: doesNotUnderstand: aMessage ^(publicSelectors includes: aMessage selector)ifTrue: [aMessage sendTo: maestro]ifFalse: [super doesNotUnderstand: aMessage] • An implementation of the facade pattern BabyUML workshop rOOts 2005

  23. MaestroMaestrofrontload: firstWeek | frontActs |activities do: [:act | act resetFrontload].[(frontActs := activities select:             [:act | act earlyStart isNil and: [act predecessors allSatisfy: [:pred | pred earlyStart notNil]]) ] notEmpty] whileTrue:            [frontActs do: [:act | act frontload: firstWeek] ] • xxx? BabyUML workshop rOOts 2005

  24. MaestroActivityfrontload: start frontload: start earlyStart := start.predecessors do: [:pred | earlyStart := earlyStart max: pred earlyFinish + 1] • xxx? BabyUML workshop rOOts 2005

  25. The Mastered ComponentInteraction <2646>actB <144>actD <1131>actA <2813>actC <2322> maestro (2) (7) (3) (2) frontload: 1 frontload: 1 frontload: 1 frontload: 1 frontload: 1 BabyUML workshop rOOts 2005

  26. Centralized Delegated Delegated Centralized BabyUML workshop rOOts 2005

  27. The Coffee Machine Design Problem:version 1 BabyUML workshop rOOts 2005

  28. Test Declarative Component «SimpleComponent» «port» sampleNet <0321> «MasteredComponent» «port» sampleNet <0724> «DeclarativeComponent» « port» sampleNet <1931> «interface» newActivity: aString duration: anInteger addDependencYFrom: actName1 to: actName2 frontload: firstWeek activityNames ActivityDescriptor: actName provided required sampleNetTester test BabyUML workshop rOOts 2005

  29. Separation of concernThree Schema Architecture External How are they used? External External External External Schema Schema Schema Schema Schema External Mapping What are thecomponent members? Conceptual Schema Internal Mapping How are they implemented? External Schema External Schema Thanks to Ragnar Normann BabyUML workshop rOOts 2005

  30. The Declarative ComponentConceptual Schema Activity name: pred duration: * earlyStart / earlyFinish * succ BabyUML workshop rOOts 2005

  31. The Declarative ComponentLayered – External Schemas BabyUML workshop rOOts 2005

  32. The Declarative Componentfrontloading sequence diagram maestro frontload : firstWeek activitiesContext activities «Collaboration» frontContext resetEarlyStart frontAct frontPreds loop queries frontContext Network frontAct frontPreds «schema» frontload : firstWeek Activity pred name: duration: * earlyStart / earlyFinish * succ [frontAct notNil] example- frontload8 BabyUML workshop rOOts 2005

  33. DeclarativeMaestrofrontload: firstWeek maestro frontload : firstWeek activitiesContext activities resetEarlyStart loop frontContext context := base activitiesContext.(context at: 'activities') do: [:act | act resetFrontloadInContext: context ]. [context := base frontContext.(context at: 'frontAct') notNil ] whileTrue: [ (context at: 'frontAct') frontload: firstWeek inContext: context. ]. [frontAct notNil] frontAct frontPreds : frontload: firstWeek inContext: context BabyUML workshop rOOts 2005

  34. DeclarativeActivityfrontload: firstWeek inContext: context frontload:firstWeekinContext:context earlyStart := firstWeek.    (context at: 'frontPreds') do: [:pred | earlyStart := (earlyStart max: (pred earlyFinish + 1))]. • xxx? BabyUML workshop rOOts 2005

  35. DeclarativeBasefrontContext (ODMG) • define query frontActivities as • select act • from activities • where act.earlyStart.isNil • and • ( select succ • from dependencies • where succ = act • and pred.earlyStart.isNil) • ) isEmpty BabyUML workshop rOOts 2005

  36. DeclarativeBasefrontContext (Smalltalk) frontActs := activities select: [:act | act earlyStart isNil and: [(self predecessorsOf: act) noneSatisfy: [:pred | pred earlyStart isNil]]. ]. cntx := Dictionary new. frontActs ifEmpty: [cntx at: 'frontAct' put: nil. cntx at: 'frontPreds' put: Array new] ifNotEmpty: [thisAct := frontActs anyOne. cntx at: 'frontAct' put: thisAct. cntx at: 'frontPreds' put: (self predecessorsOf: thisAct)]. ^cntx BabyUML workshop rOOts 2005

  37. Summary:A Discipline of ProgrammingCombining Three Architectures Output Output Input Input Central Processing Unit Input Communication Bus Central Processing Unit Central Processing Unit Output Memory Disk Memory Tape Tape Disk Memory Tape Communication-Centered CPU-Centered Storage-Centered Procedures Databases [4GL] Schema Language(NIAM) [1G L]Binary HTTP / HTML [ 2GL ] Assembly [3GL++] C ++, Java, C # [ 3GL ]FORTRAN, Algol Methods Conceptual schema (classes) External schema (collaboration) Internal schema (classes) Components Interactions BabyUML workshop rOOts 2005

  38. Thank You More info at heim.ifi.uio.no/~trygver BabyUML workshop rOOts 2005

  39. More details …. http://www.ifi.uio.no/~trygvermailto: trygver ‘at’ ifi.uio.no Trygve Reenskaug: Towards a New Discipline of Programming with the BabyUML Language Laboratory.http://heim.ifi.uio.no/~trygver/2005/babyuml/BabyUML.book.pdf [UML] Unified Modeling Language: Superstructure. Version 2.0.Object Management Group. Document ptc/04-10-02 or later http://www.omg.org Edsger Dijkstra: A Discipline of Programming, 1976 Trygve Reenskaug: Empowering People with BabyUML: A sixth GenerationProgramming Language. Opening talk, ECOOP 2004, Oslo.http://heim.ifi.uio.no/~trygver/2004/ECOOP-04/EcoopHandout.pdf Model Driven Architecture See: http://www.omg.org/mda/ Cattell, Barry: The Object Data Standard: ODMG 3.0. Academic Press,London, 2000. ISBN 1-55860-647-4 Erik Arisholm and Dag Sjøberg, A Controlled Experiment with Professionals to Evaluate the Effect of a Delegated versus Centralized Control Style on the Maintainability of Object-Oriented Software, Simula Research Laboratory Technical Report 2003-6http://www.simula.no/publication_one.php?publication_id=601 Alistair Cockburn: The Coffee Machine Design Problem: Part 1.http://alistair.cockburn.us/crystal/articles/cmdp1/coffeemachineproblem1.htm BabyUML workshop rOOts 2005

More Related