4 Managing component interactions

Samankaltaiset tiedostot
4. Komponenttien vuorovaikutus

4. Komponenttien vuorovaikutus

Roolirajapinnat Välittäjät Fasaadit Kutsun siirtäminen Edustajat Takaisinkutsut Tapahtumat Viestit Sovittimet Tehtaat

Ohjelmistoarkkitehtuurit kevät

Ohjelmistoarkkitehtuurit

Ohjelmistoarkkitehtuurit Johannes Koskinen.

Ohjelmistoarkkitehtuurit Kevät 2014

3. Software components and interfaces

7.4 Variability management

7. Product-line architectures

Ohjelmistoarkkitehtuurit Syksy 2009 TTY Ohjelmistotekniikka 1

On instrument costs in decentralized macroeconomic decision making (Helsingin Kauppakorkeakoulun julkaisuja ; D-31)

On instrument costs in decentralized macroeconomic decision making (Helsingin Kauppakorkeakoulun julkaisuja ; D-31)

Kehyspohjainen ohjelmistokehitys

Capacity Utilization

8. Framework architectures

FinFamily PostgreSQL installation ( ) FinFamily PostgreSQL

Microsoft Lync 2010 Attendee

Group 2 - Dentego PTH Korvake. Peer Testing Report

TIEKE Verkottaja Service Tools for electronic data interchange utilizers. Heikki Laaksamo

Automaatiojärjestelmän hankinnassa huomioitavat tietoturva-asiat

2 Description of Software Architectures

3. Komponentit ja rajapinnat

Lab SBS3.FARM_Hyper-V - Navigating a SharePoint site

TIE Ohjelmistojen suunnittelu

Arkkitehtuuritietoisku. eli mitä aina olet halunnut tietää arkkitehtuureista, muttet ole uskaltanut kysyä

1.3 Lohkorakenne muodostetaan käyttämällä a) puolipistettä b) aaltosulkeita c) BEGIN ja END lausekkeita d) sisennystä

Tapahtumapohjainen ohjelmointi. Juha Järvensivu 2007

812336A C++ -kielen perusteet,

Suunnittelumalleja, MVC. Juha Järvensivu 2008

C++11 seminaari, kevät Johannes Koskinen

The CCR Model and Production Correspondence

RINNAKKAINEN OHJELMOINTI A,

Asynkroninen ohjelmointi.net 4.5 versiolla

1.3Lohkorakenne muodostetaan käyttämällä a) puolipistettä b) aaltosulkeita c) BEGIN ja END lausekkeita d) sisennystä

1. SIT. The handler and dog stop with the dog sitting at heel. When the dog is sitting, the handler cues the dog to heel forward.

Salasanan vaihto uuteen / How to change password

Ohjelmistoarkkitehtuurit kevät

Security server v6 installation requirements

Jussi Klemola 3D- KEITTIÖSUUNNITTELUOHJELMAN KÄYTTÖÖNOTTO

SOA SIG SOA Tuotetoimittajan näkökulma

Efficiency change over time

Results on the new polydrug use questions in the Finnish TDI data

Ohjelmointikielet ja -paradigmat 5op. Markus Norrena

21~--~--~r--1~~--~--~~r--1~

Security server v6 installation requirements

Tarua vai totta: sähkön vähittäismarkkina ei toimi? Satu Viljainen Professori, sähkömarkkinat

2_1----~--~r--1.~--~--~--,.~~

Ohjelmistoarkkitehtuurit kevät

Miksi Suomi on Suomi (Finnish Edition)

Komponentit ja rajapinnat

BDD (behavior-driven development) suunnittelumenetelmän käyttö open source projektissa, case: SpecFlow/.NET.

KONEISTUSKOKOONPANON TEKEMINEN NX10-YMPÄRISTÖSSÄ

You can check above like this: Start->Control Panel->Programs->find if Microsoft Lync or Microsoft Lync Attendeed is listed

Olet vastuussa osaamisestasi

3. Komponentit ja rajapinnat

Ohjelmointikielet ja -paradigmat 5op. Markus Norrena

Curriculum. Gym card

Uusi Ajatus Löytyy Luonnosta 4 (käsikirja) (Finnish Edition)

WAMS 2010,Ylivieska Monitoring service of energy efficiency in housing Jan Nyman,

Choose Finland-Helsinki Valitse Finland-Helsinki

anna minun kertoa let me tell you

Windows Phone. Module Descriptions. Opiframe Oy puh Espoo

Tietorakenteet ja algoritmit

