1 Ivan Marsic Rutgers University LECTURE 18: Design Patterns Command, Decorator, State, Proxy.
Ivan Marsic Rutgers University LECTURE 1: Introduction Lecture time: 1 hr. 20 min.
-
Upload
jocelyn-wilkins -
Category
Documents
-
view
223 -
download
3
Transcript of Ivan Marsic Rutgers University LECTURE 1: Introduction Lecture time: 1 hr. 20 min.
Course Information
• Web: http://www.ece.rutgers.edu/~marsic/Teaching/SE
• Lecture Notes:http://www.ece.rutgers.edu/~marsic/books/SE
• Textbooks (see more on the course website)– Bruegge & Dutoit: Object-Oriented Software Engineering: Using UML, Patterns and
Java, Third Edition, Prentice Hall, 2010. | ISBN 0-13-6061257– Miles & Hamilton: Learning UML 2.0, O’Reilly Media, 2006. ISBN: 0-596-00982-8
• Teaching Assistant:Swapnil Mhaske <[email protected]>
2
Team Projects
• Form teams of 6 (± 1?) studentsDEADLINE: Friday, January 25, 2013After that, teams assigned randomly
• Project Ideas:http://www.ece.rutgers.edu/~marsic/books/SE/projects
• No more than two (2) groups working on the same project
• One (1) new project allowed• Email your project idea ASAP, before proposal is due, for feedback
3
Personal Health Monitoring Devices
4
Available budget:$500
To do:1. Search the Web for devices and apps that you would like to work with2. Email the components list with costs+websites
Project Deliverables
5
Item Due date
Iterat.
#1
1. Proposal January 29 2. First report (Specification only) • Part 1 (Statement of Work & Requirements) • Part 2 (Functional Requirements Spec & UI) • Full Report #1
February 12February 18February 22
3. Second report (Design only) • Part 1 (Interaction Diagrams) • Part 2 (Class Diagram and System Architecture) • Full Report #2
March 1March 8March 15
4. First demo April 2 ► ... Ite
r #2
5. Third report (All reports collated) April 27 6. Second demo May 1 ► ...
7. Electronic Project Archive May 3
Team Project Grading
35pts
26pts
12 p
100
Team 3
21 p
50 pts
70
Team 2
30pts
100
Team 1
30pts
30pts
Earned points
Project grade
21 pts
TeamProjectgrade
Member ID
Earnedpoints
Adjustedpoints
Normalizedpoints
T1 100%
M1,1 30 30 (30/35 * 100) = 86
M1,2 30 30 (30/35 * 100) = 86
M1,3 30 30 (30/35 * 100) = 86
T2 70%M2,1 21 (21 * 0.7) = 14.7 (14.7/35 * 100) = 42
M2,2 50 (50 * 0.7) = 35 100
T3 100%
M3,1 21 21 (19/35 * 100) = 60
M3,2 12 12 (12/35 * 100) = 34
M3,3 35 35 100
M3,4 26 26 (26/35 * 100) = 74
Introduction: Software is Complex
• Complex complicated
• Complex = composed of many simple parts
related to one another
• Complicated = not well understood, or explained
Complexity Example:Scheduling Fence Construction Tasks
Setting posts[ 3 time units ]
Cutting wood[ 2 time units ]
Painting[ 5 time units for uncut wood;
4 time units otherwise ]
Nailing[ 2 time units for unpainted;
3 time units otherwise ]
Setting posts Nailing, Painting
Cutting Nailing
…shortest possible completion time = ?
8[ “simple” problem, but hard to solve without a pen and paper ]
More Complexity
Suppose today is Tuesday, November 29
What day will be on January 3?
[ To answer, we need to bring the day names and the day numbers into coordination, and for that we may need again a pen and paper ]
The Role of Software Engg. (1)
CustomerCustomerProgrammer
A bridge from customer needs to programming implementation
First law of software engineeringSoftware engineer is willing to learn the problem domain(problem cannot be solved without understanding it first) 10
The Role of Software Engg. (2)
11
Customer:Requires a computer system to achieve some business goalsby user interaction or interaction with the environmentin a specified manner
System-to-be
Software-to-be
System-to-be
Software-to-beUser
Software Engineer’s task:To understand how the system-to-be needs to interact withthe user or the environment so that customer’s requirement is metand design the software-to-be
Programmer’s task:To implement the software-to-bedesigned by the software engineer
Environment
May be thesame person
Example: ATM Machine
Bank’sremote
datacenter
Bankcustomer
ATM machine
12 34
5 67 890
12 34
5 67 890
12 34
5 67 890
Communication link
Understanding the money-machine problem:
12
How ATM Machine Might Work
Window clerk
Bookkeeper
Safe keeper
Datacenterliaison
Dispenser
Safe
Cash
Transactionrecord
Phone
Speakerphone
Bank’sremote
datacenter
Domain Model
How may I help you?
Customer
Domain model created with help of domain expert
13
Cartoon Strip: How ATM Machine Works
B
Verify this
account
B
Verify this
account
C Verify account
XYZ
XYZ valid. Balance:
$100
C Verify account
XYZ
XYZ valid. Balance:
$100
D
Account valid.
Balance: $100
D
Account valid.
Balance: $100
G Record $60 less
G Record $60 less
A Enter your PIN
Typing in PIN number
…
A Enter your PIN
Typing in PIN number
…
E How may I help you?
Withdraw $60
E How may I help you?
Withdraw $60
F Release $60
Dispense$60
F Release $60
Dispense$60
H
Please take your cash
Dispensing!H
Please take your cash
Dispensing!
14
Software Engineering Blueprints
Specifying software problems and solutions is like cartoon strip writing
Unfortunately, most of us are not artists, so we will use something less exciting:UML symbols
However …
15
Second Law of Software Engineering
• Software should be written for people
first
– ( Computers run software, but hardware quickly
becomes outdated )
– Useful + good software lives long
– To nurture software, people must be able to understand
it
16
Software Development Methods
Method = work strategy The Feynman Problem-Solving Algorithm:
(i) Write down the problem (ii) think very hard, and (iii) write down the answer.
Waterfall Unidirectional, finish this step before moving to the next
Iterative + Incremental Develop increment of functionality, repeat in a feedback loop
Agile User feedback essential; feedback loops on several levels of
granularity
17
Waterfall Method
Deployment &Maintenance
Requirements
Design
Implementation
TestingWaterfallmethod
18
Unidirectional, no way backfinish this step before moving to the next
UML – Language of Symbols
«interface»BaseInterface
+ operation()
Actor
ClassName
# attribute_1 : int# attribute_2 : boolean# attribute_3 : String
+ operation_1() : void+ operation_2() : String+ operation_3(arg1 : int)
Software Class
Three commoncompartments:
1. Classifier name
2. Attributes
3. Operations
Comment
Class1Implement
+ operation()
Class2Implement
+ operation()
Software Interface Implementation
Interaction Diagram
doSomething()
instance1 : Class1 instance5 : Class2 instance8 : Class3
doSomethingElse()
doSomethingYetElse()
Inheritancerelationship:BaseInterfaceis implementedby two classes
Stereotype «» provides additional info/ annotation/ explanation
19
UML = Unified Modeling Language
Online information:http://www.uml.org
Understanding the Problem Domain
• System to be developed
• Actors
– Agents external to the system
• Concepts/ Objects
– Agents working inside the system
• Use Cases
– Scenarios for using the system
20
ATM: Gallery of Players
Actors (Easy to identify because they are visible!)
Bank’s remotedatacenter
System(ATM machine)
Bank customer
12
345
678
90
12
345
678
90
Bank’s remotedatacenter
System(ATM machine)
Bank customer
21
Gallery of Workers + Things
Concepts (Hard to identify because they are invisible/imaginary!)
Window clerk Bookkeeper Safe keeperDatacenterliaison
Dispenser
Safe CashTransactionrecord
TelephoneSpeakerphone
22
Use Case: Withdraw Cash
B Verify account
XYZ
XYZ valid. Balance:
$100
B Verify account
XYZ
XYZ valid. Balance:
$100
12 34
5 67 890
12 34
5 67 890
C How may I help you?
Withdraw $60
12 34
5 67 890
12 34
5 67 890
C How may I help you?
Withdraw $60
12 34
5 67 890
12 34
5 67 890
A Enter your PIN
Typing in PIN number
…
12 34
5 67 890
12 34
5 67 890
A Enter your PIN
Typing in PIN number
…
D
12 34
5 67 890
12 34
5 67 890
Please take your cash
Collecting cash …
D
12 34
5 67 890
12 34
5 67 890
Please take your cash
Collecting cash …
E XYZ withdrew
$60
Acknowledged
E XYZ withdrew
$60
Acknowledged
23
Window clerk
Bookkeeper
Dispenser
Transactionrecord
Speakerphone
How may I help you?
Customer
Draftsman
Solution modification
Solution modification
How ATM Machine Works (2)Domain Model (2)
Alternative solution
How ATM Machine Works (3)Domain Model (3)
Remotebank
Window clerk
Bookkeeper
Dispenser
Transactionrecord
Speakerphone
How may I help you?
Customer
Courier
Solution modification
Solution modification
Alternative solution
Which solution is the best or even feasible?
Actual Design
27
Rail with a belt or chain
Operator (includes motor and radio control mechanism)
Garage door
Safety reversing sensor
Pressing of a button on the remote control transmitter (1)authenticates the device & activates the motor in the operator (2).The motor pulls the chain (or belt) along the rail (3) and windsthe torsion spring (4).The torsion spring winds the cable on the pulleys (or drums) (5)on both sides of the door. The cables lift the door, pushing the different sections of the doorinto the horizontal tracks (6)At the same time, the trolley (or traveler) (7) moves along the rail (3)and controls how far the door opens (or closes),as well as the force the garage door exerts by way of the curved door arm (8)
Remote control transmitter 2
1
3
4 5
5
6
6
7
8
Software Measurement
• What to measure?
– Project (developer’s work),
for budgeting and scheduling
– Product,
for quality assessment
28
Sizing the Problem (1)
Size( ) = 10
Size( ) = 7
Size( ) = 4
Size( ) = 3
Size( ) = 4
Size( ) = 2
Size( ) = 4
Size( ) = 7
Step 2:Estimate relative sizes of all parts
Step 1: Divide the problem into small & similar parts
Sizing the Problem (2)
• Step 3: Estimate the size of the total work
Total size = points-for-section i (i = 1..N)
• Step 4: Estimate speed of work (velocity)
• Step 5: Estimate the work duration
Travel duration = Path size
Travel velocity
Sizing the Problem (3)
• Advantages:
– Velocity estimate may need to be adjusted (based on
observed progress)
– However, the total duration can be computed quickly
(provided that the relative size estimates of parts are
accurate – easier to achieve if the parts are small and
similar-size)
Exponential Cost of Estimation
Estimation cost
Est
imat
ion
accu
racy
100%
Improving accuracy of estimation beyond a certain point requires huge
cost and effort (known as the law of diminishing returns)
In the beginning of the curve, a modest effort investment yields huge
gains in accuracy33
Estimation Error Over Time
Time
Estimationerror
CompletionStart
The cone of uncertainty starts high and narrows down to zero as the project approaches completion.
Requirements Design ImplementationImplementation
Agile Project Effort Estimation
35Time
2nd iteration n-th iteration
Estimated completion date
Items pulled by the team into an iteration
1) Prune Section 8 3.5 days (7pts)
Work backlog
2) Prune Section 7 2 days (4pts)
3) Prune Section 6 1 day (2pts)
4) Prune Section 5 2 days (4pts)
1st iteration
5) Prune Section 4 1.5 days (3p)
6) Prune Section 1 2 days (4pts)
7) Prune Section 2 3.5 days (7p)
Work items
8) Prune Section 3 5 days (10p)
21 days
5 daysList prioritized by the customer
Estimated work duration
Good Shape(Low branches get sun)
Poor Shape(Low branches
shaded from sun) Heading back not recommended as it alters the natural shape of the shrub
Remove dead wood
Remove water spouts and suckers
Snow accumulates on broad flat tops
Straight lines require more frequent trimming
Peaked and rounded tops hinder snow accumulation
Rounded forms, which follow nature’s tendency,
require less trimming
Measuring Quality of Work
36
Concept Maps
Proposition
Concept Relation Concept
1. I have friend
2. friend engages in coding
3. coding constructs a
program
4. program
is new
SENTENCE: “My friend is coding a new program”
translated into propositions
Search the Web for Concept Maps
I
friend
have
coding
engages in
program
constructs a
newis
37
Useful tool for problem domain description
Case Study: Home Access Control
• Objective: Design an electronic system for:– Home access control
• Locks and lighting operation
– Intrusion detection and warning
System
Lock Photosensor Switch
Light bulb
Alarm bell
1
2
3
4
5
X
Y
1
2
3
4
5
X
Y
38
Case Study – More Details
System
Lock Photosensor Switch
Light bulb
Alarm bell
1
2
3
4
5
X
Y
1
2
3
4
5
X
Y CentralComputer
Backyard doors:External &
Internal lock
Front doors:External &
Internal lock
CentralComputer
Backyard doors:External &
Internal lock
Front doors:External &
Internal lock39
Know Your Problem
1
9
7
8
6
2
3
54
7 Thumb-turn
1 Lock case
2 Latch bolt
3 Dead bolt
9 Left hand lever
8 Lock cylinder
6 Protective plate
5 Strike box
4 Strike plate
Mortise Lock Parts
1
2
3
4
5
X
Y
1
2
3
4
5
X
Y
40
Concept Map for Home Access Control
tenant
key
can be prevented by enforcinglock opened
wishes
causes
enters
valid key invalid key
can be
dictionary attack
may signal
upper bound on failed attempts
burglar launches
41