Title: Gnie logiciel Software Engineering C' Petitpierre
1Génie logicielSoftware EngineeringC.
Petitpierre
2Development Process
3Waterfall Development Process
Analysis
Design
Implementation
Testing
?
Maintenance
Civil engineering One first draws plans and
only then are they realized ! Why wouldnt it
work with software ?
4Iterative Process (spiral)
Test
Implementation
Maintenance
Development
Analysis
Design
Superficial analysis, design, implementation and
test of the whole application, then better
analysis, design, implementation and test, and
improvement at each revolution ? or ? Thorough
analysis, design, implementation and test of a
part, and then analysis, design, implementation
and test of a new part at each revolution ?
5Agile Development Process
Most important characteristics No long term
planning. Deliver working software frequently
(from a couple of weeks to a couple of months,
with a preference to the shorter timescale).
6XProgramming
- Planning
- Designing
- Coding
- Testing
of a slice
2-6 weeks
7UMLUnified Modeling Language(OMG object
management group)
http//www.uml.org/ http//www.omg.org/
8Class diagram inheritance
9UML note(Omondo on Eclipse)
10Class diagram aggregation
Bill - numberOfItems int addItem(itemItem)
- getFirstItem() Item getNextItem() Item
BillItem ProductNumber int
NumberOfPieces int UnitPrice int
1
0..
Customer name String
11Sequence diagram
Main
Object X
Object B
new ( )
start ( )
run ( )
xMeth ( )
12Activity diagram an example
registration
Fork Two threads Join
quit
find
close
log
register
13ltlt Stereotypes gtgt
Customer name String
ltlt CMP EJB gtgt Bill - numberOfItems int
ltlt hasBills gtgt
14List of elements
15List of elements
function Head() this.first null
this.last null this.current null
function init() var lst new Head()
lst.addAlpha(new Name("Max"))
lst.addAlpha(new Name("Henri"))
lst.addAlpha(new Name("Moritz"))
lst.addAlpha(new Name("Judith")) var t
lst.current null while((t lst.next()) !
null) document.write(t.obj.name "ltbrgt
")
function Handle( o ) this.next null
this.obj ofunction Name(name)
this.name name
16List of elements
Head.prototype.next function()
if (this.current null)
this.current this.first else
this.current this.current.next
return this.current
Head.prototype.add function(o)
if (this.firstnull)
this.first new Handle(o)
this.last this.first else
this.last.next new Handle(o)
this.last this.last.next
17Insertion in alpha order
Head.prototype.addAlpha function(o)
var t, tmp var tmp new Handle(o)
if (this.firstnull)
this.add(o) return
this.current null if (o.name lt this.first.o
bj.name) tmp.next this.first
this.first tmp else
while( (t this.next()).next ! null)
if (o.name lt t.next.obj.name)
tmp.next t.next
t.next tmp return
t.next tmp
this.last tmp
18Insertion in alpha order
Head.prototype.addAlpha function(o)
var t, tmp var tmp new Handle(o) .
. . while( (t this.next()).next ! nul
l) if (o.name lt t.next.obj.name)
tmp.next t.next
t.next tmp
return
t.next tmp this.last tmp
tmp
o
t
19Design Patterns
http//en.wikipedia.org/wiki/Design_Patterns http
//en.wikipedia.org/wiki/Design_pattern_(computer_
science) See also anti-patterns in Wikipedia and
http//ltiwww.epfl.ch/petitp/GenieLogiciel/
PointCounterPoint.pdf
20Design Patterns
Christopher Alexander is an architect noted for
his theories about design. He produced and
validated a pattern language designed to empower
any human being to design and build at any scale.
The concept of design patterns has been reused
in IT by E.??Gamma, R Helm, R. Johnson and J.
Vlissides also known as the Gang of Four or GoF.
They have sold 500.000 copies of their
book. Abstract factory, Adapter, Composite,
Decorator, Factory methods, Observer, Strategy,
Template method E. Gamma is currently heading
the Eclipse project Other books about patterns
have been written by other authors
21The GoF patterns
Design Patterns Elements of Reusable
Object-Oriented Software, E. Gamma (mostly at
the class level, not the application level)
22Singleton
Class2
Class1
Class3
Singleton
Only one singleton is instantiated One does not
know the order in which the Classi are
instantiated All Classi are not always present,
they have no references to each other and there
may be other such classes later Who does create
the Singleton ?
23Equivalent in Javascript
function Singleton() this.attr 13Single
ton.instance null // Will contain the one and
only instance of the class
// Remember, a function's
definition is stored in an objectSingleton.getIns
tance function() if (Singleton.instance
null) Singleton.instance new Singleto
n() return Singleton.instanceSingle
ton.prototype.alerte function() alert(this
.attr)function init() //
Creation and call of the singleton var single
Singleton.getInstance() single.alerte()
// But in
Javascript, it is easy to declare a single global
object
24Composite tree structure(one must be able to
walk through and add/remove groups or leaves in
the same way)
super group
Model of a diagram for a graphical application
group
square
line
circle
square
25Composite
26Composite object diagram
super group tableau
group tableau
square
line
circle
square
Chaque objet extends Component pour que tous les
noeuds soient semblables
27Composite object diagram
Component
Component
Component
Component
group
square
line
Component
Component
circle
square
Chaque objet extends GraphicComponent pour que
chaque noeud soit semblable
28Composite in Javascript
function GraphicComponent (name) this.na
me name GraphicComponent.prototype.print f
unction () console.log(" "this.name)
Base element
CompositeGraphic.extend(GraphicComponent) functi
on CompositeGraphic () this.mChildGraphic
s new Array() CompositeGraphic.prototype.
print function () for (var i0 iltthis.m
ChildGraphics.length i) this.mChild
Graphicsi.print() CompositeGraphic.p
rototype.add function (child) this.mChil
dGraphics.push(child)
Aggregate element
29Node examples
Line.extend(GraphicComponent) function Line(name,
x1, y1, x2, y2) Line.upper(this, name)
this.x1 x1 this.y1 y1 this.x2
x2 this.y2 y2 Line.prototype.print
function () Line.upperClass.print.call(thi
s) ctx.moveTo(this.x1, this.y1) ctx.li
neTo(this.x2, this.y2)
Node element Canvas Rectangle
Rect.extend(GraphicComponent) function Rect(name,
x1, y1, w, h) Rect.upper(this, name) th
is.x1 x1 this.y1 y1 this.w w thi
s.h h Rect.prototype.print function ()
Rect.upperClass.print.call(this) ctx.fillSty
le"rgb(255,0,0)" ctx.fillRect(this.x1, this.
y1, this.w, this.h)
Node element Canvas Line
30Utilisation des objets précédents
var g1 new CompositeGraphic()
function init() var o1 new Line("l
1", 10,10,100,100) g1.add(o1)
g1.add(new Line("l2", 10, 100, 100, 100))
g1.add(new Rect("r1", 10,10,55,50))
g2 new CompositeGraphic() g1.a
dd(g2) g2.add(new Rect("r2", 100,10,55
,50)) g2.add(new Rect("r2", 200,100,55
,50)) g1.print ()
31Observer
call
Each time the subject is called, it calls a
method in all the observers. Thus at the end of
each method called in the subject, there is a
call to the list of observers. The observer are
registered, sometimes by themselves The observers
must of course have a common interface. They are
also called listeners!
call
call
Subject
Observer
Observer
32Observer
Subject void notify() for (observer o
pool) o.update()
Event
33Observer
- Observer
- update()
- it often register itself in the subject
- Subject
- notify()
- addObserver()
- removeObserver()