CSC 213 – Large Scale Programming. Today’s Goal  Learn Unified Process to design programs  Understand what are the “types” of Java classes  Methods.

Slides:



Advertisements
Similar presentations
Lecture 4 Basic Scripting. Administrative  Files on the website will be posted in pdf for compatibility  Website is now mirrored at:
Advertisements

Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
COMP 121 Week 7: Object-Oriented Design and Efficiency of Algorithms.
Chapter 7 Structuring System Process Requirements
Edsger W. Dijkstra Simplicity is prerequisite for reliability.
Lecture 1 CS171: Game Design Studio 1I UC Santa Cruz School of Engineering 5 January 2010.
Introduction to UML (slides adapted from Michael Mateas)
1 CS1001 Lecture Overview Object Oriented Design Object Oriented Design.
CSC 395 – Software Engineering Lecture 21: Overview of the Term & What Goes in a Data Dictionary.
Chapter 1 Program Design
Xtreme Programming. Software Life Cycle The activities that take place between the time software program is first conceived and the time it is finally.
CSC 395 – Software Engineering Lecture 15: Object-Oriented Design –or– Ask For Whom The Data Tolls.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Domain Modeling (with Objects). Motivation Programming classes teach – What an object is – How to create objects What is missing – Finding/determining.
Chapter 7 Structuring System Process Requirements
Objects What are Objects Observations
Lecture 2: UML Class DIAGRAM
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
CSC 213 – Large Scale Programming. Why Do We Test?
CSC 213 – Large Scale Programming Lecture 2: Object-Oriented Analysis & Object-Oriented Design.
Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established.
CSC 213 – Large Scale Programming Lecture 3: Object-Oriented Analysis.
1. 2 Object-Oriented Concept Class & Object Object-Oriented Characteristics How does it work? Relationships Between Classes Development Tools Advantage.
CSC 313 – Advanced Programming Topics. Design Pattern Intent  Each design pattern is a tool  Like all tools, have reason for being.
LECTURE 38: REFACTORING CSC 395 – Software Engineering.
1 Analysis Extracting from Use Cases to Create Diagrams.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
CSC 213 – Large Scale Programming. Today’s Goal  Improve design skills to make usable designs  Noun extraction & UML class diagram reviewed  Connections.
Problem of the Day  Why are manhole covers round?
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Refactoring1 Improving the structure of existing code.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Sept. 18, 2003CS WPI1 CS 509 Design of Software Systems Lecture #3 Thursday, Sept. 18, 2003.
Lazy Contemplative Always Using Imagination Most Important Trait.
CSC 395 – Software Engineering Lecture 14: Object-Oriented Analysis –or– Ripping the Band-Aid Off Quickly.
Object-Oriented Design CSC 212. Announcements This course is speeding up and we are starting new material. Please see me if you feel this is going too.
Slide 12A.1 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
Object Oriented Software Development
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
Design Model Lecture p6 T120B pavasario sem.
Problem of the Day  I am thinking of a question and propose 3 possible answers. Exactly one of the following is the solution. Which is it? A. Answer 1.
CSC 313 – Advanced Programming Topics. What Is the Factory Method?  Creation details hidden by AbstractCreator  Does effective job of limiting concrete.
Object Oriented Analysis and Design Class and Object Diagrams.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Software Engineering Zhang Shuang
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
CSC 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
Chapter 7 Structuring System Process Requirements Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
INFO 620Lecture #71 Information Systems Analysis and Design Design Class Diagrams and others INFO 620 Glenn Booker.
CSC 213 – Large Scale Programming. Today’s Goal  Understand why testing code is important  Result of poor or no testing & embarrassment caused  Learn.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
© 2005 by Prentice Hall Chapter 7 Structuring System Process Requirements Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George.
High Level Design Use Case Textual Analysis SE-2030 Dr. Mark L. Hornick 1.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Problem of the Day  Simplify this equation: (x - a) * (x - b) * (x - c) * … * (x - z)
DATA FLOW DIAGRAMS.
LECTURE 22: BIG-OH COMPLEXITY CSC 212 – Data Structures.
CSC 222: Computer Programming II
Lecture 9: Birds + BEES = CLASSES?
The Movement To Objects
Unified Modeling Language
UML Class Diagrams: Basic Concepts
Applying Use Cases (Chapters 25,26)
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
Presentation transcript:

