Development environments and processes Claude Petitpierre, Olivier Buchwalder, Paul-Louis Meylan.

57
Development environments and processes Claude Petitpierre, Olivier Buchwalder, Paul-Louis Meylan
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    220
  • download

    3

Transcript of Development environments and processes Claude Petitpierre, Olivier Buchwalder, Paul-Louis Meylan.

Development environments and processes

Claude Petitpierre,

Olivier Buchwalder,

Paul-Louis Meylan

(Swiss Federal Institute of Technology)

~ 340 professors~ 3400 researchers~ 6000 students6 schools

ENAC: Architecture, civil engineering, environmentI&C: Informatic & communicationsSB: Math, physics, chemistrySTI: Electricity, mechanics, microtechnics, materialsSV: Life sciencesCDM: Management of Technology

EPFL - Ecole Polytechnique Fédérale de Lausanne

RUP, MDA, IDE, Environment ?

J2EE + WebLang

Language Workbench

http://ltiwww.epfl.ch/WebLang

How to build Internet applications ?

The FBI tragic experience

The VCF was supposed to automate the FBI's paper-based work environment, allow agents and intelligence analysts to share vital investigative information, and replace the obsolete Automated Case Support (ACS) system. Instead, the FBI claims, the VCF's contractor, delivered 700 000 lines of code so bug-ridden and functionally off target that this past April, the bureau had to scrap the US $170 million project […]

IEEE Spectrum: Who Killed the Virtual Case File?September 2005

Patterns ?

They are often not adapted to an application’s description !

Address too low a level!

Spaghetti Programming (PAC + MVC)

list selected

resize

add element mainprogram call

combo box selected

invokeLateror

event

The MVC pattern

Controller View

Model (data)

Events

Wikipedia (search MVC > Holub)

JBoss IDE (Wizards)

Tutorial

See Chapter 5, Generation of the EJB related files

Tedious, poor overview!

Arc Styler (MDA – UML diagrams)

Tutorial

See page 35 and previous pages

Not much improvement!

Will MDA save the world ?

UML2, OCL and Action semantics coupled

with the MOF seem destined to be sucked

into yet another committee attempt to unify

the world in a single grand language – the

vain quest for a “computer Esperanto”.

Dave Thomashttp://www.jot.fm/issues/issue_2003_01/column1

What else then ?

DSL, domain specific languageshttp://www.codegeneration.net

Language benchworkMSP, by Jetbrains, a tool to create DSLhttp://www.martinfowler.com/articles/mpsAgree.html

Our language: WebLang

• list of templates (derived form examples)• parser (Javacc)• generator (JET)

WebLang Generator

templatescomponentdatabase

user program

classes control files( .xml)

parser (javacc)

producer (JET)DSL SyntaxDSL Syntax

See: www.codegeneration.net

ExamplesExamples

UserUser

A Template (≠ JET)

//*START $OOTTYPE $OOTNAME $OOTREL $UOOTREL *//

public $OOTPACK.$OOTTYPE get$UOOTREL() { return ($OOTREL);}

