SlideShare une entreprise Scribd logo
1  sur  35
Architecture of eSobi club
based on J2EE
Allan Huang @ eSobi Inc.
Agenda





Software Layers for J2EE Application
Table Schema structure and Domain Object
design
Look from Top-Down, Carry out from BottomUp
Software Layers for J2EE Application

Business Delegate Layer

Deployment Layer
Business Tier
Business Logic Layer
(Business Object)

Integration Tier
Data Access Object Layer

Architecture Component Layer
(Framework)

Domain Object Layer
(Domain Model / Entity)

Presentation Layer
(Servlet / JSP)
Presentation Tier
Architecture Component Layer





Generic application utilities
Often, these objects are good candidates for
enterprise-wide use
Well-known open source projects


Jakarta commons, dom4j, log4j, xerces, quartz,
java mail, jasypt, captcha …
Domain Object Layer




Lightweight structures for related business
information
Enterprise Java Bean




BMP Entity Bean (EJB1.0)
CMP Entity Bean (EJB2.0)
POJO (EJB3.0)
Ratings of Data Persistence Methods
Goal

JDBC

EJB/BMP EJB/CMP

JDO

O/R Tool

Min Learning curve

High

Low

Low

Medium

Medium

Min Code and
configuration

Low

Low

Low

Medium

Medium

Max Ability to tune

High

Medium

Low

Low

Low

Min Deployment effort

High

Low

Low

Medium

Medium

Max Code portability

Medium

Medium

High

High

High

Min Vendor reliance

High

Medium

Medium

Medium

Low

Max Availability and
fail-over

Low

High

High

Low

Low

Manageable via JTA

Yes

Yes

Yes

Yes

Yes
Data Access Object Layer


Encapsulate data access and manipulation in
a separate layer





DB CRUD, File, XML, FTP Server, Mail Server ...

1:1 correspondence between VO and DAO
Traditional JDBC DAO vs. Spring DAO Bean


Aspect-oriented programming (AOP)




Cross-cutting concerns

Inverse of Control (IOC)
Business Logic Layer







Manages business processing rules and logic
Maximize the possibility of reuse
Access Business Objects (BO) via Service Locator
(Pattern)
Stateless Session Bean vs. Spring Bean
Fast Lane Reader (Pattern)




A more efficient way to access tabular, read-only,
potentially stale data

Transfer Object (Pattern)



Carry any multiple data elements across a tier
Previously known as Value Object (is not Pattern) ?
Deployment Layer





Publishes business object capabilities
Web Server (e.g. Tomcat) acted business
client, Application Server (e.g. Weblogic)
acted business server
Remote session bean, Message-driven bean,
RMI service, Web service, CORBA service ...
Features of Deployment Wrapper Types
Feature

EJB

Web
Service

JMS

RMI

HTTP

CORBA

Caller platform
requirements

Javacomplaint only

Any

Any

Javacomplaint only

Any

Any

Communication
method
supported

Synch. only

Both

Both

Synch. only

Synch.
only

Synch.
only

Tight

Loose

Loose

Tight

Loose

Loose

Local and JTA

Local and JTA

Local

Local

Local

Local

Requires J2EE
container?

Yes

No

No

No

No

No

Supports
clustering for
scalability and
availability?

Yes

Yes

Yes

No

Yes

Yes

Coupling
Transaction
support
Business Delegate Layer




Hide clients from the complexity of remote
communication with business service
components
Service Locator (Singleton)




Transparently locate business components and
services in a uniform manner

Class BeanFactoryLocator or
ApplicationContext of Spring Context
Presentation Layer






Controls display to the end user
Servlet 2.4 & JSP 2.0
Servlet & Java Bean (View Object)
JSP & Tag library
JavaScript & DHTML & CSS


Asynchronous JavaScript And XML (AJAX)
AJAX










Only reload some part and difference of web
page each time the user requests a change
A implementation of design style, not a
framework
Consists of HTML, JavaScript, DHTML, and
DOM, is an outstanding approach
Help you to transform clunky Web interfaces
into interactive AJAX applications
AJAX Web or AJAX Application ?
Table Schema structure and Domain
Object design
User-centric Tables & Classes



ER Diagram
Class Diagram


Table per subclass