Nuku hyvin, pieni susi -????????????,?????????????????. Kaksikielinen satukirja (suomi - venäjä) ( (Finnish Edition)

FinFamily Installation and importing data ( ) FinFamily Asennus / Installation

RAIN RAKENTAMISEN INTEGRAATIOKYVYKKYYS

AYYE 9/ HOUSING POLICY

16. Allocation Models

Network to Get Work. Tehtäviä opiskelijoille Assignments for students.

Voice Over LTE (VoLTE) By Miikka Poikselkä;Harri Holma;Jukka Hongisto

T Software Architecture

11. Kehysarkkitehtuurit

Other approaches to restrict multipliers

National Building Code of Finland, Part D1, Building Water Supply and Sewerage Systems, Regulations and guidelines 2007

Alternative DEA Models

XNA grafiikka laajennus opas. Paavo Räisänen. Tämän oppaan lähdekoodit ovat ladattavissa näiden sivujen Ladattavat osiossa.

Enterprise Architecture TJTSE Yrityksen kokonaisarkkitehtuuri

Encapsulation. Imperative programming abstraction via subprograms Modular programming data abstraction. TTY Ohjelmistotekniikka

Suihkukoneet 1:73 ja pienemmät. Potkurikoneet 1:72-1:49. Suihkukoneet 1:72-1:49. Potkurikoneet 1:35 ja suuremmat. Suihkukoneet 1:35 ja suuremmat

LUONNOS RT EN AGREEMENT ON BUILDING WORKS 1 THE PARTIES. May (10)

Uusi Ajatus Löytyy Luonnosta 3 (Finnish Edition)

REST rajapintana mobiilikehityksessä

JA CHALLENGE Anna-Mari Sopenlehto Central Administration The City Development Group Business Developement and Competence

BLOCKCHAINS AND ODR: SMART CONTRACTS AS AN ALTERNATIVE TO ENFORCEMENT

TIE Ohjelmistojen suunnittelu

Rich Web Applications in Server-side Java without Plug-ins or JavaScript

Making diversity manageable. Miradore. Käytännön kokemuksia rahoituksen hakemisesta. Tiistai Technopolis Vapaudenaukio / Lappeenranta

JAVA-OHJELMOINTI 3 op A274615

Osio 4: Graafinen käyttöliittymä

Web Services tietokantaohjelmoinnin perusteet

Infrastruktuurin asemoituminen kansalliseen ja kansainväliseen kenttään Outi Ala-Honkola Tiedeasiantuntija

Business Opening. Arvoisa Herra Presidentti Very formal, recipient has a special title that must be used in place of their name

Hankkeiden vaikuttavuus: Työkaluja hankesuunnittelun tueksi

HITSAUKSEN TUOTTAVUUSRATKAISUT

On instrument costs in decentralized macroeconomic decision making (Helsingin Kauppakorkeakoulun julkaisuja ; D-31)

Perinteisesti käytettävät tiedon (datan) tyypit

Laiteriippumaton UI Ajaxilla ja Javalla

Innovative and responsible public procurement Urban Agenda kumppanuusryhmä. public-procurement

Mitä mahdollisuuksia tuloksemme tarjoavat museoille?

Transkriptio:

4 Managing component interactions Role interfaces Mediators Forwarding Proxies Callbacks Events Adapters Factories 1

Removing component dependencies with interfaces A B Unknown to A A IB B how what 2

Role-based interfaces Client1 Services Client2 Client1 Server Role1 Server Client2 Role2 3

Example VisualComponent Button EventSource 4

Fine-grained role interfaces Clients X Y Z Roles A B C D Service providers P's interface P Q Q's interface 5

Managing multi-participant interaction with mediators Set of strongly interacting components Problems: interdependencies are unstructured and difficult to understand distributed behavior between several classes cannot be customized without a lot of subclassing participants cannot be used in other contexts 6

Example 7

Mediator Advantages: limits subclassing decouples objects simplifies communication (one-to-many instead of many-to-many) Problem: centralized control (mediator may become monolithic) 8

Coordinator widgetchange(widget) createwidgets() show() Example ListBox ListBoxI getselected(): str Dialog Coordinator TextField TextFieldI settext(str) Widget changed() Button ButtonI enable() 9

Typical interaction ListBox DialogCoordinator TextField Button widgetchange getselected settext enable 10

Forwarding Unknown to A Bimp opimp() imp A call op op() B A call op op() B imp.opimp(); 11

Forwarding: example Chargable discount(int): int CustomerSupport discount(int): int Account Manager Customer KeyCustomer Support 12

Delegation: Implementing inheritance with forwarding "Collective" Car object printdescription self Car parent Vehicle parent Commodity parent printdescription: {printname;... } 13

Delegation: Implementing inheritance with forwarding "Collective" Car object printdescription self Car parent Vehicle parent Product parent Client parent printdescription: {printname;... } 14

Removing component dependencies with proxies Proxy: a component that represents another component in some activity Client op Proxy op Actual 15

Proxy design pattern Client Services request()... actual.request() Proxy request() actual Server 16

Applications distributed systems (e.g. EJB) lazy loading (e.g. object bases) smart pointers... 17

Navigator Example: lazy loading Map getname() getroute(from,to) actual getroute service provided by a Map return mapname; MapProxy map CityMap if not loaded then map = loadfromfile(); loaded = true end; map->getroute() getname getroute getname getroute 18

Removing use dependencies with callbacks Callback A technique to allow a unit that called a service to receive control during the service. Usually the service belongs to a general-purpose library that should be unaware and independent of the applications calling the services of the library. Callback makes it possible to build general-purpose units that are able to call their users without becoming dependent on them. 19

Control visits the called unit during callback library as a sequence diagram: : Library : Application oper1 service call return callback oper2 oper2 return oper1 return application callback 20

Implementing callbacks using inheritance run() Engine EngineUser warn(str) if (oilpressure<limit) { user.warn();... PowerSource start() stop() setuser(engineuser) myeng = new Engine(); myeng.setuser(this); myeng.start(); Car setup() warn(str)... Platform Application log.output("oil pressure low"); myeng.stop(); 21

Käytetään n poikkeuksia? Voidaanko poikkeuksilla saada periaatteessa aikaan sama kuin takaisinkutsuilla? A Ei koskaan B Joskus harvoin C Usein D Aina 22

Poikkeuksilla Engine start() if (oilpressure<limit) {... throw new Oilpressure(); }... PowerSource start() throws Oilpressure stop() setuser(engineuser) setup():... myeng = new Engine(); myeng.setuser(this); try { myeng.start(); } catch (Oilpressure op) {warn("...");} Erot: Edut: Haitat: Car setup() warn(str)... - ei takaisinkutsurajapintaa - käyttävän yksikön (Car) tulee varautua poikkeukseen - yksinkertaisempi - kirjastoyksikön ei tarvitse tietää mitään käyttävän yksikön operaatioista (edes takaisinkutsurajapintaa) - kankeampi: kirjastoyksikkö ei voi jatkaa tapahtuman käsittelyn jälkeen (tässä tosin ei ilmeisesti tarvitsekaan) - yleisesti vaikea erikoistaa tapahtumaan reagointia (ei tosin tässä esimerkissä) Platform Application log.output(str+": Oil pressure low"); myeng.stop(); 23

Removing dependencies with events An event is a state of things that may occur during the execution of the system, has an identifiable representation in the system, needs response from one or more components in the system. 24

From services to events service caller event source service provider event event observers 25

Using events with GUI GUI User actions State changes Application logic 26

Synchronous callback-based based event handling register Event source Observers notify event (callback) 27

Observer design pattern Observer update(event) Source Component obs src Observer Component Source register(observer) unregister(observer) 28

Event handling in Java: Example ActionListener actionperformed(actionevent) JMenuItem obs src AppComp AbstractButton addactionlistener(actionlistener) 29

Removing interface dependencies with adapters service request in interface A Adapter service request Component 1 in interface B Component 2 Adapter: a software unit between the caller and the callee, allowing the caller to be unaware of the interface of the called. 30

Adapter design pattern AbstractServices request() Client ConcreteServices concrequest()... adaptee.concrequest() Adapter request() adaptee Server 31

Example: Sun's BeanBox 32

Using adapters in event-based communication for independent components registering notify event call service Component Adapter Component 33

BeanBox: a closer look generated adapter class: public class Hookup_1734b2d565 implements java.awt.event.actionlistener, java.io.serializable { public void settarget( sunw.demo.juggler.juggler t) { target = t; } public void actionperformed( java.awt.event.actionevent arg0) { target.stopjuggling(); } When mouse click event occurs, activate stopjuggling-operation } private sunw.demo.juggler.juggler target; 34

Managing creation dependencies with factories FactoryRegistry register(factory) AppInit Factory create(): Product AppFactory Platform <<create>> Product service AppProduct 35

Simple version: Factory Method design pattern Product Creator factorymethod anoperation product = factorymethod();... AppProduct create ConcCreator factorymethod return new AppProduct(); 36

Example <<interface>> Document open() close() use Application createdocument() newdocument() opendocument() doc = createdocument(); docs.add(doc); doc.open(); MyDocument open() close() create MyApplication createdocument() return new MyDocument; 37

Problem: How to guarantee consistent object sets? Application OR BUT NOT: 38

ShapeFac Solution: a single factory object for the family of objects factory class TwoDimFac instance of factory object uses Application create instance of ThreeDimFac factory class 39

Abstract Factory design pattern: Example AbsFactory createbutton(): Button createmenu(): Menu Application WinFactory Button Menu <<create>> WinButton WinMenu 40