• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content







Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Day5 Day5 Presentation Transcript

    • 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 Whats 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 cant catch this error through unit
    • Object-based Pattern - ActiveRecord 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 wont affect outcome One step closer to Object Oriented Design, but not object-oriented yet
    • Object-based pattern - Active RecordPattern ex
    • Object-Based Patterns - Domain ModelPattern 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 diagramex1 Database ER diagram is hidden away From the Domain Model How many tables to store student info?
    • Domain Model – class diagramex2 Review table in the database may have a order_id, but in Domain Model, it is not used.
    • Domain Model – class diagramex3 Database ER diagram will have more tables to stored these information (vehicle, make, model, vendor, produc t, location, back_order, etc).
    • Domain Model – class diagramex4
    • 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