SlideShare a Scribd company logo
CSE 136 - Lecture 5 Part 1
What is Business Logic Layer
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?
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
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
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
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
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
Object-based pattern - Active Record
Pattern ex
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
Compare the Patterns
Domain Model to ER (DAL)
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
UML Review 1
UML Review 2
Domain Model – class diagram
ex1



                Database ER diagram is hidden away
                From the Domain Model

                How many tables to store student
                info?
Domain Model – class diagram
ex2




         Review table in the database may have
         a order_id, but in Domain Model, it is not
         used.
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).
Domain Model – class diagram
ex4
Break Time
CSE 136 - Lecture 5 Part 2
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
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
Creational Patterns
   Factory
   Singleton
   Prototype (skip)
   Abstract Factory (skip)
   Builder (skip)
Creational - Factory example
                        Logging C# example
                        available on class
                        homepage (136 project)




                        Polymorphism
Creational - Factory
Creational - Singleton
Creational - Singleton Code




                    C# interview question
Structural Design Patterns
   Decorator
   Proxy
   Adapter
   Facade
   Bridge (skip)
   Composite (skip)
   Flyweight (skip)
Structural - Decorator example
Structural - Decorator




                         .NET libraries are
                         based on decorator
                         pattern
Structural - Proxy example
Structural - Proxy
Structural - Adapter example
Structural - Adapter
Structural - Facade
Behavioral Pattern
   Strategy
   Chain of Responsibility
   Iterator (skip - you have seen this in C#
    lecture “enumerator”)
   Skip:
    Observer, Command, Mediator, Memento, Stat
    e, others…
Behavioral - Strategy example




                       Polymorphism
Behavioral - Strategy




                        Polymorphism


     Client may come
     From GUI
Behavioral - Chain example




                  Polymorphism
Behavioral - Chain




                     Polymorphism
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.
Demo Code
   Business Logic Layer
   Domain Objects
   Error Logging implementation (factory pattern)
   Data Transfer Object
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
References
   .NET : Architecting Applications for the
    Enterprise
   Design Patterns: Elements of Re-usable
    Object-Oriented Software
   C# Design Patterns

More Related Content

PPTX
PPTX
PPTX
PPTX
PPTX
Ef code first
PPTX
Microsoft Entity Framework
PPT
Jdbc (database in java)
PPT
Ef code first
Microsoft Entity Framework
Jdbc (database in java)

What's hot (20)

PPTX
PPT
Jdbc slide for beginers
PPT
JDBC Tutorial
PPT
Java database connectivity
PPTX
J2EE PPT --CINTHIYA.M Krishnammal college for women
PPT
Jdbc complete
PPTX
L04 base patterns
PDF
Database and Java Database Connectivity
PDF
Overview Of JDBC
PPTX
Jdbc in servlets
PPT
PPT
Java Database Connectivity
PPTX
SQL, Embedded SQL, Dynamic SQL and SQLJ
PPTX
.NET Attributes and Reflection - What a Developer Needs to Know...
PPTX
Java- JDBC- Mazenet Solution
PPT
PPS
Jdbc architecture and driver types ppt
Jdbc slide for beginers
JDBC Tutorial
Java database connectivity
J2EE PPT --CINTHIYA.M Krishnammal college for women
Jdbc complete
L04 base patterns
Database and Java Database Connectivity
Overview Of JDBC
Jdbc in servlets
Java Database Connectivity
SQL, Embedded SQL, Dynamic SQL and SQLJ
.NET Attributes and Reflection - What a Developer Needs to Know...
Java- JDBC- Mazenet Solution
Jdbc architecture and driver types ppt
Ad

Similar to Day5 (20)

PPTX
Sofwear deasign and need of design pattern
PPTX
Architecture and design
PPT
Software Design Patterns
PPT
Software Design Patterns
PPTX
Gof design patterns
PPTX
Let us understand design pattern
PPTX
Common ASP.NET Design Patterns - Telerik India DevCon 2013
PPTX
Most Useful Design Patterns
PPTX
Design patterns
PPTX
Introduction to Design Patterns
PPT
Introduction To Design Patterns
PDF
Design patterns for fun & profit - CoderCruise 2018
PPTX
PATTERNS01 - An Introduction to Design Patterns
PPTX
ap assignmnet presentation.pptx
PDF
Style & Design Principles 02 - Design Patterns
PPTX
Software System Architecture-Lecture 6.pptx
PDF
designpatterns-.pdf
DOCX
Design patterns
PPTX
Design patterns
PPSX
Prophecy Of Design Patterns
Sofwear deasign and need of design pattern
Architecture and design
Software Design Patterns
Software Design Patterns
Gof design patterns
Let us understand design pattern
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Most Useful Design Patterns
Design patterns
Introduction to Design Patterns
Introduction To Design Patterns
Design patterns for fun & profit - CoderCruise 2018
PATTERNS01 - An Introduction to Design Patterns
ap assignmnet presentation.pptx
Style & Design Principles 02 - Design Patterns
Software System Architecture-Lecture 6.pptx
designpatterns-.pdf
Design patterns
Design patterns
Prophecy Of Design Patterns
Ad

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
cuic standard and advanced reporting.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Teaching material agriculture food technology
Review of recent advances in non-invasive hemoglobin estimation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf
Modernizing your data center with Dell and AMD
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
Unlocking AI with Model Context Protocol (MCP)
Understanding_Digital_Forensics_Presentation.pptx

Day5

  • 1. CSE 136 - Lecture 5 Part 1
  • 2. What is Business Logic Layer
  • 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
  • 9. Object-based pattern - Active Record Pattern ex
  • 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
  • 12. Domain Model to ER (DAL)
  • 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).
  • 19. Domain Model – class diagram ex4
  • 21. CSE 136 - Lecture 5 Part 2
  • 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
  • 24. Creational Patterns  Factory  Singleton  Prototype (skip)  Abstract Factory (skip)  Builder (skip)
  • 25. Creational - Factory example Logging C# example available on class homepage (136 project) Polymorphism
  • 28. Creational - Singleton Code C# interview question
  • 29. Structural Design Patterns  Decorator  Proxy  Adapter  Facade  Bridge (skip)  Composite (skip)  Flyweight (skip)
  • 31. Structural - Decorator .NET libraries are based on decorator pattern
  • 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…
  • 38. Behavioral - Strategy example Polymorphism
  • 39. Behavioral - Strategy Polymorphism Client may come From GUI
  • 40. Behavioral - Chain example Polymorphism
  • 41. Behavioral - Chain Polymorphism
  • 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