User, Supervisor, Member
MemberFeed, SubscribeFeed, FavoriteFeed,
RecommendFeed, BackupFeed

1:1 Lazy initialization between Member and
MemberProfile
Nested MemberFolder



Tree structure
4 default folders per member
Feed-centric Tables & Classes



ER Diagram
Class Diagram
 Nested FeedCategory




Nested RecommendReply









Tree structure
While malicious of Reply == true, this reply would be removed from
user’s view

FeedRecommend




Tree structure

While malicious of Recommend == true, this reply would be removed
from user’s view

FeedTagCase between PublicFeed and FeedTag
FeedVote between PublicFeed and User
RecommendVote between FeedRecommend and User
M:M between FeedTag and FeedRecommend
Mail-centric Tables & Classes



ER Diagram
Class Diagram


OutMail & InMail






While trashed of OutMail == true, this mail would be
removed from sender’s view
While trashed of InMail == true, this mail would be
removed from receiver’s view
While one trashed of OutMail == true and trashed of it’s
InMails == true simultaneously, these mails will be
deleted from database
My Space-centric Tables & Classes



ER Diagram
Class Diagram






MySpaceSetting between MySpace and
MySpaceChoice
MySpaceAnswer between MySpace and
MySpaceQuestion
1:1 Lazy initialization between MemberProfile and
MySpace
Access Control-centric Tables & Classes



ER Diagram
Class Diagram


Table per class hierarchy





Nested Group






AccessControl, UserControl, RoleControl, GroupControl
AccessRule, SupervisorRule, MemberRule
Tree structure

M:M between Role and User
M:M between Group and User
Access Rule



Priority UserControl > RoleControl > GroupControl
Resolves conflicts when the same type of AccessControl are
assigned
Forum-centric Tables & Classes



ER Diagram
Class Diagram


Nested TopicReply





Tree structure
While malicious of Reply == true, this reply would be
removed from user’s view

Topic Watch



Update last replied time when user replies
Between User and ForumTopic
Look from Top-Down, Carry out from
Bottom-Up
Ready for APIs & Components I


User Authenticator


Related Tables & Classes







User-centric

Login & Logout
Cookie mechanics
Password Digester
Random 12-characters Password Generator
Ready for APIs & Components II


eSobi Feed Subscriber


Related Tables & Classes







User-centric
Feed-centric

Public Feed count & Member Feed record

eSobi Feed Recommender


Related Tables & Classes



User-centric
Feed-centric
Ready for APIs & Components III


eSobi Folder Backup


Related Tables & Classes





User-centric
Feed-centric

eSobi Folder Restorer


Related Tables & Classes



User-centric
Feed-centric
Ongoing for APIs & Components I


Data Migration




Data List Handler





Parse RSS XML to find information of feed

User Authorizer




A pattern for Large Search Result Sets
Paging Controller applied to web page

RSS Parser




Old data is migrated to the new schema

According to Access-Controls to find Access-Rules

Mail Carrier
Java Naming Convention







According to Java Bean convention
Attribute firstly, Getter method secondly,
Setter method lastly
Collection-type Attribute, add extra Adder and
Remover method
Convenient findXXXByZZZ method
SQL Syntax Convention


Statement





Spells SQL keywords in upper case
SQL statements are often broken into multiple
lines

Table & Column name




Primary key should be the table name suffixed
with "_id“
Separate words and prefixes with underlines,
never use spaces
Logging Service Convention








Replace System.out / System.err println with
Logger
Level warning & error & fatal on Production
machine
Level trace & debug & info on SIT / UAT
machine
Logging necessary messages about our
logic.


if log.isXXXEnabled, then log.XXX message
Centralized Controlling & Distributed
Computing


There’s no need to reinvent the wheel




Bitter design vs. Appropriate design




Tree traverse method

Universal entry between up-tier and down-tier




J2EE Pattern & GoF Pattern

Hard code vs. Sophisticated Algorithm




Open Source Community

e.g. Service Locator & Session Façade

Divide and conquer inside the same tier
Concurrent Access Risk




Deadlock while insert & update concurrently
Dirty columns of table for performance gain
AJAX seems delicious, but ...
Performance Issue & Tuning


High availability & High scalability





Clustering & Load Balancing
Fail Over & Session Persistence

