Unformatted text preview:

1Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 567How to Design FrameworksObject-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 568Framework is• the design of an application orsubsystem• expressed as• a set of abstract classes and• the way objects in those classescollaborate.2Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 569Use framework to build application by:• Creating new subclasses• Configuring objects together• Modifying working examples(editing scripts)Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 570Inversion of ControlSubroutine library• User's program calls reused code.• User designs structure of program.Framework• Reused code calls user's program• Structure of program determinedprimarily by reused code.3Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 571Parts of Framework ApplicationNew classesScript that specifies classes ofcomponents by• creating components• connecting components• parameterizing componentsObject-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 572Testing FrameworkClasses - Test, TestResult, TestSuiteUse by subclassing TestDefine instance methods to set up test, toperform testsDefine class methods to create a testsuite4Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 573Model/View/ControllerClasses - Model, View, Controller,ApplicationModel, ValueModel, etc.Use by using GUI builder to make ascreen; the GUI builder automaticallybuilds an ApplicationModel and awindow-spec that later gets interpretedto build a window.Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 574HotDrawClasses - Figure, Drawing, Handle, Tool,DrawingEditorSubclass DrawingEditor, Figure, rarelyDrawingParameterize Handle, Tool.There is a graphical tool for defining newTools.5Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 575 White-box vs. Black-boxBlack-boxCustomize byconfiguringEmphasizepolymorphismMust knowinterfacesWhite-boxCustomize bysubclassingEmphasizeinheritanceMust knowinternalsObject-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 576(continued)White-boxSimpler, easier todesignHarder to learn,requires moreprogramming.Black-boxComplex, harder todesignEasier to learn,requires lessprogramming.6Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 577First Rule of Framework DesignDon’t. Buy one, instead.Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 578Relevant PrinciplesFrameworks are abstractions: peoplegeneralize from concrete examplesDesigning reusable code requires iterationFrameworks encode domain knowledgeCustomer of framework is applicationprogrammer7Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 579Generalize from Concrete CasesPeople think concretely, not abstractly.Abstractions are found bottom-up, byexamining concrete examples.Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 580To Generalize:• find things with different names that arereally the same,• parameterize to eliminate differences,• break large things into small things sothat similar components can be found,and• categorize things that are similar.8Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 581Finding Abstract ClassesAbstract classes are discovered bygeneralizing from concrete classes.To give classes a common superclass:• give operations common interface• move operations with sameimplementation to superclass• make operations with differentimplementation abstractObject-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 582(continued)• give them common interface• + rename operations so classes usesame names• + reorder arguments, change types ofarguments, etc.• + refactor (split or combine)operations9Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 583Frameworks Require IterationReusable code requires many iterations.Basic law of software engineering If it hasn’t been tested, it doesn’twork.Corollary: software that hasn’t beenreused is not reusable.Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 584Frameworks EncodeDomain KnowledgeFrameworks solve a particular set ofproblems.Not always application-domain specific,but domain specific. (GUI,distribution, structured drawing editor,business transaction processing,workflow)10Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 585Customers are ProgrammersPurpose of framework is to make it easierto build applications.Apply these slogans to applicationprogrammers:• The customer is always right.• We are customer-driven.• Understand your customer.Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 586Example-driven DesignGeneralization is iterative.Most changes are small.A few big changes represent new ways oflooking at the problem.ExamplesFrameworkGeneralization11Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 587To generalize faster:• • get different points of view• • explain/defend current designTimeSystemsizeObject-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 588Ideal Way to Develop Framework1) Analyze problem domain• Learn well-known abstractions.• Collect examples of programs to bebuilt from framework. (Minimum of 4or 5).AnalysisDesignTest12Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 589Ideal Way to Design Framework2) Design abstraction that coversexamples.3) Test framework by using it to solve theexamples.• • Each example is a separateapplication.• • Performing a test means writingsoftware.Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 590Designing AbstractionsDesign phase: look for commonalities,represent each idea once.Use design patterns• implies that experience is neededInsight and ingenuity is always useful, buthard to schedule.13Object-oriented Programming and Design - Copyright 1998 by Ralph E. Johnson 591Design PatternsDesign patterns make designs more black-box.Show how to represent something thatchanges as an object• • Strategy -- algorithm• • Prototype -- products• • State -- state of an object• • Mediator -- way


View Full Document

UIUC CS 497 - How to Design Frameworks

Download How to Design Frameworks
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 How to Design Frameworks 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 How to Design Frameworks 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?