public void set$UOOTREL ( $OOTPACK.$OOTTYPE _$OOTNAME ) throws Exception { if (_$OOTNAME != null) {

. . .

}

//*END *//

Details of our language

A servlet and its caller

Client Server

servlet: showDate

doGet() ;

html: showDate

Best way to call a servlet ?Here is our choice:

servlet: Test.java

doGet() { . . .}

m1(int a, String b) { ... } m2(String c, long d) { ... }

html: InputForms

<FORM action= “Test">ab

m1

cb

m2

WebLang Servlet Module

servlet Test {

package myPackage;

m1 (int a, String b) { ... }

m2 (String c, long d) { ... }

}

// The compiler generates automatically // the .java and the .html files

Servlet template

public class Test extends HttpServlet {

public void doGet ( HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html");

x = request.getSession().getArgument("a");

myMethod(x);

}

void m1(String a) {…

}}

Template for a html pagethat calls the servlet

html: InputForms

<FORM action= "test"><INPUT ... name=“a"><INPUT ... name=“b"><SUBMIT name="m1">

</FORM>

<FORM action= "test"><INPUT ... name="c"><INPUT ... name=“d"><SUBMIT name="m2">

</FORM>

Client

N

1

ServerWebLang modules

CMP bean: Town

name

populationservlet: TownInCtry

enterData()

CMP bean: Country

name

area

Persistent objects in WebLang

html: TownInCtr

EJB WebLang Modules

cmpbean Town {package geo;

relations (Country = N:1)String name; // DB attributesint number;public void myMet (String s) {

System.out.println(s);}

// creators - finders}

Creation and use of a persistent object in WebLang

Town t ;

Country c ;

t = townHome.create("Lausanne");

c = countryHome.create("Switzerland");

System.out.println( t.getName() );

c.setName( "Suisse" );

WebLang leads to better descriptions than the ones Sun used for its Pet Store

The Pet Store: Application Description

Workflow (functions)

Workflow(devices)

Sun’s Tutorial

Struts

petListForm.petForm[ ]

(form)

basket.petFrom[ ](form)

PetOrder status = ordered OrderItems* (CMP+CMR)

0

1

showBasket

notconfimed

petListForm(JSP)

your_order (JSP)

basket(JSP)

2

confirmed

OK

PEtStore in WebLang (MVC-2 extended)(three-tiers, each object corresponds to a module)

JSPs Action Servlet

Action Forms

CMP bean

struts PersonManagement {

package management;

stateMachine

statedef State_0 (person);

statedef State_1 (job);

. . . FSM . . .

page person {

forms ( personForm,

personForm.sportForm[ ],

personForm ("Comment", submitName) );

}

}

WebLang Module : states and pages

// Pure Java code

WebLang Module : Finite State MachinestateMachine { statedef State_0 (supply); statedef State_1 (supplyConfirmation); switch (sessionState) { case State_S: sessionState = State_0; break; case State_0: Pet pet = petHome.create( petForm.getName() ); sessionState = State_1; break; case State_1: if (supplyConfirmation.getConfirmation()) sessionState = State_0; }}

Administrator

Struts

Three tiers (overview)

browseForm.petForm[ ] (form)

basket.petFrom[ ] (form)

PetOrder status = ordered OrderItems* (CMP+CMR)

PetOrder status = awaitInvoice OrderItems* (CMP+CMR)

PetOrder status = toBeChecked OrderItems* (CMP+CMR)

file

OrderForm.petForm[ ]not accept

(form)

Buying

Struts

0

1

showBasket

notconfir-med

browser (JSP)

order-registered

(JSP)

showBasket (JSP)

2

SendSupplierPO

MDBean

0

select

login

confirmed

1confirmed

OK

areYouThe-Administrator

(JSP)

checkOrders (JSP)

Display Business Layer Database

+ Dataflow

DisplayBusiness Layer

Queue

Action Forms CMP Beans

PersonForm

PersonRecreate a collection and copie one into the other member by member

Action forms

CMP beans

Next Problem:

Improving current architectures

• Container managed beans of J2EE too complex for what they offer

• A CMP bean cannot be used as a Java bean (requires data transfers)

• Hibernate improves the situation, but …

• … our SQL beans still go one step further

SQL Bean Example

sqlbean Town extends ActionForm {

package appliT;

relations (<isCapitalOf 1:1 hasCapital> Country);

String name;

public long findPK_OfTown(String x) throws Exception {

query = "SELECT * FROM Town

WHERE name=$name;

OR name=$x“ }}

Use of the SQL bean

MySQLBean mb = new MySQLBean ( );

mb.setName("someName");

mb.store();

// stores the content into the database // and set the PK into the bean

// No home proxy !

Use of a finder

// we assume that country has been created // and filled by the Struts mechanism

case State_1:

long pkC = country.findPK_OfCountry();

if (pkC != 0) { country.reloadAll(pkC); // from the DB } else { country.store(); // into the DB } country.addTownN(town);

SQL Bean Example

sqlbean Town extends ActionForm {

package appliT;

. . .

}

TownN { // object used to look for collections

public void findN_TownList(String s) throws Exception {

query = "SELECT * FROM Town WHERE name>$s"

}

Finders throwing ExceptionTownN { String name; public void findTownList (String s) throws Exception { query = "SELECT * FROM Town WHERE name>$s" }} ……………………………………………………………..

TownN tn = new TownN();

try { tn.findTownList(“N”);} catch (weblangUtils.SQLException we) { System.out.println(“Not found”);}

for (Town t: tn) { System.out.println(“t.getName());}

Detached object

Attached object

pk!=0

Attached + linked + connected object

pk!=0 rel!=0

Linked object

pk==0

o.delete()

o.findXx()

o.store()o.set(null)

o.remove(o1)

o.set(o1)o.add(o1)

o.set(null)o.remove(o1)

o.set(o1)o.add(o1)

o.reload(pk)

o.reloadAll() o.storeAll()

o.deleteAll()

o.reload()o.reloadAll()o.update()o.updateAll()

o.delete()

o.findPKXx()

o.store()

o.delete()

o = new Xxx()

FSM of the SQL beans

Operations of the SQL beans

store Copies the data of the object into the database, new primary key inserted in the object

findXxx Query method returning a DB row, the objectmust be instantiated before the method is called

findPKXxx Returns the value of the primary key (or 0),method may also throw an exception

reload(pk) Method copies the data of the object into a DB row with primary key pk

update Dual of the reload, updates the database row that has the PK found in memory

delete Removes the data in the database, not the memory, resets the object’s primary key

SQL beans• SQL beans have been devised at the

EPFL: they present the same structure as Hibernate 3 (particularly within WebLang), but they only use JDBC and the standard SQL

• Much simpler to debug, as all statements may be traced within the debugger

• No home nor manager, the object holds the finder; it is instantiated by new before find can be called.

How to standardize client architecture ?

GUI elements

Standard use of listeners in a GUI

Server

Java client

GUI Listeners

actionPerformed() {

}

Business layer

FSM () {

}

Message Listener

onMessage () {

}

GUI

setUsername ()getUsername ()setPosition ()setError ()

topic

Better use of Listeners

Conclusions

• WebLang provides a lower bound in the level of development complexity. No system should be more complex without reason.

• A language provides a simpler mean for the developer and the user of the compiler.

• WebLang opens new directions for creating Web (and other) applications.

• WebLang is not alone on this avenue: competition, such as MSP of Jetbrains and Ruby on Rails are coming up.

Synchronous Java(Concurrent objects)

Available in WebLang

Object O2Object O1

run () { . . . select { case O2.send (msg) ; case O3.m(x); } . . .}

run () { . . . select { case O2.send (msg) ; case O3.m(x); } . . .}

void send (String msg){ ......... }

run () {

accept send;

}

void send (String msg){ ......... }

run () {

accept send;

}

Object O2Object O1

void send (String msg){ .......... }

run () {

accept send;

}

void send (String msg){ .......... }

run () {

accept send;

}

void send (String msg){ ......... }

run () {

accept send;

}

void send (String msg){ ......... }

run () {

accept send;

}

run () { . . . select { case O2.send (msg) ; case O3.m(x); } . . .}

run () { . . . select { case O2.send (msg) ; case O3.m(x); } . . .}

stub

Event-driven versus listeners: active objects

GUI elements

skeleton

read

Coding a UML State Diagramwith

Synchronous Active Objects

P. Kruchten, The Rational Unified Process – An Introduction, Addison-Wesley

How to Use thisUML Diagram ?

Implementation of the Collaboration Diagram

: SessionManager

: Authenticator

: CardReader

: Display

: CardValidator

: ATM Network

: Keypad

1 : insert card

8 : get PIN

6 : "Enter PIN"

7 : PIN entered

11 : PIN valid ?

10 : PIN valid ?

9 : PIN valid ?

(4 : new session)

3 : validate card

: ATM network

: customer

5 : "Enter PIN"

2 : read card

// Session manager

loop {

2 : read card

3 : validate card

5 : "Enter PIN"

8 : get PIN

9 : PIN valide ?

}

The Sliding Window Protocol

(Go Back n)

Sliding Window Protocol: System Configuration

C2Out

C1In

C2In

C1Out

Source Destination

User 1 User 2

channels

messages losses

SWP : Message Exchanges

Source Destination

acknowledgement 1message 0

acknowledgement 2message 1

message 2

time

SWP: Data Storage

1 2 3 4 5 6 7 0 1 2 3

first middle

messagessent andacknowledged

messagessent but notacknowledged

messages ready forsending

futuremessages

window

messages kept in a queuewithin the source

last

SWP: 4 Events (Rendezvous) Handled by the Emitter

• Reception of a message from the user

• Acceptance of a message by the network driver (in order to send it)

• Timeout (one acknowledgement expected)

• Reception of an acknowled-gement from the network

C2Out

C1In

Source

User 1

SWP Program (Beginning)for ( ; ; )

select {

when ( window < WindowSize ) // a message from the user accept Write; window++ ; ULMessage.NS = NSend; NSend = ( NSend + 1 ) % WindowRange; Q.PutMessage ( ULMessage ); || when ( Q.middle != NULL ) // a message is ready to be sent C1.In ( MakeACopy (Q.middle) ); Q.middle.date = now(); Q.middle = Q.middle.next; || . . . 4 5 6 7 0

first middlewindow

SWP Program (End) ||

when ( Q.middle != Q.first ) // at least 1 message is not acknowledged

waituntil ( Q.first.date + T1 );

Q.middle = Q.first;

||

LLMessage = C2.Out (); // get an acknowledgement

while ((Q.first != NULL) && (Q.first.NS != LLMessage.NR)) {

window-- ;

ackgedMsg=Q.ExtractMessage ( ); // delete acknowledged messages

// middle has been updated if needed;

}

}

}; The receiver just accepts and acknowledges the messages in sequence

4 5 6 7 0

first middlewindow