3. What is Business Logic Layer 2
Services
exposing business logic to outside system
GPA system can provide graduation status for students
Entities
Students taking courses. Courses have schedules and
location.
Courses are categorized by departments.
Rules, Calculations
Students can only register 20 units maximum per quarter
CSE136 must be taken after CSE135, etc.
Validation Cannot rely JavaScript for validation
Is the social security # 9 digits?
Is credit card all digits?
4. Business Layer Patterns
Procedure Pattern 1980s
Transcript Script pattern - A collection of procedures
(steps of execution).
Table Module Pattern 1990s
similar to transaction script but operations are
grouped by data (dataSet/dataTable)
Object-based Pattern 21th century
Interrelated & Interconnected objects.
Active Record Pattern - record looks like data tables
from the database with additional methods()
Domain Model Pattern - not ER diagrams, but OOD
diagrams
5. Procedure Pattern
Map your business components directly onto
required user actions.
Best suited for simple scenarios and unlikely
changing spec
Simple and no start-up cost
Can not handle large/complex specs
As complexity grow, becomes more costly (not
easily extended)
CSE 136 will NOT use this design pattern
6. Table Module Pattern
Remember DataSet
in DAL (ADO.NET) Built-in in ASP.NET
Series of transaction
grouped by Data
Grouping the
info/table by how
data are related
Good for quick
presentation display
7. Table Module Pattern 2
What's wrong with this
Pattern?
You must wait for SQL
stored procedures to
finish
If SQL proc changes, it
changes the BL
structure
remove a column
changed a column
name
You can't catch this
error through unit
8. Object-based Pattern - Active
Record Pattern
Active Record Pattern is based on DataSet
design but create class object for each
DataTable.
Duplication and quite a hassle
Better than Table Module Pattern
SQL Proc changes won't affect outcome
One step closer to Object Oriented Design, but
not object-oriented yet
10. Object-Based Patterns - Domain Model
Pattern
Domain Model is also known as Object-
Oriented Design
Define the entities and the relationships &
flows between them
Each Entity has data (variables) & behavior
(methods)
Consider the issues of “coupling” and
“cohesion”. “Reuse”, “Maintainability”, and
“Extensibility”
A diagram can be really large (divide &
conquer)
More Object-oriented design using Design
13. Class Objects Design - steps
Start with use case diagram
Run thru activity diagram to identify entities
and high-level relationship
Run thru sequence diagram again to identify
attributes and methods for each entities.
You may skip this step for 136 to save time
16. Domain Model – class diagram
ex1
Database ER diagram is hidden away
From the Domain Model
How many tables to store student
info?
17. Domain Model – class diagram
ex2
Review table in the database may have
a order_id, but in Domain Model, it is not
used.
18. Domain Model – class diagram
ex3
Database ER diagram will have more
tables to stored these information
(vehicle, make, model, vendor, produc
t, location, back_order, etc).
22. Why use Design Patterns
Provide a starting point for a solution
Speed up productivity in a team
Improves system and application design
Carpenter: connector design pattern
23. Object-oriented Design Patterns
Creational
The creational patterns aim to separate a system from
how its objects are created, composed, and
represented
They increase the system’s flexibility in terms of the
what, who, how, and when of object creation
Structural
Structural patterns are concerned with how classes
and objects are composed to form larger structures
Behavioral
Behavioral patterns identify common communication
patterns between objects
They increase flexibility in carrying out this
communication
37. Behavioral Pattern
Strategy
Chain of Responsibility
Iterator (skip - you have seen this in C#
lecture “enumerator”)
Skip:
Observer, Command, Mediator, Memento, Stat
e, others…
42. Review question
Why does domain model a better pattern at the
end?
What are the three categories of OO design
pattern?
Why are inheritance and polymorphism the
center of OO design pattern?
Open/close principal, code flexibility.
43. Demo Code
Business Logic Layer
Domain Objects
Error Logging implementation (factory pattern)
Data Transfer Object
44. Your Assignment
Due next Thursday
Design and develop business layer based on
UML
UML class diagram for Domain Object Model
C# Domain Model classes
C# Domain Business Logic
Must use creational pattern for error-logging (log
to db or file based on app.config)
Must use asynchronous call for error-logging
Validations (regular expression – cover in day6)
Developing test cases for your business layer
45. References
.NET : Architecting Applications for the
Enterprise
Design Patterns: Elements of Re-usable
Object-Oriented Software
C# Design Patterns