Slides on Finding Objects - Object-Oriented Analysis and Design | CSCI 6448, Study notes of Computer Science

Material Type: Notes; Professor: Anderson; Class: OO ANALYSIS & DESIGN; Subject: Computer Science; University: University of Colorado - Boulder; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-12s
koofers-user-12s 🇺🇸

10 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 9: Finding Objects
Kenneth M. Anderson
Object-Oriented Analysis and Design
CSCI 6448 - Spring Semester, 2005
1
February 8, 2005 © University of Colorado, Boulder, 2005
2
Goals for this Lecture
Review content of Chapter 3 from the textbook
Discuss the process for discovering candidate objects and roles in
a software system
Review techniques that can aid this process
Design Stories
Search Strategies
Coming up with Names
Describing Candidate Objects and their relationships
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Slides on Finding Objects - Object-Oriented Analysis and Design | CSCI 6448 and more Study notes Computer Science in PDF only on Docsity!

Lecture 9: Finding Objects

Kenneth M. Anderson

Object-Oriented Analysis and Design

CSCI 6448 - Spring Semester, 2005

2

Goals for this Lecture

Review content of Chapter 3 from the textbook

Discuss the process for discovering candidate objects and roles in

a software system

Review techniques that can aid this process

Design Stories Search Strategies Coming up with Names Describing Candidate Objects and their relationships

February 8, 2005 © University of Colorado, Boulder, 2005

Laying a Foundation

Wirfs-Brock and McKean compare object design to graphic design

Good graphic design requires careful use of color, texture, and shapes to make images “leap off the page”. A bad design muddles what should be emphasized Example: “chart junk” A good design is more than the sum of its parts. Object designs, likewise, require good abstractions, well-formed objects, and a good overall structure To create these designs, however, you need a process

A Process for Finding Objects

Initial strategies for finding objects were a bit naïve

Take text that describes the requirements for the system and Underline nouns! Objects! Underline verbs! Methods! This strategy is inadequate because finding good objects involves finding abstractions that are going to be useful for your application Some of these abstractions may not have real-world counterparts Although we must determine which domain concepts WILL be included and how they will fit within the overall application 4

February 8, 2005 © University of Colorado, Boulder, 2005

The Process, continued

7. Organize your candidates; Look for clusters of objects that have to

work together to solve a problem (use cases can help here)

8. Double check to see if each candidate is appropriate

9. Defend each candidate’s reasons for inclusion

10. When discovery slows, move on to creating responsibilities

(chapter 4) and collaborations (chapters 5 and 6)

Discussion

Again, this process is not meant to be performed in a sequential

manner; you may do several steps at once, you might discard

several objects at once and start over, etc.

Wirfs-Brock and McKean recommend that you do start with a

design story, however

The goal is to come up with a core set of initial object candidate

that represent the fundamental abstractions upon which your

system is based

Many additional candidates will be created as you move forward in analysis and design 8

February 8, 2005 © University of Colorado, Boulder, 2005

Find Objects FIRST

Your first candidates should be concrete objects or roles

These candidates should be “smart” They “do things” in your system They may “know things” about your system as well, but they do things in response to what they know So, identify distinct objects with clear roles first; then identify their responsibilities and their relationships

Classes and Interfaces will come later once you have enough

concrete objects to understand the key relationships in your design

Identify what objects have attributes and behaviors in common (classes) and what objects have common responsibilities (interfaces)

Getting Started: Design Stories

To make finding objects easier, create a framework for searching

for candidates by writing a story about your application

This allows you to identify candidates that “fall into place” and support various aspects of your story The story should include not only functionality but your goals with respect to the software under design; what are the “cool things” about what you are trying to do and what things are you unsure about? Try to coalesce information from multiple sources, like use cases, other requirements, system architecture, users, etc. 10

February 8, 2005 © University of Colorado, Boulder, 2005

Search Strategies

Themes in Design Stories can lead to candidates

Candidates will generally fall into one of these categories

The work your system performs Things directly affected or connected to the application Information that flows through your software Decision making, control and/or coordination activities Structures and groups of objects Domain Concepts

What do these categories remind you of?

Role Stereotypes!

As discussed before, objects need to have a clear role and these

roles will often match the stereotypes we covered in Lecture 4

If your system performs computations, look for service providers If your system interacts with the outside world, look for interfacers With respect to users, only include them in your object model if you need to treat different types of users in different ways If your system handles lots of events, look for controllers If your system manipulates lots of information, look for structurers

Now, lets see how these are used to explore our two examples

(pages 85—87) in the textbook

14

February 8, 2005 © University of Colorado, Boulder, 2005

What’s In a Name

Your candidates need strong names

When the name of an object is spoken, designers infer something about the object’s role and

So make sure an object’s name fits its responsibilities

Wirfs-Brock and McKean provide several heuristics to use while

naming object candidates

They note that multiple naming systems (roles, patterns, domain concepts) can coexist within a single application

Naming Heuristics

Qualify Generic Names

This conveys both a general set of responsibilities and a specific type of behavior Calendar vs. GregorianCalendar vs. JulianCalender

Include only the most revealing and salient facts in a name

Timer vs. MillisecondTimerAccurateWithinPlusOrMinusTwoMilliseconds (!!)

Give service providers “worker” names

StringTokenizer, SystemClassLoader, AppletViewer, etc. 16

February 8, 2005 © University of Colorado, Boulder, 2005

Naming Heuristics, continued

Do not overload names

even though some OO languages support this Example: having two objects called Processor (each in different packages) that may process different things or “process” in different ways

Eliminate name conflicts by adding an adjective or using a

synomym

TransactionProperties vs. Properties as long as the two objects don’t do radically different things

Choose names that are readily understood

Account vs. Acct

Describing Candidates

Use CRC Cards to describe candidates

Record name, description, and role stereotypes

Use patterns when describing candidates

See examples on page 94

Provide examples of how a candidate will be used to clarify its

purpose (these examples will probably not fit on the CRC card)

20

February 8, 2005 © University of Colorado, Boulder, 2005

Connecting Candidates

Cluster candidates to help you clarify existing ones and “discover”

new ones

Feel free to rearrange your clusters to gain new insights

Try clustering by

application layer use case stereotype role object neighborhood abstraction level application theme

Looking for Common Ground

Once you have identified a bunch of distinct candidates, its time to

look for commonalities

These commonalities will help you identify classes and interfaces

Strategies

Look for powerful abstractions and common roles Car, Boat, Bike, Tractor! Vechicle Look for the right level of abstraction ChessMove vs. PawnMove, RookMove, etc. Discard candidates if they can be replaced by a shared role Book, CDs, DVDs, etc.! InventoryItem 22