SlideShare a Scribd company logo
1 of 63
Lecture 07
Organizing Domain Logic
Agenda
 Layering
 The Three Principal Layers
 Domain layer Patterns
– Transaction Script
– Domain Model
– Table Module
– Service Layer
 From Problem to Pattern
 Building the domain
Reading
 Fowler Introduction
– Thinking about Performance (p. 6-9)
 Fowler 1: Layering
 Fowler 2: Organizing Domain Logic
 Fowler 9: Domain Logic Patterns
Layering
Layering
 Software systems can get complicated
– Abstractions are needed
 Layering provides abstraction by separating
computer systems in layers
– Higher layers use services from
lower layers
– Each layer has dedicated tasks
and hides complexity from upper
layers
Benefits of Layering
 You can understand a single layer as a
coherent whole without knowing much about
other layers
 You can substitute layers with alternative
implementation of the same basic service
 You minimize dependencies between layers
 Layers make good places for standardization
 Once you have a layer built, you can use it for
many higher-level services
Downsides
 Layers encapsulate some, but not all, things well
– Cascading changes
– For example adding a field in the UI requires changes
on each layer
 Extra layers can harm performance
– At every layer things typically need to be transformed
from one presentation to another
 Organizational problems
– If difference teams work on different layers, code
duplications and other problems emerge
The Three Principal Layers
The Three Layers
 Presentation
– User’s interface to the system
– User can be another system
– Accepts input, displays views
 Domain
– The Application of the system
– The “Business logic”
– Tends to creep into presentation and data source
 Data Source
– Connection to the database
– Also Persistence
Where is the Business Logic?
 “Business Logic”
– or “Complex business illogic”?
– Business Rules including all special cases
– It is easy to think of business logic but difficult to spot
– many corner cases
– Also referred to as Domain Logic
 Enterprise software has a lot of “noise”
– “Plumbing” code around the domain logic
– Is getCustomer domain logic?
– Application Logic – or workflow
How to define Domain Logic?
 Definition
– If all environment (noise) is taken way, what is left should
be domain logic
– Environment is any middleware (web, data, ejb)
 Domain Logic should be
– Simple classes and interfaces – POJOs
– Easy to test!
– Easy to move around
– Easy to access
 Limited dependencies
– Dependencies can be reduced by injection
The Three Layers
 Dependencies
– Presentation gets information from lower layers,
preferable Domain Layer
– Domain or Data Source Layers should not depend
on the Presentation Layer
– Domain Layer depends on Data Source Layer
– Data Source Layer could use some objects from the
Domain Layer
Logic that is not Domain Logic
 Logic in different places
Presentation Logic
 How to display items, how things look
– Which colours to choose
– Number and Date formats, zero padding
 The presentation should
– Have easy and unified access to the data
– Avoid having assumptions on the data
– Avoid the need to calculate based on the data
 Example view models
– HTML, Flash
– JSP, ASP
Data Source Logic
 How to query and store items
– Optimization
– Data manipulation for upper layer
 The Data Source Layer should
– Provide simple interface to the domain layer
– Maintain speed and integrity
– Hide the database layout from the object model
 Example data model
– DAO
– Stored Procedures
Application Logic
 Having to do with application responsibilities
– “Workflow” logic
– Noise
 Example:
– Notifying contract administrator
– Checking HTTP parameters and selecting which
controller to pass the responsibility to
Interfaces
 Users can be other programs or services
– Presentation is an external interface that you provide
as a service to others
 Data can be other systems
– Data source is an external interface of services that
you use
Where is the Business Logic?
 Create a specific Layer for the Domain Logic
– Well know patterns like Domain Model
– An object model of the domain that incorporates both
behaviour and data
– Object-oriented programming!!!
Where is the Business Logic?
 Flooding of logic...
 If you don’t provide a place for the Domain Logic
it will find a place – usually in the wrong!
Enterprise Web Layers
 Clients usually run on the user’s machine
– Separate tier
– Web Browser or Rich Internet Application (RIA)
– Can also be processes or other applications
 Web Components run on a Web Server
 Domain Components run on Application Server
– Web Server or EJB Server for EJBs
 Data Source Components run on the same
Application Server (as the domain)
 Database is usually on a separate tier
Domain Layer Patterns
Domain Layer
 Provides the business logic of the application
– Not part of the Presentation Layer nor the Data
Source layer
Domain Layer Patterns
 Transaction Script
– Organizes business logic by procedures where each
procedure handles single request from the
presentation
 Domain Model
– An object model of the domain that incorporates both
data and behaviour
 Table Module