CSC 213 – Large Scale Programming

Today’s Goal  Learn Unified Process to design programs  Understand what are the “types” of Java classes  Methods of selecting the potential classes  How these designs presented for others to use

Classroom Development  Always start from scratch  Know all requirements from the start  And requirements will not change  Coding begins immediately at start  Projects are trivial jokes in real-world  If lasts 15 weeks, project “large scale”  Code cannot be reused  Never look at again, anyway

Why These Phases Matter

Our Goal

Our Nemesis

Other Nemesis

Where We Start

Find the Classes  Designing classes next step in process  Could help find & fix inconsistent requirements  Requirements clarified if you do not understand them  Outlining classes makes coding easy  Already know methods to call from other classes  Will provide chance to do some easy debugging

Noun Extraction  Finds entity class candidates to be used in design  Initial pass may (will) not find all entity classes  Some classes not used even though found early on  Provides strong hints for other needed classes  Start with plain English requirements  Should be easy & comes with most assignments  Many nouns not needed, so can prune list  Eliminate any & all classes external to program

Designing Elevator Controller Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.

Noun Extraction 1. Underline the nouns in the requirements Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.

1. Underline the nouns in the requirements Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Noun Extraction

2. Eliminate nouns external to the problem Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Noun Extraction

2. Eliminate nouns external to the problem Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Noun Extraction

3 “Types” of Classes  Unified Process concept simplifies design process  Entity classes hold long-lived data driving program  Input & output handled by boundary classes  Control classes do complex processing in program  "Types" not real, exist for design purposes only  A class is a class is a class within Java & program  But they can help checking design covers all needs

Entity Classes

 Focus on entity classes & ignore (for now) others  Since not things, prune abstract (non-physical) nouns  Ignore if used for communication – rarely drive program must work iteratively  Thinking will change -- must work iteratively  Writing & debugging easier given good design  Minutes spent in design saves hours in coding & testing

“Must work iteratively” !=

Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Entity Classes

1. Ignore abstract (non-physical) nouns Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Entity Classes

1. Ignore abstract (non-physical) nouns Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Entity Classes

2. Only use singular form of each noun Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Entity Classes

2. Only use singular form of each noun Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Entity Classes

Our Entity Classes

Boundary Classes  These classes will perform all input & output  May have many details which are all independent it will change before its over  Only 1 detail known: it will change before its over  Make class for each detail & limit future rewriting  Make life easier, start from simplest ideas  Easy to combine simple classes to create complex ones  Taking a complex class and breaking up far harder  Rarely rewrite complex classes because of difficulty… … instead often just throw out & start from scratch

Skipping Boundary Classes  Boundary classes may duplicate primitive type  Can eliminate this class; it adds nothing to design  Code will have primitive hard-coded everywhere  Saves writing javadoc for class, field, getter & setter  When needs change and class now needed…

Skipping Boundary Classes  Boundary classes may duplicate primitive type  Can eliminate this class; it adds nothing to design  Code will have primitive hard-coded everywhere  Saves writing javadoc for class, field, getter & setter  When needs change and class now needed…  Find & replace all primitives littering code  Scan entire program to track down all I/O for this data  Retest entire application to ensure now bugs created

Skipping Boundary Classes  Boundary classes may duplicate primitive type  Can eliminate this class; it adds nothing to design  Code will have primitive hard-coded everywhere  Saves writing javadoc for class, field, getter & setter  When needs change and class now needed…  Find & replace all primitives littering code  Scan entire program to track down all I/O for this data  Retest entire application to ensure now bugs created  Industry usually finds better writing class at start

1. Reexamine abstract nouns & keep if used in I/O Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Boundary Classes

1. Reexamine abstract nouns & keep if used in I/O Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Boundary Classes

2. Only use singular form of each noun Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Boundary Classes

3. There is no step 3 Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Find Boundary Classes

3. There is no step 3 Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Movement Request Illumination I Know Boundary Classes!

Control Classes  Non-obvious algorithms using many classes  Rule of thumb: obvious algorithm have name  Control classes already exist for named algorithms  Needed for those plurals ignored previously  Can use array or enum, if exact number known  Else, design needs structure to hold instances

Control Classes

1. Reexamine plurals & keep when necessary Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Finding Control Classes!

