17-Jan-2003 - PowerPoint PPT Presentation

About This Presentation
Title:

17-Jan-2003

Description:

Reading Questions. Lecture Contents. Binary association classes and ... Continuing this logic may ultimately lead to. complete separation of Model with Views ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 13
Provided by: georgeh1
Learn more at: http://web.cs.wpi.edu
Category:
Tags: jan | logic | questions

less

Transcript and Presenter's Notes

Title: 17-Jan-2003


1
Binary Association Classes and their
Implementation
  • 17-Jan-2003
  • Lecture 6

2
Outline
  • Previous Business
  • HW1 assigned
  • posted instructions to run examples
  • Reading Questions
  • Lecture Contents
  • Binary association classes and their
    implementation

3
Reading Questions
  • TBA

4
Extend our MVC
  • What if wanted views to have priorities?
  • the model should propagate change events
    according to the priority of the views
  • higher priority views receive events ahead of
    lower priority views
  • This complicates model

5
Model/View could look like
  • Overly complicated implementation
  • we should move relationship into association
    class
  • separate model from process view updates

notifies
1

Model
IListener
Sort by priority whenregistering Issue
modelChangedas before
6
Model/View should look like
  • Outsource the complexity into its own class
  • ModelManager contains update algorithm
  • subclasses overriding can replace algorithm
  • IListener objects register with ModelManager

Model
IListener

1
notifies
ModelManager
ModelManager
1
1
listeners IListener priorities int
IListener
ModelManager (Model m) register (IListener
listener, int priority) notifyAll ()
modelChanged (Model m)
7
Model/View
  • Continuing this logic may ultimately lead to
  • complete separation of Model with Views
  • putting view update logic into controller
  • All design evolves
  • Split class into two
  • Elevate attribute into class
  • Make association link into association class

8
Association and Links
  • A link between two objects can possess its own
    properties
  • this is a powerful statement!
  • these link properties do not exclusively belong
    to either class involved in the association
  • simplify host classes

9
Binary Association Classes
  • Complexity reduction even more impressive when
    bidirectional relationships
  • both affected classes are made simpler

C1
C2
Items C2
Items C1


prop1 intprop2 String
prop1 int Prop2 String
10
Specific Java Mechanisms
  • Inner Classes
  • When a class is used by only one class
  • When you want to restrict access
  • Note that inner class can access any method/data
    of its outer class.
  • Anonymous Classes
  • Look inside main() method.
  • Bridges between existing classes
  • Typically used for anonymous listeners

11
Monday Assignments
  • Get started on the homework which is due by the
    start of class.
  • design books will be accepted ONLY at the
    beginning of class
  • electronic submission of assignment must be
    received by 400 PM
  • any late assignments will be ungraded

12
References
  • None
Write a Comment
User Comments (0)
About PowerShow.com