– One class that provides domain logic to table or view
in database
Transaction Scripts
Organizes business logic by procedures
where each procedure handles a single request
from the presentation
 Most business applications can be thought of as
a series of transactions
– A Transaction Script organizes all this logic primarily
as a single procedure
Transaction Scripts
 Works well if model is simple
– Small amount of logic
– No state needed
– Moving data between presentation and database
 Problems
– Code duplication between transactions
– Common code tends to be duplicated
– Since no state is used, and each transaction is
separate from any other, there might be too many
calls to database layer
Transaction Scripts
 Revenue recognitions example
– One script handles all the logic
– Uses a data gateway to access data
Domain Model
An object model of the domain that
incorporates both behavior and data
 Rules and logic describe many different cases
and slants of behavior
 Web of interconnected objects
– Where each object represents some meaningful entity
– Dependencies between objects
 How it works
– Object that represent data (value objects) and
business rules (behavior)
Domain Model
 Simple model
– Similar to the database design
– Simple to map to the database
 Rich model
– Different from the database
design
– Better for solving some
complex logic and doing
calculation
Domain Model
 Revenue recognitions example
– Multiple classes each with different responsibility
– Each class has data and logic to calculate
Table Module
A single instance that handles the business logic for
all rows in a database table or view
 Organizes domain logic with one class per table in
the database
– Single instance of the class contains various procedures
that will act on the data
– One object per table handle
 How it works
– One class that provides domain logic to table or view in
database
– A Domain Model will have one order object per order while
a Table Module will have one object to handle all orders
Table Module
 When to use it
– Useful when application is centered on data
– Objects in the model are similar to the database
Making a Choice
 Pattern depends on
– Complexity of the domain logic and
– How the domain maps to the database
Service Layer
Defines an application’s boundary with a layer of
services that establishes a set of available
opertaions and coordinates the application’s
response in each operation
 Defines an application's boundary
– Provides a set of available operations from the
perspective of interfacing client layers
– Encapsulates the application's business logic
Service Layer
 Domain façade
– Provides thin interface
to the Domain Model
– Does not implement
any business logic
 Operation Script
– Implementation of
application logic
– Use the Domain Model
for domain logic
Design with Service Layer
I want to structure my domain layer and use a pattern that applies to each
situation:
A) The logic is rather extensive
B) The logic is simple and procedure based
C) The logic is moderate and is centered around the database
EXERCISE
From Problem to Pattern
How do I structure my domain layer?
A) The logic is rather extensive
Domain Model
Domain Model
An object model of the domain that
incorporates both behaviour and data
 Rules and logic describe many different cases
and slants of behaviour
 Web of interconnected objects
– Where each object represents some meaningful entity
– Dependencies between objects
 How it works
– Object that represent data (value objects) and
business rules (behaviour)
From Problem to Pattern
How do I structure my domain layer?
B) The logic is simple and procedure
based
Transaction Script
Transaction Scripts
Organizes business logic by procedures
where each procedure handles a single request
from the presentation
 Most business applications can be thought of as
a series of transactions
– A Transaction Script organizes all this logic primarily
as a single procedure
From Problem to Pattern
How do I structure my domain layer?
C) The logic is moderate and is
centered around the database
Table Module
Table Module
A single instance that handles the business logic for
all rows in a database table or view
 Organizes domain logic with one class per table in
the database
– Single instance of the class contains various procedures
that will act on the data
– One object per table handle
 How it works
– One class that provides domain logic to table or view in
database
– A Domain Model will have one order object per order while
a Table Module will have one object to handle all orders
From Problem to Pattern
How do I give my domain logic
distinct API?
Service Layer
Service Layer
Defines an application’s boundary with a layer of
services that establishes a set of available
operations and coordinates the application’s
response in each operation
 Defines an application's boundary
– Provides a set of available operations from the
perspective of interfacing client layers
– Encapsulates the application's business logic
From Problem to Patterns
Problem – Ru Movie DB (rumdb)
From Problem to Pattern
 We need to build a solution
– We know the problem – sort of
 To get to the solution
– What patterns to use?
Rumdb
The RU Movie Database
SolutionProblem
Solution?
 How to we get to this?
How to define Domain Logic?
 Definition
– If all environment (noise) is taken way, what is left should
be domain logic
– Environment is any middleware (web, data, ejb)
 Domain Logic should be
– Simple classes and interfaces – POJOs
– Easy to test!
– Easy to move around
– Easy to access
 Limited dependencies
– Dependencies can be reduced by injection
Building the Domain
 Objects – the nouns
– Movie, Ratings, Channel, …
 User Stories
– What you do with the objects
 Example