Code Refactoring




SQL statement (DAO) Tuning
Business Logic (BO) Tuning
Cached Result Page





Event-Driven: JMS (Synchronous)
Scheduling: Quartz (Asynchronous)

Database Refactoring




Re-Index on Tables
Database Trigger
Database Stored Procedure
Test-driven development


Planning







Release planning creates the schedule
Make frequent small releases
The project is divided into iterations
Iteration planning starts each iteration

Designing




Simplicity
Choose a system metaphor
Refactoring whenever and wherever possible
Test-driven development


Coding







Code must be written to agreed standards
Integrate often
Use collective code ownership
Leave optimization till last

Testing





All code must have unit tests
All code must pass all unit tests before release
When a bug is found tests are created
Acceptance tests are run often
Reference









Core J2EE Patterns
J2EE Patterns Catalog
GoF Patterns
AJAX Patterns
Java Naming Convention
Essential Database Naming Conventions
SQL Syntax Conventions
Extreme Programming
Q&A

Contenu connexe

Tendances

IBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons LearnedIBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons Learned
Ted Leung
 
Best PeoplSoft Technical Online Training
Best PeoplSoft Technical Online TrainingBest PeoplSoft Technical Online Training
Best PeoplSoft Technical Online Training
Samatha Kamuni
 
01 Persistence And Orm
01 Persistence And Orm01 Persistence And Orm
01 Persistence And Orm
Ranjan Kumar
 

Tendances (20)

ky_resume
ky_resumeky_resume
ky_resume
 
Ejb intro
Ejb introEjb intro
Ejb intro
 
Mcv design patterns
Mcv design patternsMcv design patterns
Mcv design patterns
 
IBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons LearnedIBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons Learned
 
Oracle Framework Personalization
Oracle Framework PersonalizationOracle Framework Personalization
Oracle Framework Personalization
 
Java EE EJB Applications
Java EE EJB ApplicationsJava EE EJB Applications
Java EE EJB Applications
 
WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)
 
Best PeoplSoft Technical Online Training
Best PeoplSoft Technical Online TrainingBest PeoplSoft Technical Online Training
Best PeoplSoft Technical Online Training
 
L10 Web Programming
L10 Web ProgrammingL10 Web Programming
L10 Web Programming
 
Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
Unit i
Unit iUnit i
Unit i
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
 
01 Persistence And Orm
01 Persistence And Orm01 Persistence And Orm
01 Persistence And Orm
 
Oracle ADF 11g Tutorial
Oracle ADF 11g TutorialOracle ADF 11g Tutorial
Oracle ADF 11g Tutorial
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in java
 
Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
 
Java bean
Java beanJava bean
Java bean
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
 
Unit 3 WEB TECHNOLOGIES
Unit 3 WEB TECHNOLOGIES Unit 3 WEB TECHNOLOGIES
Unit 3 WEB TECHNOLOGIES
 

Similaire à Architecture of eSobi club based on J2EE

Data Access Tech Ed India
Data Access   Tech Ed IndiaData Access   Tech Ed India
Data Access Tech Ed India
rsnarayanan
 
Jdbc Lecture5
Jdbc Lecture5Jdbc Lecture5
Jdbc Lecture5
phanleson
 
Real world java_ee_patterns
Real world java_ee_patternsReal world java_ee_patterns
Real world java_ee_patterns
Alassane Diallo
 
RailsConf 2010: From 1 to 30 - How to refactor one monolithic application int...
RailsConf 2010: From 1 to 30 - How to refactor one monolithic application int...RailsConf 2010: From 1 to 30 - How to refactor one monolithic application int...
RailsConf 2010: From 1 to 30 - How to refactor one monolithic application int...
jpalley
 
J2 EEE SIDES
J2 EEE  SIDESJ2 EEE  SIDES
J2 EEE SIDES
bputhal
 
Dh2 Apps Training Part2
Dh2   Apps Training Part2Dh2   Apps Training Part2
Dh2 Apps Training Part2
jamram82
 

Similaire à Architecture of eSobi club based on J2EE (20)

Dev381.Pp
Dev381.PpDev381.Pp
Dev381.Pp
 
