Unformatted text preview:

FrameworksSlide 2Framework isSlide 4Inversion of ControlParts of Framework ApplicationHistory of MVCSlide 8Slide 9Model/View/ControllerSlide 11Slide 12Counter applicationModel as Application Objectmore Counter1) Building model and view2) Parameterizing controller3) Opening windowperform:Slide 20Summary of Counter for Old MVCSlide 22Counter for VisualWorksCounterAppWhat is Really HappeningDirect Manipulation Interface for Old MVCCounterControllerStarting new applicationUsing New Controller in VWSlide 30MVC InterfacesMVC interfacesDance of the ObjectsInvariantsStrategy PatternControllers as StrategyController methods: redefineController methods: useController Template MethodsSlide 40Template MethodsView HierarchySome View SubclassesViewsSlide 45Slide 46CounterViewSlide 48Slide 49(continued)Slide 51CounterView class for Old MVCSlide 53Using CounterView in VisualWorksSlide 55Defining old MVC applicationDefining new MVC applicationComposite PatternSlide 59VisualComponents and GraphicsGraphicsContextGraphicsContext protocolSlide 63Scrollbar>>displayOn: aGCVisualComponent HierarchyWhite-box vs. Black-box FrameworksSlide 67White-box to Black-boxPatterns in MVCComposing Frameworks01/13/19 FrameworksModel/View/Controller01/13/19 FrameworksInterface design and functional factoring constitutes the key intellectual content of software and is far more difficult to create or re-create than code. Peter Deutsch01/13/19 Framework isthe design of an application or subsystem expressed as a set of abstract classes andthe way objects in those classes collaborate.01/13/19 Use framework to build application by:• Creating new subclasses• Configuring objects together• Modifying working examples(editing scripts)01/13/19 Inversion of ControlSubroutine libraryUser's program calls reused code.User designs structure of program.FrameworkReused code calls user's programStructure of program determined primarily by reused code.01/13/19 Parts of Framework ApplicationNew classesScript that specifies classes of components by  creating components connecting components parameterizing components01/13/19 History of MVCFirst version: 1980 -- subclass for each pane to adapt to modelPluggable views: 1983 -- specify messages to send to model with symbols01/13/19 History of MVCObjectWorks 4.0: 1989 -- compose model from value holders, compose view from Wrappers, CompositesVisualWorks: 1992 -- UI builderVisualWorks: 1998 -- event driven Controllers01/13/19 ModelView Controllerdependents01/13/19 Model/View/ControllerModelapplication objectno user interfaceViewmaintains image of modelowns region of screennested01/13/19 Model/View/ControllerControllerconverts user actions into messageschanges state of model01/13/19 Model/View/ControllerView-Model ObserverView-Controller StrategyView-View CompositeView-Controller Factory MethodView-View Decorator01/13/19 Counter applicationNew subclass of ModelReuse subclasses of ViewMake script to build View01/13/19 Model as Application ObjectCounter is a subclass of Model with instance variable valuedecrementvalue > 0 ifTrue: [value := value - 1. self changed]01/13/19 more Counterincrement value := value + 1.self changedinitializevalue := 001/13/19 1) Building model and view| aView aModel aWindow |aView := ComposedTextView new.aModel := Counter new initialize.aView model: (TypeConverter onNumberValue: aModel).01/13/19 2) Parameterizing controlleraView controller menuHolder value: (Menu labels: 'inc\dec' withCRs lines: #() values: #( #increment #decrement )).aView controller performer: aModel.01/13/19 3) Opening windowaWindow := ScheduledWindow new.aWindow component: (LookPreferences edgeDecorator on: aView).aWindow open01/13/19 perform:Objectperform: aSymbol sends the message named by aSymbol to the receiver.perform: aSymbol withArgs: anArray sends the message named by aSymbol to the receiver and uses anArray as the arguments.01/13/19 perform:All objects inherit perform:.model perform: #menuMain use:pluggable viewsmenusCan often be replaced by blocks01/13/19 Summary of Counter for Old MVCParagraphEditor sends increment and decrement messages to Counter.ComposedTextView sends value to TypeConverter, which sends it to Counter.Counter sends update: to TypeConverter, which sends it to ComposedTextView.01/13/19 TypeConverterTypeConverterComp.TextViewComp.TextViewParagraphEditorParagraphEditorCounterCounter01/13/19 Counter for VisualWorksUse UI builder to define an Application Model called CounterApp.Define input field with an aspect #countHolder. Define a menu with "increment" and "decrement" on it.Define methods (using browser)01/13/19 CounterAppincrementcountHolder value: (countHolder value + 1)decrement(countHolder value > 0) ifTrue: [countHolder value: (countHolder value - 1)]01/13/19 What is Really HappeningWindowWindowInputBoxInputBoxViewViewInputBoxInputBoxControllerControllerValueHolderValueHolderCounterAppCounterAppCounterApp has a WindowSpec, CounterApp has a WindowSpec, which is used to specify the which is used to specify the window that is created for it.window that is created for it.01/13/19 Direct Manipulation Interface for Old MVCEliminate menus -- one button increments, one decrementsCounterController is a subclass of ParagraphEditor01/13/19 CounterControllercontrolActivityself sensor redButtonPressed & self viewHasCursor ifTrue: [[self sensor redButtonPressed] whileTrue. self performer increment].“decrement when yellowButtonPressed “super controlActivity01/13/19 Starting new applicationaView controller: CounterController new.aView controller menuHolder value: (Menu labels: 'inc\dec' withCRs lines: #() values: #( #increment #decrement )).aView controller performer: aModel.01/13/19 Using New Controller in VWIt is harder to insert new controller into view hierarchy because ApplicationModel builds view hierarchy automatically from the windowSpec.Must modify view after the window has been built.CounterApppostBuildWith: aBuilder| widget oldController |widget := (builder componentAt: #counterView) widget.oldController := widget controller.widget controller: CounterController new.widget controller performer: oldController performer.01/13/19 MVC InterfacesController-Viewview is responsible for its controllerview is responsible for its area on the screenview is responsible for its subviewview can scroll itselfview can redisplay itself01/13/19 MVC interfacesController-Modelmodel keeps track of its


View Full Document

UIUC CS 497 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?