24
Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009

Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Component-Based Software Engineering

ReviewPaul Krause

Thursday, 26 March 2009

Page 2: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Why Software Engineering? The difference between writing a program

and engineering a software systemis like the difference between building a

patio table and building a bridge You can patch up one until it works You need careful analysis and design to

succeed with the other Good Software Engineering practice is

essential for Software Components

Thursday, 26 March 2009

Page 3: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Software Components mean? The main driver behind software

components is reuse. That means we must modularise

applications if they are to have potentially reusable parts.

The expectation is that if the parts (often collections of classes) can be reused then costs will be reduced (in the long run…).

Thursday, 26 March 2009

Page 4: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Drivers for CBD The development of the WWW and

Internet Systems of loosely coordinated services

Object-oriented design techniques and languages

Move from Mainframe to client-server based computing

Rapid pace of technological change Economic necessity of maximising reuse

Thursday, 26 March 2009

Page 5: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Definition A software component is a unit of

composition with contractually specified interfaces and explicit context dependencies only.

A software component can be deployed independently and is subject to composition by third parties.

1996 European Conference on Object-Oriented Programming

Thursday, 26 March 2009

Page 6: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Connector Design

:Button

:Button

:Motor :Meter

pressed

pressed

start

stop

speed

value

Thursday, 26 March 2009

Page 7: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Connector Design

:Button

:Button

:Motor

:Meter

pressed

pressed

start

stopspeed

value:OR

:Threshold

a

b

a ∨ b

a > b

a < b

:Multiplier

:Selector{1, 10, 100}

a b

a x b

5:int

a

b

Thursday, 26 March 2009

Page 8: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Interfaces Interfaces allow the clients of a component

to access the services provided by a component

Different interfaces will normally provide access to different services

Each interface specification could be viewed as a contract between the component and a client

Thursday, 26 March 2009

Page 9: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Component Specification Provides Interfaces

The services a component can offer to a client Requires Interfaces

The services required by a component to help it deliver its promises

Context of Use The “world” the component lives in

Thursday, 26 March 2009

Page 10: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Interfaces Interfaces allow the clients of a component

to access the services provided by a component

Different interfaces will normally provide access to different services

Each interface specification could be viewed as a contract between the component and a client

Thursday, 26 March 2009

Page 11: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

What is a Java Bean? “A Java Bean is a reusable software

component that can be manipulated visually in a builder tool”

JavaSoft

Thursday, 26 March 2009

Page 12: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Downside of Beans

As components, they are not “wired” together, but tightly coupled:

public class KnightOfTheRoundTable {private String name;private HolyGrailQuest quest;

public KnightOfTheRoundTable(String name) {this.name = name;quest = new HolyGrailQuest();

}......

}

12

Thursday, 26 March 2009

Page 13: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

A simple Changepublic class KnightOfTheRoundTable {

private String name;private Quest quest

public KnightOfTheRoundTable(String name) {this.name = name;quest = new HolyGrailQuest();

}...public void setQuest(Quest quest) {

this.quest = quest}

}

13

Thursday, 26 March 2009

Page 14: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Use of Interfaces

public interface Quest {abstract Object embark();

}

public class HolyGrailQuest implements Quest {public Object embark() {

// do Knightly stuff herereturn new HolyGrail();

}}

14

Thursday, 26 March 2009

Page 15: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Giving a Knight a Quest

<beans ... // some setup stuff><bean id=”quest” class=”knight.HolyGrailQuest” /><bean id=”knight”

class=”knight.KnightOfTheRoundTable”><constructor-arg value=”Bedivere” /><property name=”quest” ref=”quest” />

</bean></beans>

15

Thursday, 26 March 2009

Page 16: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Big fleas have little fleas upon their backs to bite them,

and little fleas have lesser fleas, and so on ad infinitum

16

Thursday, 26 March 2009

Page 17: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

REST- Interfacing across the Web “The Web used properly” Roy Fielding’s PhD dissertation

identified the architectural principles that had emerged in the design of http http://www.ics.uci.edu/~fielding/pubs/

dissertation/top.htm

17

Thursday, 26 March 2009

Page 18: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

1. Give Every “Thing” an ID

http://example.com/customers/1234

http://example.com/orders/2007/10/776654

http://example.com/products/4554

http://example.com/processes/sal-increase-0

18

Thursday, 26 March 2009

Page 19: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

2. Link Things to Each Other

<order self=‘http://example.com/orders/1234> <amount>23</amount>

<product ref= ‘http://example.com/products/4554><product ref= ‘http://example.com/customers/888>

</order>

19

Thursday, 26 March 2009

Page 20: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

3. Use Standard Methods

GET retrieve information, possibly cached

PUT Update or create with known ID

POST Create, or append sub-resource

DELETE (Logically) remove

20

Thursday, 26 March 2009

Page 21: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

4. Allow for Multiple “Representations”

HTML XML SVG ATOM JSON ...

21

Thursday, 26 March 2009

Page 22: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

5. Communicate Statelessly

GET /customers/1234Host: example.comAccept: application/vnd.mycompany.customer + xml....shutdown, change server, update software, buy new car, save planet, startup

GET /customers/orders/46Host: example.comAccept: application/vnd.mycompany.order + xml

22

Thursday, 26 March 2009

Page 23: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

Consequences

23

Thursday, 26 March 2009

Page 24: Component-Based Software Engineering€¦ · Component-Based Software Engineering Review Paul Krause Thursday, 26 March 2009. Why Software Engineering? The difference between writing

24

Thursday, 26 March 2009