Data Access Tech Ed India
Data Access   Tech Ed IndiaData Access   Tech Ed India
Data Access Tech Ed India
 
Day5
Day5Day5
Day5
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
 
Jdbc Lecture5
Jdbc Lecture5Jdbc Lecture5
Jdbc Lecture5
 
Adaptive Architecture
Adaptive ArchitectureAdaptive Architecture
Adaptive Architecture
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Real world java_ee_patterns
Real world java_ee_patternsReal world java_ee_patterns
Real world java_ee_patterns
 
RailsConf 2010: From 1 to 30 - How to refactor one monolithic application int...
RailsConf 2010: From 1 to 30 - How to refactor one monolithic application int...RailsConf 2010: From 1 to 30 - How to refactor one monolithic application int...
RailsConf 2010: From 1 to 30 - How to refactor one monolithic application int...
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014
 
J2 EEE SIDES
J2 EEE  SIDESJ2 EEE  SIDES
J2 EEE SIDES
 
Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0
 
Overview of atg framework
Overview of atg frameworkOverview of atg framework
Overview of atg framework
 
Innovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC IntegrationsInnovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC Integrations
 
Dh2 Apps Training Part2
Dh2   Apps Training Part2Dh2   Apps Training Part2
Dh2 Apps Training Part2
 
Jboss
JbossJboss
Jboss
 
Crafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoCrafted Design - Sandro Mancuso
Crafted Design - Sandro Mancuso
 
J2EE Batch Processing
J2EE Batch ProcessingJ2EE Batch Processing
J2EE Batch Processing
 

Plus de Allan Huang

Plus de Allan Huang (20)

Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in Java
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test tools
 
Drools
DroolsDrools
Drools
 
Java JSON Parser Comparison
Java JSON Parser ComparisonJava JSON Parser Comparison
Java JSON Parser Comparison
 
Netty 4-based RPC System Development
Netty 4-based RPC System DevelopmentNetty 4-based RPC System Development
Netty 4-based RPC System Development
 
eSobi Website Multilayered Architecture
eSobi Website Multilayered ArchitectureeSobi Website Multilayered Architecture
eSobi Website Multilayered Architecture
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
 
Tomcat New Evolution
Tomcat New EvolutionTomcat New Evolution
Tomcat New Evolution
 
JQuery New Evolution
JQuery New EvolutionJQuery New Evolution
JQuery New Evolution
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
 
Boilerpipe Integration And Improvement
Boilerpipe Integration And ImprovementBoilerpipe Integration And Improvement
Boilerpipe Integration And Improvement
 
YQL Case Study
YQL Case StudyYQL Case Study
YQL Case Study
 
Build Cross-Platform Mobile Application with PhoneGap
Build Cross-Platform Mobile Application with PhoneGapBuild Cross-Platform Mobile Application with PhoneGap
Build Cross-Platform Mobile Application with PhoneGap
 
HTML5 Multithreading
HTML5 MultithreadingHTML5 Multithreading
HTML5 Multithreading
 
HTML5 Offline Web Application
HTML5 Offline Web ApplicationHTML5 Offline Web Application
HTML5 Offline Web Application
 
HTML5 Data Storage
HTML5 Data StorageHTML5 Data Storage
HTML5 Data Storage
 
Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script Patterns
 
Weighted feed recommand
Weighted feed recommandWeighted feed recommand
Weighted feed recommand
 
Web Crawler
Web CrawlerWeb Crawler
Web Crawler
 