– As a Operator, I want to add new movie
– As a User, I want to get all movies for a specific
channel
– As a User, I want to rate specific movie
Movie Database Example
Movie Database Example
 The Service Layer
– MovieService Provides simple and clean interface for
manipulation of Movies
– External services can be injected into the Service
Layer
Movie Database Example
 MovieService
– Provides an interface to manipulate Movies
public class MovieService extends ApplicationService
{
private MovieDataGateway movieDataGateway;
public void addMovie(Movie movie) throws ServiceException
{
movie.initialize();
if(!movie.validate())
{
throw new ServiceException("Movie is invalid");
}
movieDataGateway.addMovie(movie);
getMailGateway().SendMessage("netfang@ru.is", "netfang@ru.is",
"New Movie", "New Movie was added!");
}
...
Movie Database Example
 ApplicationService
– Layered Supertype for the Service Layer
– Provides support for all service classes
public class ApplicationService
{
private MailGateway mailGateway;
public MailGateway getMailGateway()
{
return mailGateway;
}
public void setMailGateway(MailGateway mailGateway)
{
this.mailGateway = mailGateway;
}
}
Movie Database Example
 The Domain Model
– POJOs with attributes and operations
Movie Database Example
 Movie
– Object for describing and manipulating contents
– Has a Rating object which keeps count of views and
rates
public class Movie implements Comparable
{
private int id;
private String title;
private String link;
private String description;
private Date release;
private String director;
private Rating rating = new Rating();
private List<Validator> validators = new ArrayList<Validator>();
Movie Database Example
 Methods in Movie
public void initialize()
{
rating.reset();
clearValidators();
addValidator(new DefaultMovieValidator(this));
}
public boolean validate()
{
for(Validator v : validators)
{
if(!v.validate())
return false;
}
return true;
}
Movie Database Example
 Methods in Movie
– Has validators – easily extendable according to the
Open-Close Principle
public void clearValidators()
{
validators.clear();
}
public void addValidator(Validator validator)
{
validators.add(validator);
}
Movie Database Example
 Methods in Movie
public void view()
{
rating.incrementView();
}
public void rate(int rate)
{
rating.incrementRate(rate);
}
public double getAverageRate()
{
return rating.getAverageRate();
}
Movie Database Example
 Rating
public class Rating
{
private int views; // Number of requests
private int rates; // Number of rates
private int score; // Combined values of scores
public void incrementView()
{
views++;
}
public void incrementRate(int rate)
{
rates++;
score += rate;
}
public double getAverageRate()
{
return score/rates;
}
Movie Database Example
Movie Database Example
 TestSimple
public TestSimple()
{
MovieService movieService = new MovieService();
movieService.setMovieDataGateway(new MovieDataGatewayStub());
movieService.setMailGateway(new MailServerStub());
try {
movieService.addMovie(new Movie(1, "Movie 1”, "http1", "", new Date(), ""));
movieService.addMovie(new Movie(1, "Movie 2", "http2", "", new Date(), ""));
movieService.addMovie(new Movie(1, "Movie 3", "http3", "", new Date(), ""));
movieService.addMovie(new Movie(1, "Movie 4", "http4", "", new Date(), ""));
}
catch (ServiceException sex) { ... }
List<Movie> list = movieService.getMovies();
for (Movie movie : list)
{
System.out.println(movie);
}
Summary
 Layering
 Three Principal Layers
 Domain layer Patterns to choose from
– Transaction Script for simple business logic
– Domain Model for complex business logic
– Table Module for moderate business logic when you
have good tools around Record Set
– Service Layer to provide API
 Building the domain
 From Problem to Pattern

More Related Content

What's hot

CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)Daniel Cai
 
Informatica
InformaticaInformatica
Informaticamukharji
 
Client/Server Architecture By Faisal Shahzad
Client/Server Architecture By Faisal Shahzad Client/Server Architecture By Faisal Shahzad
Client/Server Architecture By Faisal Shahzad Faisal Shehzad
 
Enterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRMEnterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRMDaniel Cai
 
What can power designer do for me
What can power designer do for meWhat can power designer do for me
What can power designer do for meGeorge McGeachie
 
Introduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratIntroduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratAttaullah Hazrat
 
Generating XML schemas from a Logical Data Model (EDW 2011)
Generating XML schemas from a Logical Data Model (EDW 2011)Generating XML schemas from a Logical Data Model (EDW 2011)
Generating XML schemas from a Logical Data Model (EDW 2011)George McGeachie
 
Client-Server Computing
Client-Server ComputingClient-Server Computing
Client-Server ComputingCloudbells.com
 
Informatica Online Training
Informatica Online Training Informatica Online Training
Informatica Online Training saikirancrs
 
Informatica Power Center 7.1
Informatica Power Center 7.1Informatica Power Center 7.1
Informatica Power Center 7.1ganblues
 
Informatica Powercenter Architecture
Informatica Powercenter ArchitectureInformatica Powercenter Architecture
Informatica Powercenter ArchitectureBigClasses Com
 
How to Leverage FME in a Master Data Management Architecture
How to Leverage FME in a Master Data Management ArchitectureHow to Leverage FME in a Master Data Management Architecture
How to Leverage FME in a Master Data Management ArchitectureSafe Software
 
Informatica Server Manager
Informatica Server ManagerInformatica Server Manager
Informatica Server Managerganblues
 

What's hot (20)

Info sphere overview
Info sphere overviewInfo sphere overview
Info sphere overview
 
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
 
Client Server Architecture1
Client Server Architecture1Client Server Architecture1
Client Server Architecture1
 
Informatica
InformaticaInformatica
Informatica
 
Informatica slides
Informatica slidesInformatica slides
Informatica slides
 
Client/Server Architecture By Faisal Shahzad
Client/Server Architecture By Faisal Shahzad Client/Server Architecture By Faisal Shahzad
Client/Server Architecture By Faisal Shahzad
 
Enterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRMEnterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRM
 
eDocumentus for IBM Maximo
eDocumentus for IBM MaximoeDocumentus for IBM Maximo
eDocumentus for IBM Maximo
 
What can power designer do for me
What can power designer do for meWhat can power designer do for me
What can power designer do for me
 
Introduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah HazratIntroduction to the client server computing By Attaullah Hazrat
Introduction to the client server computing By Attaullah Hazrat
 
Generating XML schemas from a Logical Data Model (EDW 2011)
Generating XML schemas from a Logical Data Model (EDW 2011)Generating XML schemas from a Logical Data Model (EDW 2011)
Generating XML schemas from a Logical Data Model (EDW 2011)
 
Client-Server Computing
Client-Server ComputingClient-Server Computing
Client-Server Computing
 
Informatica Online Training
Informatica Online Training Informatica Online Training
Informatica Online Training
 
Informatica Power Center 7.1
Informatica Power Center 7.1Informatica Power Center 7.1
Informatica Power Center 7.1
 
L19 Application Architecture
L19 Application ArchitectureL19 Application Architecture
L19 Application Architecture
 
DMS component for MAXIMO
DMS component for MAXIMODMS component for MAXIMO
DMS component for MAXIMO
 
Informatica Powercenter Architecture
Informatica Powercenter ArchitectureInformatica Powercenter Architecture
Informatica Powercenter Architecture
 
How to Leverage FME in a Master Data Management Architecture
How to Leverage FME in a Master Data Management ArchitectureHow to Leverage FME in a Master Data Management Architecture
How to Leverage FME in a Master Data Management Architecture
 
Power BI Interview Questions
Power BI Interview QuestionsPower BI Interview Questions
Power BI Interview Questions
 
Informatica Server Manager
Informatica Server ManagerInformatica Server Manager
Informatica Server Manager
 

Viewers also liked

DDD, CQRS & ES lessons learned (Gitte Vermeiren)
DDD, CQRS & ES lessons learned (Gitte Vermeiren)DDD, CQRS & ES lessons learned (Gitte Vermeiren)
DDD, CQRS & ES lessons learned (Gitte Vermeiren)Visug
 
Defying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with AutomationDefying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with AutomationRafal Los
 
Client server architecture
Client server architectureClient server architecture
Client server architectureBhargav Amin
 
User Interface Design
User Interface DesignUser Interface Design
User Interface DesignJReifman
 
Generating Architectural Concepts & Design Ideas
Generating Architectural Concepts & Design IdeasGenerating Architectural Concepts & Design Ideas
Generating Architectural Concepts & Design IdeasWan Muhammad / Asas-Khu™
 
An introduction to fundamental architecture concepts
An introduction to fundamental architecture conceptsAn introduction to fundamental architecture concepts
An introduction to fundamental architecture conceptswweinmeyer79
 

Viewers also liked (7)

DDD, CQRS & ES lessons learned (Gitte Vermeiren)
DDD, CQRS & ES lessons learned (Gitte Vermeiren)DDD, CQRS & ES lessons learned (Gitte Vermeiren)
DDD, CQRS & ES lessons learned (Gitte Vermeiren)
 
Physical Architecture Layer Design
Physical Architecture Layer DesignPhysical Architecture Layer Design
Physical Architecture Layer Design
 
Defying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with AutomationDefying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with Automation
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 
User Interface Design
User Interface DesignUser Interface Design
User Interface Design
 
Generating Architectural Concepts & Design Ideas
Generating Architectural Concepts & Design IdeasGenerating Architectural Concepts & Design Ideas
Generating Architectural Concepts & Design Ideas
 
An introduction to fundamental architecture concepts
An introduction to fundamental architecture conceptsAn introduction to fundamental architecture concepts
An introduction to fundamental architecture concepts
 

Similar to L07 Oranizing Domain Logic

Domain Logic Patterns
Domain Logic PatternsDomain Logic Patterns
Domain Logic PatternsElifTech
 
L12 Session State and Distributation Strategies
L12 Session State and Distributation StrategiesL12 Session State and Distributation Strategies
L12 Session State and Distributation StrategiesÓlafur Andri Ragnarsson
 
Study the past if you would define the future: How Gang of Four patterns are ...
Study the past if you would define the future: How Gang of Four patterns are ...Study the past if you would define the future: How Gang of Four patterns are ...
Study the past if you would define the future: How Gang of Four patterns are ...Thomas Gamble
 
Why you shouldnt use django for that
Why you shouldnt use django for thatWhy you shouldnt use django for that
Why you shouldnt use django for thatIván Stepaniuk
 
session on pattern oriented software architecture
session on pattern oriented software architecturesession on pattern oriented software architecture
session on pattern oriented software architectureSUJOY SETT
 
Implementing the Database Server session 01
Implementing the Database Server  session 01Implementing the Database Server  session 01
Implementing the Database Server session 01Guillermo Julca
 
Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014Sandro Mancuso
 
Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Sandro Mancuso
 
Application architecture
Application architectureApplication architecture
Application architectureIván Stepaniuk
 

Similar to L07 Oranizing Domain Logic (20)

L15 Organising Domain Layer
L15 Organising Domain LayerL15 Organising Domain Layer
L15 Organising Domain Layer
 
L15 Data Source Layer
L15 Data Source LayerL15 Data Source Layer
L15 Data Source Layer
 
L11 Application Architecture
L11 Application ArchitectureL11 Application Architecture
L11 Application Architecture
 
L08 Data Source Layer
L08 Data Source LayerL08 Data Source Layer
L08 Data Source Layer
 
L19 Application Architecture
L19 Application ArchitectureL19 Application Architecture
L19 Application Architecture
 
L17 Data Source Layer
L17 Data Source LayerL17 Data Source Layer
L17 Data Source Layer
 
L06 Using Design Patterns
L06 Using Design PatternsL06 Using Design Patterns
L06 Using Design Patterns
 
Domain Logic Patterns
Domain Logic PatternsDomain Logic Patterns
Domain Logic Patterns
 
L12 Session State and Distributation Strategies
L12 Session State and Distributation StrategiesL12 Session State and Distributation Strategies
L12 Session State and Distributation Strategies
 
Study the past if you would define the future: How Gang of Four patterns are ...
Study the past if you would define the future: How Gang of Four patterns are ...Study the past if you would define the future: How Gang of Four patterns are ...
Study the past if you would define the future: How Gang of Four patterns are ...
 
L12 Visualizing Architecture
L12 Visualizing ArchitectureL12 Visualizing Architecture
L12 Visualizing Architecture
 
Why you shouldnt use django for that
Why you shouldnt use django for thatWhy you shouldnt use django for that
Why you shouldnt use django for that
 
session on pattern oriented software architecture
session on pattern oriented software architecturesession on pattern oriented software architecture
session on pattern oriented software architecture
 
Implementing the Database Server session 01
Implementing the Database Server  session 01Implementing the Database Server  session 01
Implementing the Database Server session 01
 
Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014
 
L21 scalability
L21 scalabilityL21 scalability
L21 scalability
 
Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014
 
L02 Architecture
L02 ArchitectureL02 Architecture
L02 Architecture
 
Application architecture
Application architectureApplication architecture
Application architecture
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 

More from Ólafur Andri Ragnarsson

New Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionNew Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionÓlafur Andri Ragnarsson
 
New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine Ólafur Andri Ragnarsson
 

More from Ólafur Andri Ragnarsson (20)

Nýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfaraNýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfara
 
Nýjast tækni og framtíðin
Nýjast tækni og framtíðinNýjast tækni og framtíðin
Nýjast tækni og framtíðin
 
New Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionNew Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course Introduction
 
L01 Introduction
L01 IntroductionL01 Introduction
L01 Introduction
 
L23 Robotics and Drones
L23 Robotics and Drones L23 Robotics and Drones
L23 Robotics and Drones
 
L22 Augmented and Virtual Reality
L22 Augmented and Virtual RealityL22 Augmented and Virtual Reality
L22 Augmented and Virtual Reality
 
L20 Personalised World
L20 Personalised WorldL20 Personalised World
L20 Personalised World
 
L19 Network Platforms
L19 Network PlatformsL19 Network Platforms
L19 Network Platforms
 
L18 Big Data and Analytics
L18 Big Data and AnalyticsL18 Big Data and Analytics
L18 Big Data and Analytics
 
L17 Algorithms and AI
L17 Algorithms and AIL17 Algorithms and AI
L17 Algorithms and AI
 
L16 Internet of Things
L16 Internet of ThingsL16 Internet of Things
L16 Internet of Things
 
L14 From the Internet to Blockchain
L14 From the Internet to BlockchainL14 From the Internet to Blockchain
L14 From the Internet to Blockchain
 
L14 The Mobile Revolution
L14 The Mobile RevolutionL14 The Mobile Revolution
L14 The Mobile Revolution
 
New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine
 
L12 digital transformation
L12 digital transformationL12 digital transformation
L12 digital transformation
 
L10 The Innovator's Dilemma
L10 The Innovator's DilemmaL10 The Innovator's Dilemma
L10 The Innovator's Dilemma
 
L09 Disruptive Technology
L09 Disruptive TechnologyL09 Disruptive Technology
L09 Disruptive Technology
 
L09 Technological Revolutions
L09 Technological RevolutionsL09 Technological Revolutions
L09 Technological Revolutions
 
L07 Becoming Invisible
L07 Becoming InvisibleL07 Becoming Invisible
L07 Becoming Invisible
 
L06 Diffusion of Innovation
L06 Diffusion of InnovationL06 Diffusion of Innovation
L06 Diffusion of Innovation
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

L07 Oranizing Domain Logic

  • 2. Agenda  Layering  The Three Principal Layers  Domain layer Patterns – Transaction Script – Domain Model – Table Module – Service Layer  From Problem to Pattern  Building the domain
  • 3. Reading  Fowler Introduction – Thinking about Performance (p. 6-9)  Fowler 1: Layering  Fowler 2: Organizing Domain Logic  Fowler 9: Domain Logic Patterns
  • 5. Layering  Software systems can get complicated – Abstractions are needed  Layering provides abstraction by separating computer systems in layers – Higher layers use services from lower layers – Each layer has dedicated tasks and hides complexity from upper layers
  • 6. Benefits of Layering  You can understand a single layer as a coherent whole without knowing much about other layers  You can substitute layers with alternative implementation of the same basic service  You minimize dependencies between layers  Layers make good places for standardization  Once you have a layer built, you can use it for many higher-level services
  • 7. Downsides  Layers encapsulate some, but not all, things well – Cascading changes – For example adding a field in the UI requires changes on each layer  Extra layers can harm performance – At every layer things typically need to be transformed from one presentation to another  Organizational problems – If difference teams work on different layers, code duplications and other problems emerge
  • 9. The Three Layers  Presentation – User’s interface to the system – User can be another system – Accepts input, displays views  Domain – The Application of the system – The “Business logic” – Tends to creep into presentation and data source  Data Source – Connection to the database – Also Persistence
  • 10. Where is the Business Logic?  “Business Logic” – or “Complex business illogic”? – Business Rules including all special cases – It is easy to think of business logic but difficult to spot – many corner cases – Also referred to as Domain Logic  Enterprise software has a lot of “noise” – “Plumbing” code around the domain logic – Is getCustomer domain logic? – Application Logic – or workflow
  • 11. How to define Domain Logic?  Definition – If all environment (noise) is taken way, what is left should be domain logic – Environment is any middleware (web, data, ejb)  Domain Logic should be – Simple classes and interfaces – POJOs – Easy to test! – Easy to move around – Easy to access  Limited dependencies – Dependencies can be reduced by injection
  • 12. The Three Layers  Dependencies – Presentation gets information from lower layers, preferable Domain Layer – Domain or Data Source Layers should not depend on the Presentation Layer – Domain Layer depends on Data Source Layer – Data Source Layer could use some objects from the Domain Layer
  • 13. Logic that is not Domain Logic  Logic in different places
  • 14. Presentation Logic  How to display items, how things look – Which colours to choose – Number and Date formats, zero padding  The presentation should – Have easy and unified access to the data – Avoid having assumptions on the data – Avoid the need to calculate based on the data  Example view models – HTML, Flash – JSP, ASP
  • 15. Data Source Logic  How to query and store items – Optimization – Data manipulation for upper layer  The Data Source Layer should – Provide simple interface to the domain layer – Maintain speed and integrity – Hide the database layout from the object model  Example data model – DAO – Stored Procedures
  • 16. Application Logic  Having to do with application responsibilities – “Workflow” logic – Noise  Example: – Notifying contract administrator – Checking HTTP parameters and selecting which controller to pass the responsibility to
  • 17. Interfaces  Users can be other programs or services – Presentation is an external interface that you provide as a service to others  Data can be other systems – Data source is an external interface of services that you use
  • 18. Where is the Business Logic?  Create a specific Layer for the Domain Logic – Well know patterns like Domain Model – An object model of the domain that incorporates both behaviour and data – Object-oriented programming!!!
  • 19. Where is the Business Logic?  Flooding of logic...  If you don’t provide a place for the Domain Logic it will find a place – usually in the wrong!
  • 20. Enterprise Web Layers  Clients usually run on the user’s machine – Separate tier – Web Browser or Rich Internet Application (RIA) – Can also be processes or other applications  Web Components run on a Web Server  Domain Components run on Application Server – Web Server or EJB Server for EJBs  Data Source Components run on the same Application Server (as the domain)  Database is usually on a separate tier
  • 22. Domain Layer  Provides the business logic of the application – Not part of the Presentation Layer nor the Data Source layer
  • 23. Domain Layer Patterns  Transaction Script – Organizes business logic by procedures where each procedure handles single request from the presentation  Domain Model – An object model of the domain that incorporates both data and behaviour  Table Module – One class that provides domain logic to table or view in database
  • 24. Transaction Scripts Organizes business logic by procedures where each procedure handles a single request from the presentation  Most business applications can be thought of as a series of transactions – A Transaction Script organizes all this logic primarily as a single procedure
  • 25. Transaction Scripts  Works well if model is simple – Small amount of logic – No state needed – Moving data between presentation and database  Problems – Code duplication between transactions – Common code tends to be duplicated – Since no state is used, and each transaction is separate from any other, there might be too many calls to database layer
  • 26. Transaction Scripts  Revenue recognitions example – One script handles all the logic – Uses a data gateway to access data
  • 27. Domain Model An object model of the domain that incorporates both behavior and data  Rules and logic describe many different cases and slants of behavior  Web of interconnected objects – Where each object represents some meaningful entity – Dependencies between objects  How it works – Object that represent data (value objects) and business rules (behavior)
  • 28. Domain Model  Simple model – Similar to the database design – Simple to map to the database  Rich model – Different from the database design – Better for solving some complex logic and doing calculation
  • 29. Domain Model  Revenue recognitions example – Multiple classes each with different responsibility – Each class has data and logic to calculate
  • 30. Table Module A single instance that handles the business logic for all rows in a database table or view  Organizes domain logic with one class per table in the database – Single instance of the class contains various procedures that will act on the data – One object per table handle  How it works – One class that provides domain logic to table or view in database – A Domain Model will have one order object per order while a Table Module will have one object to handle all orders
  • 31. Table Module  When to use it – Useful when application is centered on data – Objects in the model are similar to the database
  • 32. Making a Choice  Pattern depends on – Complexity of the domain logic and – How the domain maps to the database
  • 33. Service Layer Defines an application’s boundary with a layer of services that establishes a set of available opertaions and coordinates the application’s response in each operation  Defines an application's boundary – Provides a set of available operations from the perspective of interfacing client layers – Encapsulates the application's business logic
  • 34. Service Layer  Domain façade – Provides thin interface to the Domain Model – Does not implement any business logic  Operation Script – Implementation of application logic – Use the Domain Model for domain logic
  • 36. I want to structure my domain layer and use a pattern that applies to each situation: A) The logic is rather extensive B) The logic is simple and procedure based C) The logic is moderate and is centered around the database EXERCISE
  • 37. From Problem to Pattern How do I structure my domain layer? A) The logic is rather extensive Domain Model
  • 38. Domain Model An object model of the domain that incorporates both behaviour and data  Rules and logic describe many different cases and slants of behaviour  Web of interconnected objects – Where each object represents some meaningful entity – Dependencies between objects  How it works – Object that represent data (value objects) and business rules (behaviour)
  • 39. From Problem to Pattern How do I structure my domain layer? B) The logic is simple and procedure based Transaction Script
  • 40. Transaction Scripts Organizes business logic by procedures where each procedure handles a single request from the presentation  Most business applications can be thought of as a series of transactions – A Transaction Script organizes all this logic primarily as a single procedure
  • 41. From Problem to Pattern How do I structure my domain layer? C) The logic is moderate and is centered around the database Table Module
  • 42. Table Module A single instance that handles the business logic for all rows in a database table or view  Organizes domain logic with one class per table in the database – Single instance of the class contains various procedures that will act on the data – One object per table handle  How it works – One class that provides domain logic to table or view in database – A Domain Model will have one order object per order while a Table Module will have one object to handle all orders
  • 43. From Problem to Pattern How do I give my domain logic distinct API? Service Layer
  • 44. Service Layer Defines an application’s boundary with a layer of services that establishes a set of available operations and coordinates the application’s response in each operation  Defines an application's boundary – Provides a set of available operations from the perspective of interfacing client layers – Encapsulates the application's business logic
  • 45. From Problem to Patterns
  • 46. Problem – Ru Movie DB (rumdb)
  • 47. From Problem to Pattern  We need to build a solution – We know the problem – sort of  To get to the solution – What patterns to use? Rumdb The RU Movie Database SolutionProblem
  • 48. Solution?  How to we get to this?
  • 49. How to define Domain Logic?  Definition – If all environment (noise) is taken way, what is left should be domain logic – Environment is any middleware (web, data, ejb)  Domain Logic should be – Simple classes and interfaces – POJOs – Easy to test! – Easy to move around – Easy to access  Limited dependencies – Dependencies can be reduced by injection
  • 50. Building the Domain  Objects – the nouns – Movie, Ratings, Channel, …  User Stories – What you do with the objects  Example – As a Operator, I want to add new movie – As a User, I want to get all movies for a specific channel – As a User, I want to rate specific movie
  • 52. Movie Database Example  The Service Layer – MovieService Provides simple and clean interface for manipulation of Movies – External services can be injected into the Service Layer
  • 53. Movie Database Example  MovieService – Provides an interface to manipulate Movies public class MovieService extends ApplicationService { private MovieDataGateway movieDataGateway; public void addMovie(Movie movie) throws ServiceException { movie.initialize(); if(!movie.validate()) { throw new ServiceException("Movie is invalid"); } movieDataGateway.addMovie(movie); getMailGateway().SendMessage("netfang@ru.is", "netfang@ru.is", "New Movie", "New Movie was added!"); } ...
  • 54. Movie Database Example  ApplicationService – Layered Supertype for the Service Layer – Provides support for all service classes public class ApplicationService { private MailGateway mailGateway; public MailGateway getMailGateway() { return mailGateway; } public void setMailGateway(MailGateway mailGateway) { this.mailGateway = mailGateway; } }
  • 55. Movie Database Example  The Domain Model – POJOs with attributes and operations
  • 56. Movie Database Example  Movie – Object for describing and manipulating contents – Has a Rating object which keeps count of views and rates public class Movie implements Comparable { private int id; private String title; private String link; private String description; private Date release; private String director; private Rating rating = new Rating(); private List<Validator> validators = new ArrayList<Validator>();
  • 57. Movie Database Example  Methods in Movie public void initialize() { rating.reset(); clearValidators(); addValidator(new DefaultMovieValidator(this)); } public boolean validate() { for(Validator v : validators) { if(!v.validate()) return false; } return true; }
  • 58. Movie Database Example  Methods in Movie – Has validators – easily extendable according to the Open-Close Principle public void clearValidators() { validators.clear(); } public void addValidator(Validator validator) { validators.add(validator); }
  • 59. Movie Database Example  Methods in Movie public void view() { rating.incrementView(); } public void rate(int rate) { rating.incrementRate(rate); } public double getAverageRate() { return rating.getAverageRate(); }
  • 60. Movie Database Example  Rating public class Rating { private int views; // Number of requests private int rates; // Number of rates private int score; // Combined values of scores public void incrementView() { views++; } public void incrementRate(int rate) { rates++; score += rate; } public double getAverageRate() { return score/rates; }
  • 62. Movie Database Example  TestSimple public TestSimple() { MovieService movieService = new MovieService(); movieService.setMovieDataGateway(new MovieDataGatewayStub()); movieService.setMailGateway(new MailServerStub()); try { movieService.addMovie(new Movie(1, "Movie 1”, "http1", "", new Date(), "")); movieService.addMovie(new Movie(1, "Movie 2", "http2", "", new Date(), "")); movieService.addMovie(new Movie(1, "Movie 3", "http3", "", new Date(), "")); movieService.addMovie(new Movie(1, "Movie 4", "http4", "", new Date(), "")); } catch (ServiceException sex) { ... } List<Movie> list = movieService.getMovies(); for (Movie movie : list) { System.out.println(movie); }
  • 63. Summary  Layering  Three Principal Layers  Domain layer Patterns to choose from – Transaction Script for simple business logic – Domain Model for complex business logic – Table Module for moderate business logic when you have good tools around Record Set – Service Layer to provide API  Building the domain  From Problem to Pattern