190 likes | 324 Views
CSE 111: Object Oriented Design. Design. “To program is human but to design is divine” (WEH). What is a Design?. Different possibilities, e.g. Algorithmic strategy e.g. rate-monotonic scheduling strategy for a real time system Decomposition of a system
E N D
Design “To program is human but to design is divine” (WEH)
What is a Design? • Different possibilities, e.g. • Algorithmic strategy • e.g. rate-monotonic scheduling strategy for a real time system • Decomposition of a system • modules with well-defined consistent interfaces • Abstract function hierarchy • abstract functions defined in terms of less abstract functions
Design and Abstraction • Design uses abstraction to create views that are comprehensible • Vs the complete code for the program that cannot be comprehended all at the same time • breaking down a system into pieces involves an abstract model that ties the pieces together
Why Design? • Provides an overall picture of the system • Allows us to focus on one thing at a time • A harmonious, understandable design is our best hope for constructing a program that works • Facilitates (design) reuse (NOT code reuse): transmission of expert knowledge
No Design? • Possible for simple or small well- understood programs • For complex systems: 85% phenomenon • milestone 1: 50% done • milestone 2: 75% done • milestone 3: 85% done • milestone 4: 85% done • milestone 5: 85% done .........
Design Paradigms – Functional 1 • Basic components: functions/procedures • Component relationships: one function calls other functions • Abstraction • one function calls another • defined in terms of less abstract or concrete functions
Design Paradigms - Functional 2 • Design strategy • top level function corresponds to program requirements • define this in terms of less abstract functions • continue on down until all functions are concrete • Refactoring: go back and re-design higher level functions if design becomes ugly
Design Paradigms – Object Oriented 1 • Basic components: • classes: state plus function • Component relationships • one class uses other classes to help it fulfill its responsibilities (by its methods calling methods in the other classes) • inheritance • classes grouped into packages/subsystems
Design Paradigms – Object Oriented 2 • Abstraction • inheritance where a superclass is an abstraction of subclasses • usefulness much more restricted than functional top down abstraction • when one class’s methods call methods in another class, this is often a peer relationship not a (top down) abstraction relationship
Design Paradigms – Object Oriented 3 • Layers abstraction • group classes into “layers” in which the classes in the upper layers can use classes in lower layers but not vice-versa • lower layers simulate existence of an abstract machine that can be “used” by higher layers
Design Paradigms – Object Oriented 4 • Design Strategy • identify basic objects/concepts in application domain, and use these as foundation classes • select a design architecture/metaphor • add additional classes for desired functionality • abstract out superclasses to facilitate understanding and possible re-use • refactor as necessary
Functional versus Object Oriented Design? • Application types • Functional • input – computation – output • input may include persistent data (data base or files) • Object oriented • interactive programs with retained distributed session state between interactions • object methods are functions that can be functionally designed but are often simple
Topics • Development Process • Design Paradigms • Design Patterns • mid to low level design ideas that are useful in certain commonly occurring contexts • UML Modeling and Design Language
Project • Two phases • due at midterm and end of class • Purpose: help learn UML and design patterns • Deliverables • assigned at the end of the lecture in which they are described • not due until end of first and second phase
Running Example • Use to illustrate patterns and corresponding UML diagrams • Template for required simple project • Very simple toy dating system
Dating System Example • Initial Start/End screen • Member and Admin Users • Admin recognized by special name at login • Admin can add and delete users • Member can ask for date or update/initialize member data • After each request reset to Start/End
Some Dating System Details • Member properties: • world view: spiritual/ secular • gender: M/F • Exact matches only • Members identified by their names • If date found, member info returned (name, email address)
Assignment 1 • Form a project team • Choose a project topic • .5 to 1 page brief description • “concept document” • Submit for approval by the end of the week • in class or email to • howden@cse.ucsd.edu