domain logic patterns of software architecture

32
PRESENTATION ON Domain Logic Patterns Guided by :Priya Deshpande Presented By:Shweta Ghate

Upload: shweta-ghate

Post on 10-Jun-2015

1.165 views

Category:

Education


1 download

DESCRIPTION

Software architechture Domain logic patterns

TRANSCRIPT

Page 1: Domain logic patterns of Software Architecture

PRESENTATION ON

Domain Logic Patterns

Guided by :Priya Deshpande

Presented By:Shweta Ghate

Page 2: Domain logic patterns of Software Architecture

Domain Logic describe the functional algorithms or business logic that handle the information exchange between a database and a user interfaces.

A well organized Domain Logic components are easy to maintain and scale.

What is Domain Logic ???

Page 3: Domain logic patterns of Software Architecture

Transition Script

Domain Model

Table Moduless

A Service Layer is placed over an underlying Domain Model or Table Module

3 Types of Domain Logic Patterns

Page 4: Domain logic patterns of Software Architecture

Transaction Script organizes business logic by procedures where each procedure handles a single request from the presentation.

Transition Script

Page 5: Domain logic patterns of Software Architecture

Example of Transition Script

Revenue Recognition Problem

Page 6: Domain logic patterns of Software Architecture

A Transaction Script organizes all this logic primarily as a single procedure, making calls directly to the database or through a thin database wrapper

Each transaction will have its own Transaction Script, although common subtasks can be broken into sub procedures.

Continued……

Page 7: Domain logic patterns of Software Architecture

With Transaction Script the domain logic is primarily organized by the transactions that you carry out with the system.

For e.g.: If your need is to book a hotel room, the logic to check room availability, calculate rates, a the database is found inside the Book Hotel Room procedure

Working

Page 8: Domain logic patterns of Software Architecture

AdvantagesIt is independent of other transaction.It allow you to manipulate instances of scripts

as objects at runtime.

When to use it…?Glory of Transaction Script is its simplicity .As the business logic gets more

complicated ,we can move to the Domain Model.

Page 9: Domain logic patterns of Software Architecture

Domain Model is an object model of the domain that incorporates both behavior and data.

Domain Model

Page 10: Domain logic patterns of Software Architecture

Example of Domain ModelRevenue Recognition Problem

Page 11: Domain logic patterns of Software Architecture

More complex business domains need to build in Domain Model.

It will give you many more options in structuring the code, increasing readability and decreasing duplication.

Domain Model mingles data and process, has

multivalued attributes and a complex web of associations, and uses inheritance.

Continued……

Page 12: Domain logic patterns of Software Architecture

Simple Domain Model looks very much like the database design with

mostly one domain object for each database table. use Active Record

Rich Domain Model look different from the database design, with

inheritance, strategies, and other patterns, and complex webs of small interconnected objects.

requires Data Mapper

Styles of Domain Model

Page 13: Domain logic patterns of Software Architecture

If you have complicated and ever changing business rules involving validation, calculations, and derivations, chances are that you'll want an object model to handle them.

Data Mapper which helps keep your Domain Model independent from the database and is the best approach to handle cases where the Domain Model and database schema diverge.

When to use it ???

Page 14: Domain logic patterns of Software Architecture

One of the problems with Domain Model is the interface with relational databases.

If you have many orders, a Domain Modewill have one order object per order.

To overcome such problems we move to Table Module.

Problems

Page 15: Domain logic patterns of Software Architecture

Table Module is a single instance that handles the business logic for all rows in a database table or view.

Table Module

Page 16: Domain logic patterns of Software Architecture

Example of Table ModelRevenue Recognition Problem

Page 17: Domain logic patterns of Software Architecture

A Table Module organizes domain logic with one class per table in the database and a single instance of a class contains the various procedures that will act on the data.

Table Module will have one object to handle

all orders.

Continued……

Page 18: Domain logic patterns of Software Architecture

The strength of the of Table Module is that it allows you to package the data and behavior together and at the same time play to the strengths of the relational database.

We use Table Module with a backing data structure that's table oriented.

The tabular data is normally the result of SQL calland is held in a Record Set that mimics a SQL table .

Working

Page 19: Domain logic patterns of Software Architecture

Grouping the behavior with the table gives you many of the benefits of encapsulation.

The Table Module may be an instance or it may be a collection of static methods.

The Table Module may include queries as factory methods.

Continued……

Page 20: Domain logic patterns of Software Architecture

Table Module is very much based on table-oriented data ,so we can use it when we access tabular data using Record Set .

Table Module allows you to fit business logic into the application in a well-organized manner, without losing the way the various elements work on the tabular data.

When to use it ???

Page 21: Domain logic patterns of Software Architecture

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.

It encapsulates the application's business logic, controlling transactions and coordinating responses in the implementation of its operations

Service Layer

Page 22: Domain logic patterns of Software Architecture
Page 23: Domain logic patterns of Software Architecture

Service Layer is a pattern for organizing business Service Layer factors each kind of business logic into

a separate layer, yielding the usual benefits of layering and rendering the pure domain object classes more reusable from application to application.

Continued……

Page 24: Domain logic patterns of Software Architecture

2 Basic implementation variations are Domain facade approach

Operation script approach

Implementation Variation

Page 25: Domain logic patterns of Software Architecture

Service Layer is implemented as a set of thin facades over a Domain Model

The classes implementing the facades don't implement any business logic but the Domain Model implements all the business logics

The thin facades establish a boundary and set of operation through which client layers interact with the application, exhibiting the defining characteristics of Service Layer.

Domain Facade Approach

Page 26: Domain logic patterns of Software Architecture

Service Layer is implemented as a set of thicker classes that directly implement application logic but delegate to encapsulated domain object classes for domain logic.

A Service Layer is comprised of these application service classes, which should extend a Layer Supertype , abstracting their responsibilities and common behaviors.

Operation Script Approach

Page 27: Domain logic patterns of Software Architecture

Service Layer classes are well remote invocation from an interface granularity perspective.

Starting with a locally invocable Service Layer whose method signatures deal in domain object, we can add services remotability when we need it by putting Remote Facades on your Service Layer .

To Remote or Not to remote

Page 28: Domain logic patterns of Software Architecture

Identifying the operations needed on a Service Layer boundary is pretty straightforward and they're determined by the needs of Service Layer clients.

The starting point for identifying Service Layer operations is the use case model and the user interface design for the application.

Identifying Services and Operations

Page 29: Domain logic patterns of Software Architecture

The benefit of Service Layer is that it defines a common set of application operations available to many kinds of clients.

An application with more than one kind of type of its business logic, and complex response in its use cases involving multiple transaction resources, it makes a lot of sense to include a Service Layer with container-managed, transactions, even in an undistributed architecture.

When to use it ???

Page 30: Domain logic patterns of Software Architecture

Domain Model you may want to consider Service Layer to give your Domain Model a more distinct API

Examples

Page 31: Domain logic patterns of Software Architecture

Patterns of Enterprise Application Architecture, Martin Fowler, Addison-Wesley Professional, 2003,ISBN-10: 0321127420 ISBN-13: 9780321127426

Paper :Homework 1 : Domain Logic , by Basanta Raj Onta (111701), Computer Science – August 2010.

Refrences

Page 32: Domain logic patterns of Software Architecture

Thank You