modelēšana un rīku būve (specseminārs)
DESCRIPTION
Modelēšana un rīku būve (specseminārs). Elīna Kalniņa, Agris Šostaks 2013. Šodien. Saimnieciskie jautājumi (Kas, Kur, Kad, Kā ???) Ievads modelēšanas rīku būvē Kas ir modelēšana, modeļi, modelēšanas valodas Kas ir Domēn Specifiskas Valodas (DSL – Domain Specific Languages) - PowerPoint PPT PresentationTRANSCRIPT
Modelēšana un rīku būve(specseminārs)
Elīna Kalniņa, Agris Šostaks 2013
Šodien
• Saimnieciskie jautājumi (Kas, Kur, Kad, Kā ???)• Ievads modelēšanas rīku būvē
– Kas ir modelēšana, modeļi, modelēšanas valodas– Kas ir Domēn Specifiskas Valodas (DSL – Domain
Specific Languages)– Rīku būves platformu apskats
• Demo
Saimnieciskie I
• Kas?– LU DF docente, LU MII vadošā pētniece Elīna
Kalniņa– LU DF docents, LU MII vadošais pētnieks Agris
Šostaks– LU DF bakalaura programmas studenti
Saimnieciskie II
• Kad? – Trešdienās, 16:30
• Kur?– Raiņa 29-404
• Kā sazināties?– E-pasts: [email protected]– E-pasts: [email protected]– Skype: @agrissh
Saimnieciskie III
• Ko darīsim?– Pasniedzēji izstāstīs metamodelēšanas,
modeļbāzētās izstrādes pamatus un parādīs vairākas rīku būves platformas.
– Studenti izvēlēsies kādu rīku būves platformu un uzbūvēs rīku:
• Pasniedzēja ieteiktai modelēšanas valodai• Pašu izvēlētai modelēšanas valodai
– Studenti referēs par pasniedzēja izvēlētu tēmuVAI
Saimnieciskie IV
• Par ko dos kredītpunktus?– Semināru apmeklējumu un aktīvu piedalīšanos– Patstāvīgu modelēšanas rīka izstrādi un atrādīšanu
seminārā
Kas ir modelēšana?
• “Modeling in its broadest sense is the cost−effective use of something in place of something else for some purpose. It allows us to use something that is simpler, safer, or cheaper than reality instead of reality for some purpose. A model represents reality for the given purpose; the model is an abstraction of reality in the sense that it cannot represent all aspects of reality.”
/Jeff Rothenberg/
Kāpēc modelēt?
• Lai saprastu pasauli• Lai simulētu, t.i., paredzētu notikumus• Lai palīdzētu uzbūvēt sarežģītas lietas
– arī lai tās vēlāk varētu saprast– arī lai vēlāk simulētu, t.i., pārbaudītu vai kaut kas
derīgs iznāks
Kas ir modelis?
Author Definition
Oxford Dictionaries 1. a three-dimensional representation of a person or thing or of a proposed structure,
typically on a smaller scale than the original;
o (in sculpture) a figure or object made in clay or wax, to be reproduced in another
more durable material;
2. a thing used as an example to follow or imitate;
o a person or thing regarded as an excellent example of a specified quality;
o an actual person or place on which a specified fictional character or location is
based;
o (the Model) the plan for the reorganization of the Parliamentary army, passed by
the House of Commons in 1644-5.
3. a simplified description, especially a mathematical one, of a system or process, to assist
calculations and predictions;
4. a person employed to display clothes by wearing them;
o a person employed to pose for an artist, photographer, or sculptor;
5. a particular design or version of a product;
o a garment or a copy of a garment by a well-known designer. [131]
Jeff Rothenberg “Modeling in its broadest sense is the cost-effective use of something in place of something else
for some purpose. It allows us to use something that is simpler, safer, or cheaper than reality
instead of reality for some purpose. A model represents reality for the given purpose; the model
is an abstraction of reality in the sense that it cannot represent all aspects of reality.” [143]
Marvin L. Minsky “To an observer B, an object A* is a model of an object A to the extent that B can use A*
to answer questions that interest him about A.” [112]
Jean Bézivin “A model is a simplification of a system built with an intended goal in mind. The model
should be able to answer questions in place of the actual system.” [18]
Author Definition
Alan W. Brown “Models provide abstractions of a physical system that allow engineers to reason about
that system by ignoring extraneous details while focusing on the relevant ones.” [24]
Liliana Favre “A model is a simplified view of a (part of) system and its environments.” [40]
Michael Jackson “Here the word ‘Model’ means a part of the Machine’s local storage or database that it
keeps in a more or less synchronised correspondence with a part of the Problem Domain. The
Model can then act as a surrogate for the Problem Domain, providing information to the Machine
that can not be conveniently obtained from the Problem Domain itself when it is needed.” [61]
Thomas Kühne “A model is an abstraction of a (real or language based) system allowing predictions or
inferences to be made.” [89]
Jochen Ludewig “Models help in developing artefacts by providing information about the consequences
of building those artefacts before they are actually made.” [103]
OMG “A model of a system is a description or specification of that system and its environment
for some certain purpose.” [111]
Ed Seidewitz “A model is a set of statements about some system under study (SUS).” [147]
Bran Selic “Engineering models aim to reduce risk by helping us better understand both a complex
problem and its potential solutions before undertaking the expense and effort of a full
implementation” [148]
Wilhelm Steinmüller “A model is information: on something (content, meaning), created by someone
(sender), for somebody (receiver), for some purpose (usage context).” [160]
Thomas Stahl,
Markus Völter
“A model is an abstract representation of a system’s structure, function or behaviour.”
[159]
Kas ir modelis?
• “A model is a simplification of a system built with an intended goal in mind. The model should be able to answer questions in place of the actual system.”
/Jean Bézivin/
Modeļa piemērs
“Sistēma”
Modelis
Vēl divi modeļu piemēri“Sistēma”
Modelis 2
Modelis 1Vēlētāju aktivitāte
Modeļa piemērs – Parīzes metro 1
Modeļa piemērs – Parīzes metro 2
Modeļi programmatūras izstrādē?
• Lai uzbūvētu/saprastu sarežģītu programmatūras sistēmu, arī tiek būvēti modeļi, kas apraksta sistēmas dažādus aspektus dažādās detalizācijas pakāpēs– Sistēmas prasību specifikācija– Informācijas plūsmas modelis– Sistēmas konceptuālais modelis– Biznesa procesu modelis – Sistēmas projektējuma modelis– Datu modelis– Lietotāja saskarnes modelis– Sistēmas uzvedības modelis– ...– Programmatūras kods
Modelēšanas valodas• Modelēšanas valodas nepieciešamas, lai pierakstītu modeļus un lai citi šos
modeļus varētu saprast. • Piemēri:
– ER diagrammas• Čena sintakse• “Vārnu kāju” sintakse• ...
– Datu plūsmu diagrammas (DPD)– UML
• klašu diagramma• aktivitāšu diagramma• secības diagramma• stāvokļu diagramma• komponenšu diagramma• lietojumu diagramma
– BPMN (apraksta biznesa procesus)– SysML– SQL (arī to var uzskatīt par modelēšanas valodu!)– ...
• Modelēšanas valodas var būt gan grafiskas, gan tekstuālas! Modelis nav tikai bildīte! Svarīgs ir MĒRĶIS, ar kādu modelis ir veidots!
Modelēšanas valodu piemēri• Lietojumu diagramma• Aktivitāšu diagramma• Komponenšu diagramma• Secības diagramma• Klašu diagramma• Biznesa procesu modelis
uc Reserv ations
(from Common)
Browse an offer
Browse an offer and reserve
Customer
(from Actors)
(from Common)
Change display criteria
«use»
«invoke»{userintervention}
act Browse an offer and reserve
(Customer) wants to make : facility reservation
(System) shows : reservable facility list
(Customer) selects : facility
(System) shows : information message
Message: "No facilities found according to the given criteria"
(System) asks to confirm : facility reservation
(System) reserves : facility : for : customer
«...success
«...ActivityInitial
«invoke/request»
Change display criteria
«Pre-condition»{Customer must be logged in}
(System) asks to select : facility reservation time
(Customer) selects : facility reservation time : from :
time table
(System) shows : facility reservation summary
(Customer) confirms : facility reservation
(Customer) discards : facility reservation
«invoke/insert»
Change display criteria
[l ist is empty]
[rejoin]
[rejoin]
class Architecture
User Interface
Application Logic
Business Logic
Data Access Layer
UserInterface
IUserInterface
Common
IChangeDisplayCriteria IRegisterACustomer
Reserv ations
IBrowseAnOfferAndReserve
CustomersServ ices
ICustomer
FacilitiesServ ices
IFacil ity
CustomersDataAccess
ICustomerDAO
ICustomerDataDAO
FacilitiesDataAccess
IFacil ityDAO
sd Browse an offer and reserve - basic path
User Interface::UserInterface
Customer
(from Actors)
«interface»
CustomersServices::ICustomer
«interface»
Reservations::IBrowseAnOfferAndReserve
IUserInterface
(from User Interface)wants to make facilityreservation() wantToMakeFacilityReservation()
showReservableFacilityList()
selects facility()
selectFacility()
askToSelectFacilityReservationTime()
selects facility reservationtime from time table()
selectFacilityReservationTimeFromTimetable()
askToConfirmFacilityReservation()confirms facilityreservation()
confirmFacilityReservation()reserveFacility(CustomerDTO,FacilityDTO)
showFacilityReservationSummary()
Modelēšanas rīki
• Modelēšanas rīki palīdz pierakstīt un izveidot modeļus, kuri nepieciešami izstrādes gaitā. Parasti tie ir paredzēti veidot modeļus kādā noteiktā valodā(s).
• Var lietot zīmēšanas rīkus (t.i. rīkus, kas ļauj ievadīt patvaļīgu tekstu vai zīmējumu), piemēram, PowerPoint, LibreOffice, Visio, utml. ...– Ar šādiem rīkiem var uzzīmēt jebko – viegli uzzīmēt savu
modeli savā valodā! Kas vēl to sapratīs? – Šādos rīkos ir ierobežotas iespējas pārbaudīt izveidotā
modeļa korektību. Kā noķert kļūdas?
Modelēšanas rīku raksturiezīmes
• Ļauj veidot modeļus tikai noteiktā modelēšanas valodā(s)
• Veic sintakses pareizības pārbaudes• Veic modeļu validāciju• Veic papildus modeļu apstrādi
– Veic modeļu pārveidojumus (transformācijas)– Ģenerē programmatūras koda fragmentus– Veic simulāciju (ja tiek modelēti, piem., biznesa
procesi)
Rīku būve
Domēna specifiskas valodas
• Specifiskos problēmu apgabalos tiek lietotas specializētas modelēšanas valodas - domēna specifiskas valodas (DSL – Domain Specific Language), kuras ir paredzētas kādas konkrētas uzdevumu grupas veikšanai.
DSL aplikāciju būvei telefoniemNokia, Symbian/S60
DSL valodas
• Orientēta uz konkrētu problēmu apgabalu• Lietotāji var operēt ar pazīstamiem jēdzieniem• Var būt gan grafiskas, gan tekstuālas• Programmēšanas, definēšanas, aprakstīšanas
valoda
DSL īpašības
• Lai DSL būt praktiska jēga jābūvē kompilators• No DSL modeļiem var iegūt:
– Kodu, kas integrējams platformā– Izpildāmu aplikāciju,– Testa piemērus,– Dokumentāciju,– ....
Tekstuālu DSL piemēri
• SQL• HTML• UNIX shell scripts• Rīkos Maple un Mathematica lietotās valodas• BNF• ....
SQL
SELECT a1.Name, a1.Sales, SUM(a2.Sales) Running_Total
FROM Total_Sales a1, Total_Sales a2
WHERE a1.Sales <= a2.sales or (a1.Sales=a2.Sales and a1.Name = a2.Name)
GROUP BY a1.Name, a1.Sales
ORDER BY a1.Sales DESC, a1.Name DESC;
HTML<html><body> <p> Each table starts with a table tag. </p> <h4>One column:</h4>
<table border="1"> <tr><td>100</td><td>200</td></tr> <tr><td>300</td><td>400</td></tr><tr><td>500</td><td>600</td></tr>
</table></body> </html>
Grafisku DSL piemēri
• MOLA • WebUML• OpenMusic• Microsoft Visual Programming Language• CODE• DRAKON• webMethods Flow• Labview• ....
OpenMusic
http://recherche.ircam.fr/equipes/repmus/OpenMusic/
MOLA
@tb : Tab (properties){tabKind_="StyleTab"}
@col : GridColumn (properties){title="Background color:"}
@col : GridColumn (properties){title="Line color:"}
@tb : Tab (properties){tabKind_="StyleTab"}
rw el : Row Element (properties)
col : GridColumn (properties)
dgr : AbstractPropertyGrid (properties)
tb : Tab (properties)
{single}cle : ColorEditor (properties)
upd_StyleBackgroundColor(@rw el)
upd_StyleLineColor(@rw el)
column{1}
tab{1}
grid{1}
{ELSE}
{ELSE}
row Element{1}
Microsoft Visual Programming Language
http://msdn2.microsoft.com/en-us/library/bb483088.aspx
CODE
http://www.cs.utexas.edu/users/code/code2.2a3-screenshot.gif
FLOW
http://www1.webmethods.com/images/products/screenshots/wm_ESP_BI_2.jpg
DSL aplikāciju būvei telefoniemNokia, Symbian/S60
User-Interface Designer
User-Interface Designer
WaKe DSML
Izstrādes modelis
Implementācija
DSL atbalsta rīki• Domēna specifisku valodu atbalsta rīku izstrādāšana
ir darbietilpīgs process. • DSL rīku izstrādes procesu var uzlabot, izmantojot
universālas, metamodeļu bāzētas rīku izstrādes platformas.
• Ar šo pieeju vienkāršus DSL rīkus var izveidot ļoti ātri• DSL rīku būves platformas:
– Microsoft DSL Tools– MetaEdit+– Eclipses GMF platforma– GRAF– ...
DSL rīku būves platformas loma
MOLAs rīks
DSL 1 rīks
DSL X rīks
…
Izpildāma transformācija
…
Izpildāma transformācija
Izpildāma transformācija
Rīku būves platforma
Valoda MOLA
DSL 1
DSL X
Programma 1valodā MOLA
Programma 2 valodā MOLA
Programma 3valodā MOLA
Eksperts
Domēna eksperts
Lietotājs
Kā šīs platformas darbojas?
• Tiek definēts domēna modelis• Tiek definēts prezentācijas modelis• Tiek definētas statisks attēlojums starp
prezentācijas un domēna modeļiem• Ģenerējam DSL rīku
Ieguvumi
– Programmēšana izmantojot domēna nevis programmēšanas valodu jēdzienus
– Mazākas izmaksas– Lielāka produktivitāte– Labāka kvalitāte– Elastīgums – var nomainīt ģeneratoru– Īsāks apmācības laiks – mazākas prasības pret
apmācāmajiem– Var mēģināt ieskaidrot klientam, ko modeļi nozīmē
Izmaksas
Demo