eSobi Site Initiation
eSobi Site InitiationeSobi Site Initiation
eSobi Site Initiation
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Architecture of eSobi club based on J2EE

  • 1. Architecture of eSobi club based on J2EE Allan Huang @ eSobi Inc.
  • 2. Agenda    Software Layers for J2EE Application Table Schema structure and Domain Object design Look from Top-Down, Carry out from BottomUp
  • 3. Software Layers for J2EE Application Business Delegate Layer Deployment Layer Business Tier Business Logic Layer (Business Object) Integration Tier Data Access Object Layer Architecture Component Layer (Framework) Domain Object Layer (Domain Model / Entity) Presentation Layer (Servlet / JSP) Presentation Tier
  • 4. Architecture Component Layer    Generic application utilities Often, these objects are good candidates for enterprise-wide use Well-known open source projects  Jakarta commons, dom4j, log4j, xerces, quartz, java mail, jasypt, captcha …
  • 5. Domain Object Layer   Lightweight structures for related business information Enterprise Java Bean    BMP Entity Bean (EJB1.0) CMP Entity Bean (EJB2.0) POJO (EJB3.0)
  • 6. Ratings of Data Persistence Methods Goal JDBC EJB/BMP EJB/CMP JDO O/R Tool Min Learning curve High Low Low Medium Medium Min Code and configuration Low Low Low Medium Medium Max Ability to tune High Medium Low Low Low Min Deployment effort High Low Low Medium Medium Max Code portability Medium Medium High High High Min Vendor reliance High Medium Medium Medium Low Max Availability and fail-over Low High High Low Low Manageable via JTA Yes Yes Yes Yes Yes
  • 7. Data Access Object Layer  Encapsulate data access and manipulation in a separate layer    DB CRUD, File, XML, FTP Server, Mail Server ... 1:1 correspondence between VO and DAO Traditional JDBC DAO vs. Spring DAO Bean  Aspect-oriented programming (AOP)   Cross-cutting concerns Inverse of Control (IOC)
  • 8. Business Logic Layer      Manages business processing rules and logic Maximize the possibility of reuse Access Business Objects (BO) via Service Locator (Pattern) Stateless Session Bean vs. Spring Bean Fast Lane Reader (Pattern)   A more efficient way to access tabular, read-only, potentially stale data Transfer Object (Pattern)   Carry any multiple data elements across a tier Previously known as Value Object (is not Pattern) ?
  • 9. Deployment Layer    Publishes business object capabilities Web Server (e.g. Tomcat) acted business client, Application Server (e.g. Weblogic) acted business server Remote session bean, Message-driven bean, RMI service, Web service, CORBA service ...
  • 10. Features of Deployment Wrapper Types Feature EJB Web Service JMS RMI HTTP CORBA Caller platform requirements Javacomplaint only Any Any Javacomplaint only Any Any Communication method supported Synch. only Both Both Synch. only Synch. only Synch. only Tight Loose Loose Tight Loose Loose Local and JTA Local and JTA Local Local Local Local Requires J2EE container? Yes No No No No No Supports clustering for scalability and availability? Yes Yes Yes No Yes Yes Coupling Transaction support
  • 11. Business Delegate Layer   Hide clients from the complexity of remote communication with business service components Service Locator (Singleton)   Transparently locate business components and services in a uniform manner Class BeanFactoryLocator or ApplicationContext of Spring Context
  • 12. Presentation Layer      Controls display to the end user Servlet 2.4 & JSP 2.0 Servlet & Java Bean (View Object) JSP & Tag library JavaScript & DHTML & CSS  Asynchronous JavaScript And XML (AJAX)
  • 13. AJAX      Only reload some part and difference of web page each time the user requests a change A implementation of design style, not a framework Consists of HTML, JavaScript, DHTML, and DOM, is an outstanding approach Help you to transform clunky Web interfaces into interactive AJAX applications AJAX Web or AJAX Application ?
  • 14. Table Schema structure and Domain Object design
  • 15. User-centric Tables & Classes   ER Diagram Class Diagram  Table per subclass     User, Supervisor, Member MemberFeed, SubscribeFeed, FavoriteFeed, RecommendFeed, BackupFeed 1:1 Lazy initialization between Member and MemberProfile Nested MemberFolder   Tree structure 4 default folders per member
  • 16. Feed-centric Tables & Classes   ER Diagram Class Diagram  Nested FeedCategory   Nested RecommendReply       Tree structure While malicious of Reply == true, this reply would be removed from user’s view FeedRecommend   Tree structure While malicious of Recommend == true, this reply would be removed from user’s view FeedTagCase between PublicFeed and FeedTag FeedVote between PublicFeed and User RecommendVote between FeedRecommend and User M:M between FeedTag and FeedRecommend
  • 17. Mail-centric Tables & Classes   ER Diagram Class Diagram  OutMail & InMail    While trashed of OutMail == true, this mail would be removed from sender’s view While trashed of InMail == true, this mail would be removed from receiver’s view While one trashed of OutMail == true and trashed of it’s InMails == true simultaneously, these mails will be deleted from database
  • 18. My Space-centric Tables & Classes   ER Diagram Class Diagram    MySpaceSetting between MySpace and MySpaceChoice MySpaceAnswer between MySpace and MySpaceQuestion 1:1 Lazy initialization between MemberProfile and MySpace
  • 19. Access Control-centric Tables & Classes   ER Diagram Class Diagram  Table per class hierarchy    Nested Group     AccessControl, UserControl, RoleControl, GroupControl AccessRule, SupervisorRule, MemberRule Tree structure M:M between Role and User M:M between Group and User Access Rule   Priority UserControl > RoleControl > GroupControl Resolves conflicts when the same type of AccessControl are assigned
  • 20. Forum-centric Tables & Classes   ER Diagram Class Diagram  Nested TopicReply    Tree structure While malicious of Reply == true, this reply would be removed from user’s view Topic Watch   Update last replied time when user replies Between User and ForumTopic
  • 21. Look from Top-Down, Carry out from Bottom-Up
  • 22. Ready for APIs & Components I  User Authenticator  Related Tables & Classes      User-centric Login & Logout Cookie mechanics Password Digester Random 12-characters Password Generator
  • 23. Ready for APIs & Components II  eSobi Feed Subscriber  Related Tables & Classes     User-centric Feed-centric Public Feed count & Member Feed record eSobi Feed Recommender  Related Tables & Classes   User-centric Feed-centric
  • 24. Ready for APIs & Components III  eSobi Folder Backup  Related Tables & Classes    User-centric Feed-centric eSobi Folder Restorer  Related Tables & Classes   User-centric Feed-centric
  • 25. Ongoing for APIs & Components I  Data Migration   Data List Handler    Parse RSS XML to find information of feed User Authorizer   A pattern for Large Search Result Sets Paging Controller applied to web page RSS Parser   Old data is migrated to the new schema According to Access-Controls to find Access-Rules Mail Carrier
  • 26. Java Naming Convention     According to Java Bean convention Attribute firstly, Getter method secondly, Setter method lastly Collection-type Attribute, add extra Adder and Remover method Convenient findXXXByZZZ method
  • 27. SQL Syntax Convention  Statement    Spells SQL keywords in upper case SQL statements are often broken into multiple lines Table & Column name   Primary key should be the table name suffixed with "_id“ Separate words and prefixes with underlines, never use spaces
  • 28. Logging Service Convention     Replace System.out / System.err println with Logger Level warning & error & fatal on Production machine Level trace & debug & info on SIT / UAT machine Logging necessary messages about our logic.  if log.isXXXEnabled, then log.XXX message
  • 29. Centralized Controlling & Distributed Computing  There’s no need to reinvent the wheel   Bitter design vs. Appropriate design   Tree traverse method Universal entry between up-tier and down-tier   J2EE Pattern & GoF Pattern Hard code vs. Sophisticated Algorithm   Open Source Community e.g. Service Locator & Session Façade Divide and conquer inside the same tier
  • 30. Concurrent Access Risk    Deadlock while insert & update concurrently Dirty columns of table for performance gain AJAX seems delicious, but ...
  • 31. Performance Issue & Tuning  High availability & High scalability    Clustering & Load Balancing Fail Over & Session Persistence Code Refactoring    SQL statement (DAO) Tuning Business Logic (BO) Tuning Cached Result Page    Event-Driven: JMS (Synchronous) Scheduling: Quartz (Asynchronous) Database Refactoring    Re-Index on Tables Database Trigger Database Stored Procedure
  • 32. Test-driven development  Planning      Release planning creates the schedule Make frequent small releases The project is divided into iterations Iteration planning starts each iteration Designing    Simplicity Choose a system metaphor Refactoring whenever and wherever possible
  • 33. Test-driven development  Coding      Code must be written to agreed standards Integrate often Use collective code ownership Leave optimization till last Testing     All code must have unit tests All code must pass all unit tests before release When a bug is found tests are created Acceptance tests are run often
  • 34. Reference         Core J2EE Patterns J2EE Patterns Catalog GoF Patterns AJAX Patterns Java Naming Convention Essential Database Naming Conventions SQL Syntax Conventions Extreme Programming
  • 35. Q&A