Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
11
Introduction
OO Basics
Lecture 1
Wednesday July 26, 2006
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
2
Agenda
„ Administrative
„ Course objective and outline
„ OO Basics
„ What’s OOAD?
„ Functional decomposition and its problem
„ What’s UML?
„ Software Development Process
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
3
Administrative
„ Instructor
„ Dr. Ying ZHOU (zhouy@it.usyd.edu.au)
„ Office: SIT 437
„ Lectures
„ Wednesday 6-8 pm SIT Lecture Theatre
„ Labs
„ Wednesday 8-9 SIT Lab 114/115
„ Course Website:
„ http://www.cs.usyd.edu.au/~comp5028/s2_20
06
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
4
Communication Channels
„ Consultation
„Wednesday 4-5pm, SIT 437
„ Email: zhouy@it.usyd.edu.au
„ WebCT discussion board (Not ready yet)
„ All news, notices will be published there
„ Course Weblog
„ All news, notices will be published there 
2COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
5
Objectives
„ Learn O-O A&D methodology
„ Understand why a methodology is useful for 
real software projects
„ Learn UML (Unified Modeling Language)
„ Learn O-O design patterns
„ Build something that illustrates the concepts
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
6
Expectations
„ Assumed Knowledge
„ Java or other similar OO language (C#)
„ Java is the official language in this course
„ BEFORE each lecture
„ Download and printout the lecture slides 
„ Read the related chapter and lectures notes
„ Read the tutorial instruction
„ Make sure you keep up with the progress
„ Consult course staff EARLY enough for 
difficulties and problems!
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
7
Course Outline
„ Four Major parts of the content
„ Inception (2 weeks)
„ Elaboration Iteration 1 (4 week)
„ Analysis, basic design, design to code
„ Elaboration iteration 2 (3 weeks)
„ Design principles and patterns
„ Elaboration iteration 3 (4 weeks)
„ More design patterns
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
8
Assessment Components
„ Two project assignments
„ Assignment 1 (15%)
„ System analysis
„ Due on week 6
„ Assignment 2 (25%)
„ System design and implementation ( Java or C#)
„ Due on week 11 Demo on week 12
„ Results will be published on webCT two weeks after the due 
date, please check webCT to make sure that your results are 
correctly recorded. Any discrepancies should be resolved 
within one week after the result being published!
„ Final Exam (60%)
„ Closed book, 2 hours
„ Sample exam will be given
„ Should expect question regarding coding
3COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
9
Team Work
„ Software development is a team-oriented 
activity…
„ Two assignments will work around the same 
project
„ You need to work in the same team for both 
assignments
„ Preferred team size: 2-3 students
„ You can do it by yourself
„ Form your team as early as possible
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
10
Team project – Collaborative Tagging 
System
„ Your client:
„ Charites Inc. a search engine company
„ Your goal:
„ Design a system to allow users to upload and 
collaboratively tag web contents: article or 
image.
„ Manage registered users
„ Manage contents and their tags
„ Produce summaries upon request
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
11
Project task
„ Assignment 1
„ Prepare requirement document
„ Write use cases
„ Develop Domain Model
„ Assignment 2
„ Write Design Document
„ Implement the system (desktop version)
„ System Demo 
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
12
Our Textbook
„ Craig Larman, Applying UML 
and Patterns: An 
Introduction to Object-
Oriented Analysis and 
Design and Iterative 
Development, 3rd edition, 
Prentice Hall PTR, 2005
„ Detailed Intro to Object-
Oriented Analysis & Design
„ Unified Modeling 
Language (UML)
„ Design Patterns
„ Unified Process
4COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
13
Reference Books
„ Martin Fowler, UML Distilled, 3rd edition, Addison-
Wesley, 2004 
„ Robert C. Martin, Agile Software Development: 
Principles, Patterns and Practices, Prentice Hall, 
2003 
„ Erich Gamma, Richard Helm, Ralph Johnson, John 
Vlissides, Design Patterns, Addison-Wesley, 1995 
„ Allan Shalloway ,James R. Trott Design patterns 
explained: A new perspective on Object-Oriented 
Design, 2nd edition, Addison-Wesley, 2005.
„ Martin Fowler, Kent Beck, John Brank, William 
Opdyke, Don Roberts, Refactoring, Addison-Wesley, 
1999 
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
14
Software
„ Microsoft Visio 
„ Licensed software
„ Installed on the lab PC
„ J2SE 1.5 or above
„ Free download from java.sun.com
„ JCreator
„ Free Java IDE
„ Installed on the lab PC
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
15
Rule of Conducts
„ Okay to discuss ideas and problem approaches
„ All work must be your own creation
„ Plagiarism will not be tolerated under any 
circumstance!
„ What is plagiarism
„ Copying all or part of another student’s work (with 
or without their knowledge)
„ Using another person’s ideas without 
acknowledgement
„ Obtaining material (code or other) from the web or 
a book and passing it off as your own 
16
Questions?
5COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
17
Today’s lecture topic
„ What’s OOAD?
„ Functional decomposition and its problem
„ What’s UML?
„ Software Development Process
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
18
What is Analysis and Design
„ Analysis emphasizes an investigation of the 
problem rather than how a solution is defined
„ Design emphasizes a logical solution, how 
the system fulfills the requirements
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
19
Analysis and Design (cont)
„ Division between A & D is fuzzy
„ A & D activities exist on a continuum
„ Some practitioners can classify an activity as analysis
while others put it into design category
More analysis oriented More design oriented
-what
-requirements
-investigation of domain
-understanding of problem
-how
-logical solution
-understanding and  
description of solution
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
20
What is O-O A&D?
„ The essence of O-O A&D is to consider a 
problem domain and logical solution from the 
perspective of objects (things, concepts, or 
entities)
„ O-O Analysis emphasizes finding and 
describing the objects – or concepts- in the 
problem domain
„ O-O Design emphasizes defining logical 
software objects (things, concepts, or entities) 
that have attributes and methods
6COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
21
Object vs. Function Oriented Analysis
Library Info 
System
O-O A&D
Decompose by objects and concepts
Structured A&D
Decompose by functions and processes
Catalog Librarian
Book Library
System
Record Loans Add Resource Report Fines
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
22
Functional Decomposition
„ A very simple development case
„ You are asked to write code to access a list 
of shapes that were stored in a database 
then display them
„ What steps we need to achieve this?
1. Locate the list of shapes in the database
2. Open up the list of shapes
3. Sort the list according to some order
4. Display the individual shapes on the monitor
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
23
Functional Decomposition
„ We might breakdown some step further
a. Identify the type of shapes
b. Get the location of the shape
c. Call the appropriate function that will display 
the shape, giving it the shape’s location
„ This is called functional decomposition
because the analyst breaks down 
(decomposes) the problem into the 
functional steps that compose it.
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
24
How do people do things
„ Case:
„ You are an instructor at a seminar. People in 
your seminar have another class to attend 
following yours, but don’t know where it is 
located. One of your responsibilities is to make 
sure everyone knows how to get to the next 
class.
7COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
25
A “software like” option
„ Steps:
„ Get list of people in the 
class
„ For each person on this 
list, do the following:
„ Find the next class he 
or she is taking
„ Find the location of 
that class
„ Find the way to get 
from your classroom to 
the persona’s next 
class
„ Tell the person how to 
get to his or her next 
class
„ Procedures needed:
„ A way of getting the list 
of people in the class
„ A way of getting the 
schedule for each person 
in the class
„ A program that gives 
someone directions from 
your classroom to any 
other classroom
„ A control program that 
works for each person in 
the class and does the 
required steps for each 
person
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
26
A “human like” option
„ What’s the alternatives?
„ Post a directions to go from this classroom to 
the other classrooms and tell everyone in the 
class
„ I have posted the locations of the other classes 
following this in the back of the room, as well as 
the locations of the other classrooms. Please use 
them to go to your next classroom.
„ Assume everyone knows what his or her next 
class is
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
27
Difference?
„ Option 1: giving explicit directions to 
everyone – pay attention to lots of details. 
You are responsible for everything
„ Option 2: giving general instructions and then 
expect each person will figure out how to do 
the task individually
„ Two kinds of objects
„ Instructor: responsible for posting the instruction
„ Students: knowing their own next classes, able to 
follow the instruction
„ Key point: Shift of responsibility!
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
28
Dealing with changing 
requirements
„ Impact
„ What if you need to distinguish postgraduate 
students from undergraduate students?
„ Option 1: change the control program a lot
„ Option 2: add an additional routine for 
graduate students to follow
„ The second case can minimize changes
8COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
29
Dealing with changing 
requirements
„ What makes it happen?
„ The people are responsible for their own behavior
„ The control program can talk to different types of 
people as if they were exactly the same
„ The control program does not need to know about any 
special steps that students might need to take when 
moving from class to class
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
30
Unified Modeling Language
„ “A language for specifying, visualizing and 
constructing the artifacts of software system”
[Booch, Jacobson, Rumbaugh]
„ It is a notational system aimed at modeling 
systems using O-O concepts
„ Define " boxes", "lines " with specific 
meanings
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
31
Ways of using the UML
„ UML as sketch 
„ Developers use the UML to communicate some 
aspects of a system: selectivity
„ Forward engineering
„ Reverse engineering
„ UML as blueprint: completeness
„ CASE tools: do code generation or build diagrams from 
code
„ UML as programming language
„ Draw UML diagrams that are compiled directly into 
executable code. 
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
32
UML diagrams
„ Use case diagram
„ Class diagram
„ Behavior diagrams:
„ statechart diagram
„ activity diagram
„ interaction diagrams:
„ Sequence diagram
„ Collaboration diagram
„ Implementation diagrams:
„ component diagram
„ deployment diagram
9COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
33
What is legal UML?
„ Legal UML is what is defined as well formed in the 
specification
„ Prescriptive rules
„ A language with prescriptive rules is controlled 
by an official body that states what is or isn’t legal 
in the language and what meaning you give to 
utterances in that language
„ Descriptive rules
„ A language with descriptive rules is one which 
you understand its rules by looking at how people 
use the language in practice
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
34
Key Steps in OOAD [1]
Use Case: a textual description or “story” describing the system
Example:
Play A Dice Game: “A player picks up and rolls the dice.
If the dice face values total seven, they win; otherwise, they lose.”
Define domain
model
Define interaction
diagrams
Define design
class diagramsDefine use cases
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
35
Key steps in OOAD [2]
Domain Model: diagram(s) showing domain concepts, attributes,
and associations
Example: Player
name
DiceGame
Die
faceValue
Rolls
Plays
Includes
2
2
1
1
1
1
Define domain
model
Define interaction
diagrams
Define design
class diagramsDefine use cases
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
36
Key steps in OOAD [3]
Interaction Diagram: shows the flow of messages between software
objects (method invocation)
Define domain
model
Define interaction
diagrams
Define design
class diagramsDefine use cases
:DiceGame
play()
die1 : Die
fv1 := getFaceValue()
die2 : Die
roll()
roll()
fv2 := getFaceValue()
Example:
10
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
37
Key steps in OOAD [4]
Define domain
model
Define interaction
diagrams
Define design
class diagramsDefine use cases
Class Model: shows attributes, methods and associations
for software (solution) objects (not domain objects!)
2
Die
faceValue : int
getFaceValue() : int
roll()
DiceGame
die1 : Die
die2 : Die
play()
1
Example:
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
38
Iterative and Evolutionary 
Development
„ Iterative development
„ Development is organized into a series of 
short, fixed-length mini-projects called 
iterations.
„ The outcome of each is a tested, integrated, 
and executable partial system. 
„ Known as iterative and incremental 
development
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
39
Iterative and evolutionary 
development
Requirements
Design
Implementation &
Test & Integration
& More Design
Final Integration
& System Test
Requirements
Design
4 weeks (for example)
The system grows
incrementally.
Feedback from
iteration N leads to
refinement and
adaptation of the
requirements and
design in iteration
N+1.
Iterations are fixed in
length, or timeboxed.
Time
Implementation &
Test & Integration
& More Design
Final Integration
& System Test
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
40
Handle change on iterative project
Early iterations are farther from the "true
path" of the system. Via feedback and
adaptation, the system converges towards
the most appropriate requirements and
design.
In late iterations, a significant change in
requirements is rare, but can occur. Such
late changes may give an organization a
competitive business advantage.
one iteration of design,
implement, integrate, and test
11
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
41
How long should an iteration be?
„ Most iterative methods recommend an 
iteration length between two and six weeks.
„ Iteration are timeboxed, or fixed in length
„ Date slippage is illegal
„ If it seems difficult to meet the deadline, the 
recommended response is to de-scope –
remove tasks or requirements from the 
iteration, and include them in a future iteration
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
42
The oldest waterfall lifecycle
„ Attempt to define all or most of the requirements 
before programming. To create a thorough design 
before programming
„ Strongly associated with high rates of failure, lower 
productivity, and higher defect rates.
„ 45% of the features in waterfall requirements are 
never used, early waterfall schedules and estimates 
vary up to 400% from the final actuals.
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
43
Mini workshop
„ Which one of the following is true iterative 
development
„ I’ve done five iterations on requirement collection and 
the client finally satisfied and signed off the 
requirement document.
„ We take iterative method to achieve good database 
design. After the first interview with the client, we make 
an initial design of the database and brought this to the 
client. We got valuable feedback from them and made 
according changes, we repeat this process for four 
times and now have our final version of the database 
design
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
44
How to do iterative and evolutionary 
analysis and design
12
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
45
Agile Methods and attitudes
„ Agile development methods usually apply 
timeboxed iterative and evolutionary development, 
employ adaptive planning, promote incremental 
delivery and include other values and practices that 
encourage agility – rapid, and flexible response to 
change.
„ Example
„ programming in pairs
„ test-driven development
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
46
Agile Modeling
„ Adopting an agile method does not mean 
avoiding any modeling
„ The purpose of modeling and models is 
primarily to support understanding and 
communication, not documentation
„ Don’t model or apply the UML to all or most of 
the software design
„ Use the simplest tool possible
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
47
Agile modeling (cont)
„ Don’t model alone
„ Create models in parallel
„ Use “good enough” simple notation while sketching 
with a pen on paper
„ Know that all models will be inaccurate
„ Developers themselves should do the OO design 
modeling, for themselves, not to create diagrams that 
are given to other programmers to implement.
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
48
What is the UP
„ A software development process describes an 
approach to building, deploying, and possibly 
maintaining software
„ A popular iterative software development process 
„ Provide an example structure for how to do OOA/D
„ Is flexible and open, can be applied in a lightweight 
and agile approach
13
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
49
What are UP Phases
„ Inception – Approximate vision, business case, 
scope, vague estimates
„ Elaboration – refined vision, iterative implementation 
of the core architecture, resolution of high risks, 
identification of most requirements and scope, more 
realistic estimates
„ Construction – iterative implementation of the 
remaining lower risk and easier elements, and 
preparation for deployment
„ Transition – beta tests, deployment
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
50
UP phases (cont)
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
51
What is an agile UP
„ Prefer a small set of UP activities and artifacts. All UP 
artifacts are optional
„ Requirements and designs are not completed before 
implementation
„ Apply the UML with agile modeling practices
„ No detailed plan for the entire project
„ Phase Plan: high-level plan
„ Iteration Plan: only plans with greater detail one 
iteration in advance. 
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
52
Layers and texbook case study
User Interface
Sale Payment
Logging ... Database Access ...
application 
logic layer
other layers or 
components
minor focus
explore how to connect to 
other layers
primary focus 
of case studies
explore how to 
design objects
secondary 
focus
14
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
53
Case study strategy
Iteration 1
Iteration 2
Iteration 3
Introduces just those 
analysis and design 
skills related to 
iteration one.
Additional analysis and 
design skills introduced.
Likewise.
COMP5028 Object-Oriented Analysis and Design (S2 2006)
© Dr. Ying Zhou, School of IT, The University of Sydney 
54
Cases
„ Case one: The NextGen POS 
system
„ A POS system is a 
computerized application 
used (in part) to record 
sales and handle payments
„ Hardware: computer, bar 
code scanner
„ Software
„ Interfaces to service 
applications: tax 
calculator, inventory 
control
„ Case Two: The Monopoly 
Game System