Presentation is loading. Please wait.

Presentation is loading. Please wait.

MVC and DCA: Two complimentary system architectures.

Similar presentations


Presentation on theme: "MVC and DCA: Two complimentary system architectures."— Presentation transcript:

1 MVC and DCA: Two complimentary system architectures.
MVC and DCA: JavaZone 2006 Thursday, November 29, 2018 MVC and DCA: Two complimentary system architectures. Trygve Reenskaug Department of Informatics University of Oslo Java code at MVC and DCA: JavaZone 2006 ©2006 Trygve Reenskaug

2 The price of reliability is the pursuit of the utmost simplicity
The BabyUML Project The essence of object orientation is that objects interact to accomplish some desired functionality. The price of reliability is the pursuit of the utmost simplicity (C.A.R. Hoare, 1980 Turing Award lecture) BabyUML Goal: Answer explicitly What are the objects? How are they interlinked? How do they interact? Do more – type less MVC and DCA: JavaZone 2006

3 Model – View - Controller
MVC and DCA: JavaZone 2006 Thursday, November 29, 2018 Model – View - Controller mental model computer data Model View bridges gap between user Mental model and Computer data View User MVC and DCA: JavaZone 2006 ©2006 Trygve Reenskaug

4 Model – View - Controller
MVC and DCA: JavaZone 2006 Thursday, November 29, 2018 Model – View - Controller Controller creates and coordinates multiple Views View Controller * 1 mental model computer data Model View bridges gap between user Mental model and Computer data View User Run Demo MVC and DCA: JavaZone 2006 ©2006 Trygve Reenskaug

5 MVC and DCA: JavaZone 2006 Thursday, November 29, 2018 MVC Demo MVC and DCA: JavaZone 2006 ©2006 Trygve Reenskaug

6 The Anatomy of MVC Demo controller :Controller
MVC and DCA: JavaZone 2006 The Anatomy of MVC Demo Thursday, November 29, 2018 controller :Controller panelView :DependencyPanel :ActivityView MVC and DCA: JavaZone 2006 ©2006 Trygve Reenskaug

7 MVC example Synchronized Selection
MVC and DCA: JavaZone 2006 Thursday, November 29, 2018 MVC example Synchronized Selection User focusView controller activityView* pointAndClickMouse actionPerformed() selectionChanged() isSelected() present MVC and DCA: JavaZone 2006 ©2006 Trygve Reenskaug