1. Reexamine plurals & keep when necessary Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Finding Control Classes!

2. Eliminate if constant number (array) needed Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Finding Control Classes!

2. Eliminate if constant number (array) needed Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Finding Control Classes!

2. Eliminate if constant number (array) needed Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Finding Control Classes!

3. Select data structure to use for each plural Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed. Finding Control Classes!

3. Select data structure to use for each plural Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.PriorityQueue Finding Control Classes!

Now Determine Fields in Design  Designing classes next step in process  For each class, determine fields  Link classes that work together so easy to code  When done well, coding becomes relatively simple  What should be fields & how can we know?  Since they are abstract, boundary classes often fields  Control classes often fields; something must use it  Read text again: look where one noun posses another

What To Do Next?  Must communicate design in clear way to others  Make explicit what the classes for this program are  Identify fields & other relationships between classes  Make certain information is clearly highlighted  Provides vital check that can often find bugs  Will do this by drawing pretty pictures

What To Do Next?  Must communicate design in clear way to others  Make explicit what the classes for this program are  Identify fields & other relationships between classes  Make certain information is clearly highlighted  Provides vital check that can often find bugs  Will do this by drawing pretty pictures

Pictures Worth 1,000 Words

Why Draw Classes?  Pictures used to share ideas easily  Gets everyone up & coding at once  Group spends lab watching you code… suckers  …or get suckers to work while you relax

Why Draw Classes?  Pictures used to share ideas easily  Gets everyone up & coding at once  Group spends lab watching you code… suckers teammates  …or get suckers teammates to work while you relax

Why Draw Classes?  Pictures used to share ideas easily  Gets everyone up & coding at once  Group spends lab watching you code… suckers teammates suckers  …or get suckers teammates suckers to work while you relax

Why Draw Classes?  Pictures used to share ideas easily  Gets everyone up & coding at once  Group spends lab watching you code… suckers teammates suckers  …or get suckers teammates suckers to work while you relax  Even better to get suckers working in parallel

Why Draw Classes?  Pictures used to share ideas easily  Gets everyone up & coding at once  Group spends lab watching you code… suckers teammates suckers  …or get suckers teammates suckers to work while you relax  Even better to get suckers working in parallel

Why Draw Classes?  Pictures used to share ideas easily  Gets everyone up & coding at once  Group spends lab watching you code… suckers teammates suckers  …or get suckers teammates suckers to work while you relax  Even better to get suckers working in parallel  Methods & their signatures included in diagrams  Can write code using all classes, even if unwritten

UML Class Diagrams

Drawing Relationships  Must be able to explain all relationships

Drawing Relationships  Must be able to explain all relationships Boyfriend-Girlfriend Just Friends Friends “with benefits” Sweeties Married Best Friends

Relationships From Fields  Aggregation  Used for collection whose instances do not rely on source aggregates  Car aggregates CarParts (e.g., tires, engine, lights…)  Composition  Use when objects from target used only within source composes  Chessboard composes Squares  Association  Source object has field of target type (not a collection)  Often used to imply source calls target's methods

Playing “Utah Hold’Em”?  All of above relationships must be labeled  Give field a name & show it near midpoint of arrow  Monogamous? Poly? Specify numbers involved  Each end of link has number involved on that end  Could be some range of numbers like ‘2..5’  + means 1 of more objects required to be used  Use Kleene’s star ‘*’ for 0 or more objects  Specific number (1, 42, 69) good if specifically known

 Generalization (“inheritance”)  Shows subclass-superclass relationship  Does not involve fields, multiplicities, or anything else  Makes this a different type of connection than others  Must draw all generalizations within the diagram  For implementation to be correct, these are critical Other Type of Connections

Our “Final” Design Decisions Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.

Elevator's UML Class Diagram  Note that Button class serves two purposes  Direct travel to specific floor if in an elevator  Used on a floor to request travel up or down  Much easier with 2 subclasses of Button

Elevator's UML Class Diagram

 Next: where do methods come from?

For Next Lecture  Link to article for Monday on lecture page  Reading for Monday available on Angel  What else can we do before coding?  Are there more tricks that enables our laziness?  How to trick smarter suckers into doing our work?  Weekly assignment problem due in class Mon.  Weekly assignment page has problem for today  Noun extraction to find entity, boundary, & control classes  Show the connections by drawing UML class diagram