Software Architecture in Practice Exercise H1 Architectural Description TM16
Provided: TM16 report template TM16 source code LaTeX Java Ant build mgt. system Ivy dep. mgt. system Review the README Try it out – ’ant help’ Inspect source code H B Christensen
Case - Challenges (Our research: www.net4care.org) Demographic challenges 2009: 70% of public health expenditure goes to chronic diseases 2040: 100% more elderly Geographical challenges Larger, fewer hospitals Fewer general practitioners Leads to a need for telemedical solutions ICT-supported healthcare services where some of the people participating in service delivery are not co-located with the receiver of the service (Our research: www.net4care.org) H B Christensen
Vision Vision Motivation Replace out-patient visits by measurements made by patients in their home Move data from home to regional/national storage so all health care personal can view them... Motivation Reduce out-patient visits Better quality of life Cost savings Better traceability and visibility H B Christensen
Use case 1 2) BP measurement stored as HL7 document 1) Inger measures her BP using her TM16 terminal H B Christensen
Use case 2 2) Query for all BP documents associated with Inger 1) GP queries last month’s BP measurements for Inger using web browser H B Christensen
(What is XDS) Cross-Enterprise Document Sharing Think One Registry + Multiple Repositories Repository: Stores clinical documents (id,document) pairs Registry: Stores metadata with document id Metadata (cpr, timeinterval, physician, measurement type,...) Id of associate document and its repository Think Registry = Google (index but no data) Repository = Webserver (data but no index) H B Christensen
(What is HL7) HL7 is a standard (complex!) for clinical information storage and exchange. Version 3 loves XML! Our version: Real version: H B Christensen
Demo Start a server Send an obs. GP review in browser ant server ant home GP review in browser http://localhost:4567/bp/pid01 Use case 1 Use case 2
Henrik Bærbak Christensen Demo 2 ifconfig eth0 Can talk remotely Fire up a new machine, note its IP ant home –Dhost=192.168.237.135 CS@AU Henrik Bærbak Christensen
Skeletal system TM16.zip Tool chain - choose: Download and unzip Now you can read Get tool chain Now you can execute Tool chain - choose: VM path: Get the fully working virtual machine Manual path: Install all tools on your local machine Ensure they are correctly installed View the Tools web page... H B Christensen
Henrik Bærbak Christensen Getting Started I actually recommend using the VM In particular if you are not core Java developer Docker is bit tricky on Mac and Win machines Getting TM16 up and running Review the screencasts, links on weekplan! CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Tool chain Java programming language Lots of tutorials on the web, use them Ant build management Probably you do not need to change it ‘ant server’, ‘ant home’, … Ivy dependency management Automatically download all dependencies Review the screencasts on the weekplan CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen IDE I stick to Eclipse even though many say IntelliJ is better Review screencasts on weekplan Importing TM16 + Updating once dependencies are changed Please, adhere to this rule Source files encoded in UTF-8 (not default on Windows!) Indent using spaces! Preferences -> java -> code style -> formatter Create new profile Pane ‘indentation’ CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Code structure Baerbak projects src = Production code test = Junit test code Run tests Right click ‘test’ package Run As -> JUnit Test Screencast ‘import into eclipse’ CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Dependency Injection I have written a book on Flexibility Program to interface Role is expressed by interface Favour Object Composition Small services collaborate to form whole Dependency injection The services you collaborate with are provided to you (injected) CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Example TeleMed : Role of a tele medicine system/server XDSBackend: Role of an XDS database system Xds is injected into the telemed I can configure any suitable variant of the system by selecting the right implementations of roles to inject! CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Test Doubles I have written a book on Reliability Test Doubles Replacements for real ‘depended-on units’ that are under test control Test cases in JUnit Inject test doubles instead of ‘real’ units to ease and control testing CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Example XDSBackend: Role of an XDS database system FakeObjectXDSDatabase: A fake test double No persistence, all in-memory! I can test TeleMed code without starting a real XDS database server; it is much faster and initial state is well-defined = empty database CS@AU Henrik Bærbak Christensen
TM16 served another purpose Broker TM16 served another purpose
Distributed Computing I am writing the 2nd edition of my book on Distributed Computing Broker pattern ? CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen FRS 2nd Edition Broker CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Broker Example TeleMed implementation is on machine ‘server’ On client we want to call teleMed.processAndStore( myBloodPressure ); But networks only have send(address, byte[]); Byte[] receive(); CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Client Side Broker Broker dynamics on Client side ClientProxy: Implements TeleMed interface Convert every call into requests to the Requestor Requestor: Does marshaling = convert data to byte array format Typically JSON or XML ClientRequestHandler Binds to the OS and particular network protocol Sockets, HTTP, Messaging Does the ‘send(payload) and blocks until answer returned CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Server Side Broker Broker dynamics on Server side ServerRequestHandler: Binds to the OS and network protocol Receives payload from ClientRequestHandler Invoker: Demarshals byte[] into parameters Dispatches to proper method and proper servant object Servant: Implements TeleMed interface The real implementation! CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Why all the trouble? Now we can configure our own Broker system A HTTP based client And HTTP webserver based server See the TM16 code for a socket based variant CS@AU Henrik Bærbak Christensen
Unit Testing Distribution! Why code the broker myself? One big advantage: Test doubles Now single VM system! CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Remember: Roles They are all roles One object may play several In REST and HTTP you often merge e.g. ServerRequestHandler and Invoker Because typically you use HTTP verbs, GET, POST, PUT, = operation names Routes /bp/pid01 = object identifiers Thus embody responsibilities from both roles… CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen In TM16 In the documentation exercise next (H1) do not spend an awful lot of energy on the Broker part Early release of my book chapters are on the course web page CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Exercise H1 CS@AU Henrik Bærbak Christensen
Exercise H1 Document the Module viewpoint C&C viewpoint Rather mechanically Find packages and classes But what to abstract and what not? Hint: Broker is detailed elsewhere C&C viewpoint What does it do? Deployment viewpoint The ’real’ production deployment The +1 Architectural significant scenarios H B Christensen
Digging in... Where to start? Learning tests! Manual tests! Lots of code, many variants Learning tests! TestScenario.java Manual tests! Review build.xml H B Christensen
Important TM16 is somewhat large ! Beware: Discuss, ask questions Much code is not really architectural! Do not dispair but keep me informed!!! Use the web forum Discuss, ask questions H B Christensen