8 MVC example Synchronized Selection
MVC and DCA: JavaZone 2006 Thursday, November 29, 2018 MVC example Synchronized Selection User class Controller { Activity selection; inputView controller leafView* public void actionPerformed (ActionEvent e) { ActivityView source = (ActivityView) e.getSource(); selection = source.activity(); for (ActivityView view : activityViews) { view.selectionChanged(); } repaint(); pointAndClickMouse actionPerformed() selectionChanged() isSelected() public boolean isSelected (Activity act) { return ( selection == act ); } present MVC and DCA: JavaZone 2006 ©2006 Trygve Reenskaug

9 Model – View - Controller
MVC and DCA: JavaZone 2006

10 the Model as a single Object
illustration copied from The Java Tutorial Copyright Sun Microsystems, Inc. methods (behavior) derived attributes owned attributes (state) MVC and DCA: JavaZone 2006

11 the DCA Model Component Data + Collaboration + Algorithm
Algorithms Collaborations Data activities allocations dependencies resource netBase member Objects (behavior) (derived attributes) (external data view) (owned attributes) (base data) MVC and DCA: JavaZone 2006

12 DCA netBase – UML schema
predecessor Activity successor Dependency name earlyStart earlyFinish duration color * Data activities allocations dependencies resource netBase DependencyPanel DependencyPanel GanttPanel ResourcePanel MVC and DCA: JavaZone 2006

13 Java as schema language
DCA netBase - Java public class Activity { private Integer earlyStart, earlyFinish, duration; private String name; private Color color = Color.gray; …. public class BabyBase extends Observable implements Observer { private Set<Activity> activities; private Set<MemberDependency> dependencies; public class MemberDependency { private Activity predecessor, successor; ... Java as schema language activities allocations dependencies resource netBase Data (state) MVC and DCA: JavaZone 2006

14 First DCA example DependencyPanel layout + collaboration
activities allocations dependencies resource Base network Base DependencyPanel layout Algorithm (behavior) GanttPanel Collaboration (external data view) Data (state) ResourcePanel MVC and DCA: JavaZone 2006

15 DCA ex.1: DependencyPanel responsible for layout Algorithm
layout Algorithm (behavior) Model private void addActivityViews() { // Compute gridX, gridY, x0, y0, buttonExtent for (int rank=0; rank <= rankedCollab.maxRank(); rank++) { // compute xPos, yPos for (Activity act : rankedCollab.activityListAtRank(rank)) { ActivityView actView = new ActivityView(controller, act, 24) ; add (actView); yPos = yPos + gridY; // misc. computations } activities allocations dependencies resource Base network Base DependencyPanel layout Algorithm (behavior) GanttPanel Collaboration (external data view) Data (state) ResourcePanel MVC and DCA: JavaZone 2006

16 DCA ex.1: RankedCollab Query
Model define activityListAtRank(Integer rank) as select act from activities act where rank(act) = rank activities allocations dependencies resource netBase DependencyPanel rankedCollab (external data view) GanttPanel Data (state) ResourcePanel MVC and DCA: JavaZone 2006

17 DCA ex.1: RankedCollab Java
Model activities allocations dependencies resource netBase public List<Activity> activityListAtRank (Integer rank) { List<Activity> activityListAtRank = new ArrayList<Activity>(); for (Activity act : bBase. allActivities()) { if (rankOf(act) == rank) { activityListAtRank.add(act); } return activityListAtRank ; DependencyPanel layout Algorithm (behavior) rankedCollab (external data view) GanttPanel Data (state) ResourcePanel MVC and DCA: JavaZone 2006

18 Second DCA example frontloading
Model Compute earlyStart activities allocations dependencies resource Base network Base Identify activity for frontloading Compute earlyFinish Algorithms (behavior) Collaborations (external data views) Data (state) MVC and DCA: JavaZone 2006

19 DCA ex.2: frontloading query - frontloader
Model activities allocations dependencies resource Base network Base define frontloader as (select act from Activities act where act.earlyStart == null and (for all pred in predecessors(act): pred.earlyStart != null) ) someInstance Algorithms (behavior) DependencyPanell GanttPanel Collaborations (external data views) BabyDataBase (state) ResourcePanel MVC and DCA: JavaZone 2006

20 DCA ex.2: frontloading Java - frontloader
Model activities allocations dependencies resource Base network Base private boolean areAllDone(Set<Activity> actSet) { boolean allPredsDone = true; for ( Activity pred : actSet) { if (pred.earlyStart() == null) { allPredsDone = false; break; } return allPredsDone; public Activity frontloader() { for (Activity act : netBase.allActivities()) { if (act.earlyStart() == null) { Set<Activity> predSet = predecessorsOf(act); if (areAllDone(predSet)) { frontloader = act; return (frontloader); return null; public Activity frontloader() { for (Activity act : netBase.allActivities()) { if (act.earlyStart() == null) { Set<Activity> predSet = predecessorsOf(act); if (areAllDone(predSet)) { frontloader = act; return (frontloader); } return null; private boolean areAllDone(Set<Activity> actSet) { boolean allPredsDone = true; for ( Activity pred : actSet) { if (pred.earlyStart() == null) { allPredsDone = false; break; return allPredsDone; Algorithms (behavior) DependencyPanell GanttPanel Collaborations (external data views) BabyDataBase (state) ResourcePanel MVC and DCA: JavaZone 2006

21 DCA ex.2: frontloading frontload algorithm - Java
Model public void frontload (Integer startWeek) { Activity frontloader; while ((frontloader = frontloadCollab.frontloader()) != null) { Integer earlyStart = startWeek; for (Activity pred : frontloadCollab.frontPredecessors()) { earlyStart = Math.max(earlyStart, pred.earlyFinish() + 1); } frontloader.setEarlyStart(earlyStart); activities allocations dependencies resource Base network Base Algorithms (behavior) DependencyPanell GanttPanel Collaborations (external data views) BabyDataBase (state) ResourcePanel MVC and DCA: JavaZone 2006

22 Second DCA example compute earlyFinish
Model activities allocations dependencies resource Base network Base public Integer earlyFinish() { if (earlyStart != null) { return (earlyStart + duration – 1); } else { return null; } Algorithms (behavior) Collaborations (external data views) Data (state) MVC and DCA: JavaZone 2006

23 MVC – DCA Critique MVC separate Model and View DCA
when GUI and Model are deployed on different machine. when the application code is complex. write several View classes for the same Model class when the user needs to see the Model from several perspectives. write a Controller class to create and coordinate the Views when the user needs to see them simultaneously. DCA simplify Data with a baby database when the data structure is not obvious from the code. separate out data queries in Collaboration classes if Algorithms need to see data from different perspectives. create a separate Algorithm class if the Algorithm spans several member objects. MVC and DCA: JavaZone 2006

24 The BabyUML Project Status
The essence of object orientation is that objects interact to accomplish some desired functionality. The price of reliability is the pursuit of the utmost simplicity (C.A.R. Hoare, 1980 Turing Award lecture) BabyUML Goal: Answer explicitly What are the objects? Database schema How are they interlinked? Collaboration How do they interact? Algorithm Do more – type less Remains to be done MVC and DCA: JavaZone 2006

25 Java code and comments at
That’s all, thank you Questions? Java code and comments at MVC and DCA: JavaZone 2006

26 More reading MVC and DCA: JavaZone 2006 Thursday, November 29, 2018
mailto: trygver ‘at’ ifi.uio.no dca-demo example code: Trygve Reenskaug: Original MVC notes from Xerox PARC Charles Antony Richard Hoare: The Emperor's Old Clothes Turing Award lecture. Comm.ACM 24, 2 (Feb. 1981) Trygve Reenskaug: The BabyUML discipline of programming (where A Program = Data + Communication + Algorithms). SoSym 5,1 (April 2006). DOI: /s x. Unified Modeling Language: Superstructure. Version Object Management Group (OMG) document ptc/ Cattell, Barry: The Object Data Standard: ODMG Academic Press, London, ISBN Erik Arisholm and Dag Sjøberg: A Controlled Experiment with Professionals to Evaluate the Effect of a Delegated versus Centralized Control …, Simula Research Laboratory Technical Report Reenskaug, Wold, Lehne: Working With Objects. This book is out of print. A .pdf version kan be downloaded free from Donald A. Norman: The Design of Everyday Things. Doubleday/Currency ISBN MVC and DCA: JavaZone 2006 ©2006 Trygve Reenskaug


Download ppt "MVC and DCA: Two complimentary system architectures."

Similar presentations


Ads by Google