Beruflich Dokumente
Kultur Dokumente
BlueJ BlueJ
book book
(Many first
editions still
around
Cambridge
from 2004)
BlueJ Demo Fundamental concepts
object
class
method
parameter
data type
1.0
assignment statements
How is that price determined?
conditional statements
How is ‘money’ entered into a machine?
How does a machine keep track of the money
that is entered?
Ticket machine – internal view Basic class structure
Interacting with an object gives us clues
about its behavior. outer wrapper
public class TicketMachine
of TicketMachine
Looking inside allows us to determine how {
Inner part of the class omitted.
that behavior is provided or implemented. }
All Java classes have a similar-looking
internal view.
public class ClassName
{
Fields contents of a
Constructors
generic class
Methods
}
The body encloses the method’s statements. start and end of method body (block)
Mutator methods Mutator methods
Have a similar method structure: header and
return type (void)
body.
method name parameter
But these are used to mutate (i.e., change) visibility modifier
an object’s state.
Achieved through changing the value of one public void insertMoney(int amount)
or more fields. {
Typically contain assignment statements. balance += amount;
}
Typically receive parameters.
assignment statement
field being changed
Object interaction
Creating cooperating objects
1.0
} }
SomeObject a; SomeObject b;
SomeObject obj;
“object” type
b = a;
int i;
int a; int b;
32 “primitive” type 32 32
/**
* Update the internal string that
* represents the display.
*/
Review Review
Class bodies contain fields, constructors and Local variables are used for short-lived
methods. temporary storage.
Fields store values that determine an object’s Objects can make decisions via conditional
state. (if) statements.
Constructors initialize objects. A true or false test allows one of two
Methods implement the behavior of objects alternative courses of actions to be taken.
Fields, parameters and local variables are all Objects can create other objects
variables. They can interact via method calls
Fields persist for the lifetime of an object. An object can call its own internal methods
Parameters are used to receive values into a
constructor or method.
Concepts
abstraction primitive types
modularization object types
classes define types object creation
class diagram internal/external Grouping objects
object diagram method call
object references
Collections and iterators
1.0
import java.util.ArrayList;
...
}
Retrieving an object Removal may affect numbering
Index validity checks
Review Review
Collections allow an arbitrary number of Items may be added and removed.
objects to be stored. Each item has an index.
Class libraries usually contain tried-and- Index values may change if items are
tested collection classes. removed (or further items added).
Java’s class libraries are called packages. The main ArrayList methods are add,
We have used the ArrayList class from get, remove and size.
the java.util package.
Iteration ‘While’ loop – pseudo code
We often want to perform some actions an General form of a while-loop
Boolean test
arbitrary number of times.
while keyword
E.g., print all the notes in the notebook. How many
are there?
while ( loop condition ) {
Most programming languages include loop loop body – code to be
statements to make this possible. repeated
Java has three sorts of loop statement.
}
We will focus on its while loop. Statements to be repeated
Example to print every note
while(there is at least one more note to be printed) {
show the next note
}
1.0
Superclass Subclasses
Polymorphism Casting
Java collection classes are polymorphic Allowed to assign subtype to supertype.
They can operate on many different types Not allowed to assign supertype to subtype!
while(loop condition) {
loop body Statements to be repeated
A few more Java features }
do … while loop
do keyword
“Fred” “Jill”
if(input.equals("bye")) {
...
} tests equality: does this string
have the same letters? person1 person2
input
Æ (may be) false!
input
Æ true!
Cambridge University
Computer Science Tripos Part 1a
How hard can it be … … to define this system?
The United Kingdom Passport Agency
http://www.parliament.the-stationery-office.co.uk/
pa/cm199900/cmselect/cmpubacc/65/6509.htm
1997 contract for new computer system born in issue
aimed to improve issuing efficiency, on tight project timetable UK passport
project delays meant throughput not thoroughly tested
first live office failed the throughput criterion to continue roll-out
second office went live, roll out halted, but no contingency plan
return to record record
rising backlog in early 1999, alongside increasing demand
leave UK UK exit entry
passport processing times reached 50 days in July 1999
widespread publicity, anxiety and panic for travelling public
telephone service overloaded, public had to queue at UKPA offices
only emergency measures eventually reduced backlog
dies cancel
So how hard can it be to issue a passport?
… let’s try some simple definition
Prototype
Specification 2
Implementation
& unit testing
Initial plan
Integration & Prototype
system testing 1
Operations &
maintenance Requirements
Development Code
plan Test
Integrate
Implement Develop and verify
Plan next phases next level product
The Design Process vs. The Design Books
Inception Code Complete: A practical handbook of software construction
Usage Model Use Case Diagrams Steve McConnell, Microsoft Press 2004 (2nd edition)
UML Distilled: A brief guide to the standard object modeling language
Structure Model Class Diagrams Martin Fowler, Addison-Wesley 2003 (3rd edition)
Further:
Elaboration Behaviour Models Statechart Diagrams
Software Pioneers, Broy & Denert
Activity Diagrams
Software Engineering, Roger Pressman
Interaction Models The Mythical Man-Month, Fred Brooks
Sequence Diagrams
The Design of Everyday Things, Donald Norman
Collaboration Diagrams
Construction Contextual Design, Hugh Beyer & Karen Holtzblatt
The Sciences of the Artificial, Herbert Simon
Implementation
Component Diagrams
Educating the Reflective Practitioner, Donald Schon
Models
Deployment Diagrams Designing Engineers, Louis Bucciarelli
Transition
Exam questions
This syllabus appeared under this name for
the first time in 2006 (without Java element):
Software Design 2006, Paper 2, Q7
But syllabus was previously introduced as:
Software Engineering II 2005, Paper 2, Q8
Inception phase
Some components had previously been
taught elsewhere in the Tripos: structured description of system usage
Programming in Java 2004, Paper 1, Q10 and function
Software Engineering and Design 2003 Paper 10,
Q12 and 2004 Paper 11, Q11
Additional Topics 2000, Paper 7, Q13
Pioneers – Tom DeMarco
Structured Analysis
1978, Yourdon Inc
Defined the critical technical role of the
system analyst
Analyst acts as a middleman between users and
How can you capture requirements?
(technical) developers
Analyst’s job is to construct a functional
specification
data dictionary, data flow, system partitioning
Each theatre has seats arranged in rows. Each theatre has seats arranged in rows.
Customers can reserve seats and are given a row number Customers can reserve seats and are given a row number
and seat number. and seat number.
They may request bookings of several adjoining seats. They may request bookings of several adjoining seats.
Each booking is for a particular show (i.e., the screening of Each booking is for a particular show (i.e., the screening of
a given movie at a certain time). a given movie at a certain time).
Shows are at an assigned date and time, and scheduled in a Shows are at an assigned date and time, and scheduled in a
theatre where they are screened. theatre where they are screened.
The system stores the customers’ telephone number. The system stores the customers’ telephone number.
operations
actions invoked on objects (Java “methods”) Customer
Seat Row
instance
Telephone number
can create many instances from a single class
state NB: one class, Number
all the attributes (field values) of an instance two uses
UML Class
diagram UML Class diagram
Attributes
type and visibility
Operations
signature and visibility
Relationships
association
with multiplicity
potentially aggregation
generalisation
Construction
UML Collaboration
diagram UML Sequence diagram
Objects
class instances
can be transient
Links
from associations
Messages
travel along links
numbered to show
sequence
UML Sequence diagram Loose coupling
Interaction again Coupling: links between parts of a program.
same content as
collaboration If two classes depend closely on details of
emphasises time each other, they are tightly coupled.
dimension
We aim for loose coupling.
Object lifeline
keep parts of design clear & independent
objects across page
time down page
may take several design iterations
Shows focus of control Loose coupling makes it possible to:
achieve reusability, modifiability
understand one class without reading others;
change one class without affecting others.
Thus improves maintainability.
object internals
int local_data_A;
Consistently express the logical structure int local_data_B;
bugs
bugs? k/T
Managing a large-scale testing process requires some kind
of statistical model. time spent testing
But changing testers brings new bugs to light
But not a good idea to use this as an incentive for
release targets, productivity bonuses etc
Programmers are smart enough to figure out basic statistics bugs tester
2 tester
if there is money involved. 3
tester
4
tester
1
Requirements
Specification
Implementation
& unit testing
written in
user's Integration &
language system testing
written in
system Operations &
language maintenance
checks units
against
specification
Checks
requirements
are met
Spiral model (Boehm, 88) Prototyping
Increasing cost
Evaluate alternatives
Determine objectives,
and resolve risks
Supports early investigation of a system.
alternatives, Risk analysis
constraints Early problem identification.
Risk analysis Incomplete components can be simulated.
Operational
prototype
e.g. always returning a fixed result.
Prototype
Prototype 1 2 May want to avoid random or time-dependent
Requirements plan
behavior which is difficult to reproduce.
Software Detailed
Life-cycle plan requirements design Allows early interaction with clients
Development Requirements
plan validation Code
Perhaps at inception phase of project
Test Especially (if feasible) with actual users!
Integrate In product design, creative solutions are
Implement Develop and verify
Plan next phases next level product discovered by building many prototypes
RJA fix:
Tuesday
Week-End: V0.2b
Version 0.2
0.4
Alan’s work
is clobbered!!
Record regular “snapshot” backups
often appropriate to do so daily Essential in programming teams
Provides ability to “roll back” from errors Avoid the “clobbering” problem
Older tools (RCS, SCCS) rely on locking
Useful even for programmers working alone
More recent (CVS) automate merging
Variants from branch fixes Builds and Releases
1 2a 2a1 2a2 3 4 Record actual configuration of components that were
in a product release, or an overnight build integrating
single
2b 2b1 2b2 work of a large team.
update
split merge Allows problems to be investigated with the same source
two two code that was delivered or tested
updatesupdates
Often includes regression testing as part of build process
Branching (from local fixes) results in a tree of Also allow start of development on next release while
different versions or “variants” testing and supporting current release
Maintaining multiple branches is costly Universal requirement of commercial software development
(at least after release 1.0!)
Merge branches as often as possible Bug fixes made to 1.0.1 are also expected to be there in 2.0,
Minimise number of components that vary in each which requires regular merging
branch (ideally only one configuration file) Think about this: ‘About Internet Explorer’ reported:
If necessary, conditional compile/link/execution 6.0.2900.2180.xpsp2.070227-2254
can merge several variants into one
Participatory Design
User-centred Design
Focus on ‘end-users’, not just specifications Users become partners in the design team
from contract and/or client Originated in Scandinavian printing industry
Use ethnographic methods at inception stage Now used in developing world, with children, …
Design based on user conceptual models PICTIVE method
Early prototyping to assess conceptual model Users generate scenarios of use in advance
Low fidelity prototyping tools (simple office
Contextual evaluation to assess task
supplies) are provided for collaborative session
relevance The session is videotaped for data analysis
Frequent iteration
CARD method
Cards with screen-dumps on them are arranged
on a table to explore workflow options
Xtreme Programming’ (XP) Would XP have helped CAPSA?
Described in various books by Kent Beck Now Cambridge University Financial System
An example of an agile design methodology Previous systems:
Increasingly popular alternative to more In-house COBOL system 1966-1993
“corporate” waterfall/spiral models. Didn’t support commitment accounting
Reduce uncertainty by getting user feedback Reimplemented using Oracle package 1993
as soon as possible, but using actual code No change to procedures, data, operations
Typical team size = two (pair programming). First (XP-like?) attempt to change:
Constant series of updates, maybe even daily. Client-server “local” MS Access system
Respond to changing requirements and To be “synchronised” with central accounts
understanding of design by refactoring. Loss of confidence after critical review
When used on large projects, some evidence May 1998: consultant recommends restart
of XD (Xtreme Danger)! with “industry standard” accounting system