Upload
dinhdan
View
213
Download
0
Embed Size (px)
Citation preview
Building modern enterprise applications
from scratch: lessons learned
DOAG 2014 – Dr. Clemens Wrzodek
@wrzodek
Roche Group – Penzberg
• Founded 1896 in Basel, Switzerland
• Employing > 82,000 people
• Clear focus on healthcare
• Pharma Research and Early Development (pRED) Informatics
• Provide informatic and bioinformatic services and tools to researchers
Focus of this talk
Architecture
• Traditional
• Revised
Web UI
• Server-side
• Client-side
Backend
• Interfaces
• Integration
Great! A new project!
Let’s setup the architecture.
DB Middle tier WebUI
This talk will focus on Java for
the middle tier and Oracle as
database.
Let’s implement things!
DB Middle tier WebUI JPA
Technology choices have been similar to this for many years.
Why has it developed like this?
DB Middle tier WebUI
• Our enterprise web servers are application platforms
• Requirements:
– Interactivity with users
– Dynamic content
– MVC on server-side
• Client flow is determined and given by server, which holds sessions
JavaEE Developer
Why has it developed like this?
DB Middle tier WebUI
• Our enterprise web servers are application platforms
• Requirements:
– Interactivity with users
– Dynamic content
– MVC on server-side
• Client flow is determined and given by server, which holds sessions
• Browser is used as “dumb” terminal
Let’s look aside!
DB Middle tier WebUI
• What about the big tech-companies?
– Platforms provide services
– Services are separated from applications
– Web 2.0:
• Maps
• …
Service layer
Application layer
Use Oracle
functionality
Takes care of
integrity
Provide
resources,
independent
of workflow
Processing
unit
Application
flow
MVC
Let’s think again!
Frontend architecture:
SOFEA – service oriented frontend
architecture
DB Middle tier WebUI
Database architecture similar to frontend?
Frontend technologies
Architecture
• Traditional
• Revised
Web UI
• Server-side
• Client-side
Backend
• Interfaces
• Integration
Conclusion Client-side Server-side
Frontend technologies
• APEX
• JSF / JSP
• GWT
• HTML5 / JavaScript
– Plain + JQuery
– Angular
– Ember
– …
WebUI: Overview
Conclusion Client-side
Frontend technologies
• APEX
• JSF / JSP
• GWT
• HTML5 / JavaScript
– Plain + JQuery
– Angular
– Ember
– …
Availability of JavaScript Frameworks
comparable to situation with Java ~2006.
Server-side WebUI: Overview
Conclusion Client-side
Frontend technologies Server-side examples
• Server-side solutions
– Integrated development of WebUI and middle tier
– Server-side MVC
• Application runs on the server
• Need more bandwidth and server memory (stateful)
– Example: APEX
• PL/SQL (JavaScript)
• Smaller projects with focus on reporting and grid-editing
• Rapid application development
– Example: JSF
• Established and stable
• Usually, heavily coupled to the Backend Java code
Server-side WebUI: Overview
Frontend technologies Client-side examples
• Client-side solutions
– Application runs in the browser
– Client-side MVC
– Consumes services from servers
– Stateful Client – Stateless Server
– Example: Google Web Toolkit (GWT)
• Java to JavaScript translator by Google, now open-source
• Easy to start for Java Developers
• Eclipse as IDE, Java Code with all it‘s advantages for large teams
• Many DOM Elements, not really lightweight
Conclusion Client-side Server-side WebUI: Overview
Conclusion Client-side
Frontend technologies
Client-side examples
• Example: JavaScript
– Yes, it is mature!
• Package management: npm
• Build tool: grunt
• Dependency management: Bower/requireJS
• IDE: WebStorm/Eclipse
• Testing: Jasmin/Karma/Protractor
– UI-Widgets:
• Bootstrap (Alternatives: MaterialDesign, Foundation, Pure, …)
– Frameworks
• AngularJS
• Ember
Server-side WebUI: Overview
Conclusion and remarks
• SOFEA is not a fat-client architecture
• No session timeouts
• No session clustering/replication More lightweight app servers
• Quicker client-side modifications and re-deployments
• High responsiveness and enhanced user-experience
• Why keeping the view and app flow on the server?
• Why having this many workarounds?
Conclusion Client-side Server-side WebUI: Overview
Ready for the lessons-learned
Architecture
• Traditional
• Revised
Web UI
• Server-side
• Client-side
Backend
• Interfaces
• Integration
Lessons-learned
1. Know your team! Choose according to available knowledge.
– Don’t underestimate the “coolness” of new technologies.
Lessons-learned
1. Know your team! Choose according to available knowledge.
– Don’t underestimate the “coolness” of new technologies.
2. Choose according to project complexity.
Lessons-learned
1. Know your team! Choose according to available knowledge.
– Don’t underestimate the “coolness” of new technologies.
2. Choose according to project complexity.
3. New technology vs. workarounds for existing technology
Lessons-learned
1. Know your team! Choose according to available knowledge.
– Don’t underestimate the “coolness” of new technologies.
2. Choose according to project complexity.
3. New technology vs. workarounds for existing technology
4. Be professional! Also in UI code development!
Backend technologies
Architecture
• Traditional
• Revised
Web UI
• Server-side
• Client-side
Backend
• Interfaces
• Integration
Middle tier – WebUI interfaces
DB Middle tier WebUI
vs.
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – WebUI interfaces SOAP vs. REST
SOAP • Simple object access protocol
• XML
• Requires dedicated protocol
implementation on client-side
• Needs some time…
• Secure +++
• Stateful
• Service oriented (getStockPrice)
REST • Representational state transfer
• JSON
• Describes the web-architecture
(“It’s the internet”)
• Easy to implement
• Secure ++
• Stateless
• Resource oriented (/stock)
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – WebUI interfaces Digression: best-practice for REST API design
• http://www.example.com/api/1.1/cars
• HTTP methods for CRUD
• Querystring for filtering, sorting, paging
/cars/?doors=4
• HTTP Response codes (200 OK, 404 Not found, 405 Not allowed)
vs. JSON object with status
HTTP Command Operation
GET Get
POST Create new
PUT Update existing
DELETE Delete
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
DB Middle tier WebUI
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
• DirectSQL
– Quick’n dirty
– Unsecure
• Object-relational mapping (ORM)
– Very popular (JPA, Hibernate)
– Quick and easy, once it is setup
– Mostly uses database just for persistence
• PL/SQL API
– Java and PL/SQL share objects, Java calls PL/SQL API
– Business logic also in PL/SQL
– Recommended for complex inserts
– Allows using full oracle DB feature set
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
• Roche pharma research
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
• Roche pharma research
• Treatments for cancer
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
• Roche pharma research
• Treatments for cancer
• Cancer is due to proliferating cells
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
• Roche pharma research
• Treatments for cancer
• Cancer is due to proliferating cells
• Antibodies can be used to “kill” cancer cells
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
• Roche pharma research
• Treatments for cancer
• Cancer is due to proliferating cells
• Antibodies can be used to “kill” cancer cells
• Screening for antibodies results in many variants
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
• Roche pharma research
• Treatments for cancer
• Cancer is due to proliferating cells
• Antibodies can be used to “kill” cancer cells
• Screening for antibodies results in many variants
– Has one of these variants already been tested?
– Do we already know properties of one of these variants?
Antibody registration on molecular level.
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
1. Check uniqueness
– Sequences
– Connections
– Properties
2. Register
– Sequences
– Connections
– Properties
– Domains
– Mutations
– …
CH 2
C
H 3
CH2
CH3
-S-S-
-S-S-
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
CH 2
C
H 3
CH2
CH3
-S-S-
-S-S- Decompose
CH 2
C
H 3
CH2
CH3
Domains
based on similarity
to other
sequences
-S-S-
-S-S-
-S-S-
-S-S-
Continuous integration Use case DB interface Backend: WebUI interface
Middle tier – database interfaces
Reasoning for PL/SQL API: A use-case
• Oracle Cartridge API for DNA sequence search
• Accelrys Cartridge for Chemistry searches
• Transaction with inserts / updates into 11 tables
PL/SQL code for
– utilizing Oracle features
– ensuring integrity
– Performance
Java code to simply INSERT or UPDATE Antibody-object
Continuous integration Use case DB interface Backend: WebUI interface
Continous integration / delivery
DB WebUI Middle tier
Continuous integration Use case DB interface Backend: WebUI interface
Continous integration / delivery
• Continous integration
– Write Unit tests
– Test PL/SQL Packages from JUnit, if no other means available
– Integration tests
• Continous delivery / Continous deployment
– Configure build server to deploy on DEV after tests succeed
– UI developers benefit from an always up-to-date backend
Code Commit Unit test Integrate Deploy
Application layer
Service layer
Continuous integration Use case DB interface Backend: WebUI interface
Ready for the lessons-learned
Architecture
• Traditional
• Revised
Web UI
• Server-side
• Client-side
Backend
• Interfaces
• Integration
Lessons-learned
1. Clear API design!
– Decouple UI / Backend, Document API (swagger, enunciate)
2. Use provided oracle features. Don’t implement DB methods in Java.
https://blogs.oracle.com/imc/entry/oracle_database_12c_free_new
Lessons-learned
1. Clear API design!
– Decouple UI / Backend, Document API (swagger, enunciate)
2. Use provided oracle features. Don’t implement DB methods in Java.
3. Organize and plan your code well!
– Refactor is a must in agile setups, define rules and structure
Code
Test
Integrate
Refactor
Lessons-learned
1. Clear API design!
– Decouple UI / Backend, Document API (swagger, enunciate)
2. Use provided oracle features. Don’t implement DB methods in Java.
3. Organize and plan your code well!
– Refactor is a must in agile setups, define rules and structure
4. Jersey != RESTeasy. Start with final setup!
Lessons-learned
1. Clear API design!
– Decouple UI / Backend, Document API (swagger, enunciate)
2. Use provided oracle features. Don’t implement DB methods in Java.
3. Organize and plan your code well!
– Refactor is a must in agile setups, define rules and structure
4. Jersey != RESTeasy. Start with final setup!
5. Unit test ALL code – UI, Middle tier, PL/SQL use CI/CD
PL/SQL API
Oracle
cartridge
REST
PL/SQL
Interface
Bootstrap
Angular
DB Middle tier WebUI
Conlusion Choices for our project
PL/SQL API
Oracle
cartridge
REST
PL/SQL
Interface
Bootstrap
Angular
DB Middle tier WebUI Thank you very much for
your attention!