Enterprise Software Architecture Patterns

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What is the objective of structuring business applications?

To improve their organization and maintainability, especially those operating through several layers of processing.

What does 'Architecture' refer to in the context of business applications?

The main application parts and how they connect.

What is the purpose of architectural patterns?

To provide important decisions on application parts.

What do design patterns help with in the context of architecture?

<p>They help to realize the architecture.</p> Signup and view all the answers

For an online store, capturing orders, calculating prices, and shipment notifications are examples of complex business logic

<p>False (B)</p> Signup and view all the answers

Which of the following is NOT a typical feature of a small company expenses management system?

<p>Complex reporting and analytics (B)</p> Signup and view all the answers

What does a 'Pattern' describe in software architecture?

<p>A common problem and guidelines to solve it.</p> Signup and view all the answers

What is a 'Layered Architecture'?

<p>A common approach to decompose a complex problem.</p> Signup and view all the answers

In a layered architecture, the top layer needs to know the services defined by the bottom one.

<p>True (A)</p> Signup and view all the answers

In a layered architecture, a lower layer is aware of the top layer.

<p>False (B)</p> Signup and view all the answers

In a layered architecture, the bottom layer hides layers below to upper levels.

<p>True (A)</p> Signup and view all the answers

What is one of the benefits of layered architecture?

<p>You only need to know the first layer below, independently from others below.</p> Signup and view all the answers

What is one disadvantage of layered architecture?

<p>Risk of cascade changes.</p> Signup and view all the answers

What are the three layers in a 3-Layer Architecture?

<p>Presentation, Data Sources, and Domain Logic.</p> Signup and view all the answers

What does the Presentation layer handle in a 3-Layer Architecture?

<p>The logic of user-application interaction.</p> Signup and view all the answers

What is the function of the Data Sources layer in a 3-Layer Architecture?

<p>Communication with systems that provide data.</p> Signup and view all the answers

What is the role of the Domain Logic layer in a 3-Layer Architecture?

<p>Application-specific functionality.</p> Signup and view all the answers

What is a Transaction Script?

<p>A procedure that receives input parameters from Presentation, processes them, stores/retrieves data, invokes operations, and responds to Presentation.</p> Signup and view all the answers

Give an example of where Transaction Scripts may be used?

<p>An Online Store.</p> Signup and view all the answers

What is a Domain Model?

<p>A pattern based on the use of objects, suitable for complex domains.</p> Signup and view all the answers

What is a Table Module?

<p>A module designed to operate with pattern Record Set, a compromise between Transaction Script and Domain Model.</p> Signup and view all the answers

What is the function of an HTTP Interface in remote communication?

<p>To communicate through a browser or Web service using HTML, JSON, or XML formats.</p> Signup and view all the answers

What is the benefit of using an HTTP Interface?

<p>Almost universal and easy deployment.</p> Signup and view all the answers

What is one of the disadvantages of using an HTTP Interface

<p>Less explicit specification of the interface.</p> Signup and view all the answers

What is an OO interface?

<p>CORBA, ActiveX, Java RMI.</p> Signup and view all the answers

What is a disadvantage of an OO interface?

<p>More complex deployment.</p> Signup and view all the answers

What is the advantage of web presentation?

<p>No software to install, common user interface and universal access.</p> Signup and view all the answers

What is a script when refering to web presentation?

<p>Program with HTTP processing capabilities, HTML string as output.</p> Signup and view all the answers

What is server page when refering to web presentation?

<p>HTML + code template.</p> Signup and view all the answers

What web presentation pattern can be applied to control the processing of requests?

<p>Model View Controller.</p> Signup and view all the answers

How many stages are there applying Transform View and Template View?

<p>One.</p> Signup and view all the answers

Name three patterns for views?

<p>Transform View, Template View and Two Step View.</p> Signup and view all the answers

What is Template View?

<p>Page structure defines presentation, markers to include executable code for dynamic content.</p> Signup and view all the answers

What is Transform View?

<p>Based on transformation language (eg. XSLT for XML) data.</p> Signup and view all the answers

What is the 2nd decision in the number of stages of the View pattern?

<p>Number of stages of the view pattern (1 or 2).</p> Signup and view all the answers

Give a feature of the Two Steps View?

<p>Only one second step for the entire application.</p> Signup and view all the answers

What does a Front Controller do?

<p>Isolates the responsibilities to process and serve HTTP requests and to decide what to do with them.</p> Signup and view all the answers

What is the problem when mapping to relational databases?

<p>Store objects in relational databases.</p> Signup and view all the answers

Name four RDB Mapping Architectural Patterns?

<p>Row Data Gateway, Table Data Gateway, Active Record, Data Mapper.</p> Signup and view all the answers

What is the basic pattern for Row Data Gateway and Table Data Gateway?

<p>Gateway.</p> Signup and view all the answers

Outline one of the database concurrency issues?

<p>Avoid changing objects in DB while loaded.</p> Signup and view all the answers

Mapping classes encapsulate SQL for object-relational mapping. Give an example?

<p>Search methods encapsulate SQL &quot;SELECT&quot; command.</p> Signup and view all the answers

What should you do when reading a foreign key?

<p>If not yet in the Identity Map, load object from DB using key.</p> Signup and view all the answers

What should you do when storing object?

<p>References are replaced by the referenced entity Identity Field.</p> Signup and view all the answers

When saving a collection what should you do?

<p>Store each object in it with foreign key pointing to the object keeping the collection.</p> Signup and view all the answers

Name three mechanisms to store relational databases without inheritance mechanism?

<p>Single Table Inheritance, Concrete Table Inheritance and Class Table Inheritance.</p> Signup and view all the answers

What does Metadata Mapping facilitate?

<p>The reuse of mapping tools.</p> Signup and view all the answers

Give two problems related to Concurrency?

<p>Lost updates and Inconsistent readings.</p> Signup and view all the answers

What is a potential problem that Concurrency can introduce?

<p>Lost updates.</p> Signup and view all the answers

Name the interaction Contexts?

<p>Request and Session.</p> Signup and view all the answers

What are the 3 processing contexts?

<p>Process, Thread and DB Access context.</p> Signup and view all the answers

What is the source of concurrency problems?

<p>More than one process or thread accessing the same data.</p> Signup and view all the answers

Name two measures of concurrency control?

<p>Optimistic or pessimistic.</p> Signup and view all the answers

Outline Optimistic locking?

<p>Focus on detecting conflict.</p> Signup and view all the answers

With regards to concurrency when should you Prefer Optimistic?

<p>When conflicts rare or consequences not critical, higher degree of concurrency.</p> Signup and view all the answers

With regards to concurrency when should you Prefer Pessimist?

<p>When big risk of conflicts or they are critical.</p> Signup and view all the answers

How can Pessimistic Lock lead to deadlocks?

<p>Two users editing different files, to complete their work they need to edit the files blocked by the other user.</p> Signup and view all the answers

Name three options to avoid deadlocks?

<p>Detect deadlock and break it by selecting a victim, Locks with expiry time and All locks obtained at the beginning of user work session.</p> Signup and view all the answers

What properties does the text describe in a Transaction?

<p>Atomicity, consistency, isolation, and persistence.</p> Signup and view all the answers

Name the two types of Transaction?

<p>System Transaction and Business Transaction.</p> Signup and view all the answers

What needs to be kept track of with regards to Business Transactions?

<p>Changes. For instance with Domain Model and Unit of Work.</p> Signup and view all the answers

Name two Concurrency patterns discussed in the text?

<p>Optimistic Offline Lock and Pessimistic Offline Lock.</p> Signup and view all the answers

In Distributed Applications, what happens at implementation?

<p>Objects from application design become separate components.</p> Signup and view all the answers

What should you do with Distributed objects to improve performance?

<p>Maximize distribution degree but with efficiency problems.</p> Signup and view all the answers

What should you Differentiate for callable objects?

<p>Local and remote interfaces</p> Signup and view all the answers

What type of interface provides complex functionality and minimizes number of calls?

<p>Remote.</p> Signup and view all the answers

What type of interface has many methods with simple functionality?

<p>Local.</p> Signup and view all the answers

Name the two Distributed Objects Patterns?

<p>Remote Facade and Data Transfer Object.</p> Signup and view all the answers

What is a Remote Facade?

<p>Groups methods to be called remotely, remote interface. Build on top of simpler local methods.</p> Signup and view all the answers

What is a Data Transfer Object?

<p>For remote calls that receive or return objects, simplified version of local object that reduces amount of data sent.</p> Signup and view all the answers

Name the database options when selecting the Domain Layer?

<p>Transaction Script, Table Module and Domain Model.</p> Signup and view all the answers

Which database option depends on Row Data Gateway or Table Data Gateway if platform implements Record Set?

<p>Transaction Script.</p> Signup and view all the answers

Flashcards

Objective of Enterprise Architecture

Structuring business applications, especially those operating through several layers of processing.

Architecture Definition

The main parts of an application and how they connect.

Architectural Patterns

Important decisions about the parts of architecture.

Design Patterns

Helps realize that architecture.

Signup and view all the flashcards

Layered Architecture

Decompose a complex problem.

Signup and view all the flashcards

Layered Architecture Dependency

The lower layer is unaware of the top layer but the top layer uses services defined by the bottom one.

Signup and view all the flashcards

Layered Architecture Benefit

Only needs to know the first layer below, independently from others.

Signup and view all the flashcards

Presentation Layer

The logic of user-application interaction.

Signup and view all the flashcards

Data Sources Layer

Communication with systems that provide data.

Signup and view all the flashcards

Domain Logic Layer

Application-specific functionality.

Signup and view all the flashcards

Transaction Script

Simplest domain logic pattern where a procedure receives input parameters.

Signup and view all the flashcards

Pattern

Describes a common problem and guidelines to solve it.

Signup and view all the flashcards

Domain Model

Pattern based on the use of objects.

Signup and view all the flashcards

Table Module

Designed to operate with pattern Record Set.

Signup and view all the flashcards

Web Presentation

User interfaces based on web browsers.

Signup and view all the flashcards

Remote Facade

Groups methods to be called remotely; a remote interface.

Signup and view all the flashcards

Data Transfer Object

Simplified version of local object that reduces amount of data sent for remote calls.

Signup and view all the flashcards

Controller Function

The receipt of HTTP requests.

Signup and view all the flashcards

View Patterns

Transform View, Template View and Two Step View

Signup and view all the flashcards

Template View

Defines presentation, markers include executable code for content.

Signup and view all the flashcards

Study Notes

  • Patterns of Enterprise Software Architecture address software architecture patterns.

Introduction

  • Structuring business applications is a key objective.
  • Architecture includes the main application parts and their connections.
  • Architectural patterns involve important decisions about these components
  • Design patterns assist in realizing the architecture.

Sample Business Applications

  • Online Store (B2C) features many users, simple business logic for orders, price calculations, and a generic web interface.
  • It uses a database for orders and inventory
  • Processing house renting features few users and complex business logic for bills, overdrafts, and contract validation.
  • It offers a complex user interface and database integrated with external packages for asset valuation and pricing
  • Small company expenses management is scalable for future growth and integrates with other applications

Patterns

  • A pattern describes a common problem and provides guidelines to solve it

Layered Architecture

  • Layered Architecture helps decompose complex problems.
  • The top layer uses services from the bottom layer, but the bottom layer is unaware of the top one
  • The bottom layer typically hide ones below to upper levels.
  • Benefits include needing to know only the layer below, independent replacement of layers, minimized dependencies, and layer reuse
  • Disadvantages include the risk of cascading changes, reduced performance, and difficulty in deciding layer functionality

3-Layer Architecture

  • Presentation layer is the user-application interaction logic using command line, menus, rich client, or HTML
  • Data Sources layer communicates with systems providing data like transaction monitors, legacy systems, or databases
  • Domain Logic is application-specific functionality for validating tickets, generating invoices, or computing problems

Layer Execution

  • Layer separation is useful even on a single computer
  • Everything can be managed on the server with HTML presentation for instance
  • Client-side can offer better responsiveness and offline operation with an installable client application (Applet, App, etc.)

Transaction Script

  • Transaction Script is a simple domain logic pattern where a procedure receives parameters from presentation, processes them, stores/retrieves data, invokes other systems, and responds with data
  • It works well with simple data and has obvious transaction limits, but is too simple for complex domain logics which require the Domain Model Pattern

Transaction Script Example

  • An online store uses Transaction Scripts to add products to cart, checkout, and check order status

Domain Model

  • Domain Model is a pattern based on the use of objects, suitable for complex domains
  • The more complex the domain, the more difficult is the mapping to relational DBs

Table Module

  • Table Module is an alternative, designed to operate with a Record Set (DB query result)
  • It is a compromise between Transaction Script and Domain Model (Domain structured with tables)
  • Table Module misses inheritance of OO patterns and is ideal for technologies like .NET

Remote Interfaces to Domain Logic

  • HTTP Interfaces through a browser or web service using HTML, JSON, XML formats are nearly universal and easy to deploy
  • The disadvantage is a less explicit interface specification via XML Schema or API documents
  • OO interfaces like CORBA, ActiveX, or Java RMI have explicit interface specifications with methods and parameters but may be complex to configure

Web Presentation

  • Web Presentation enables user interfaces based on web browsers offering no software installation, a common UI and universal access
  • A Web Server interprets URLs and passes control to the corresponding web application
  • Main structural elements include scripts with HTTP processing and server pages with HTML templates
  • Model View Controller (MVC) pattern applies: a controller receives the HTTP request, redirects to the appropriate model object, queries data sources, and the view receives the response using HTTP session object and displays it

View Patterns

  • Three patterns for views are Transform View, Template View, and Two Step View
  • Transform and Template View have one stage, Two Step View has two stages applying to either Transform or Template View

Template View

  • With Template View page structure defines presentation with markers for dynamic code, typically on server pages.
  • Template View offers easy development.
  • The code can be messy and harder to maintain

Transform View

  • Transform View using languages like XSLT to transform XML data generated from the model
  • With Transform View, Controller selects and applies the transformation to XML from the model
  • It is adaptable to formats or devices, but complex

View Pattern Stages

  • A view pattern can have one or two stages.
  • 1 Stage: each screen is a view component, Template or Transform View
  • 2 Stages: e.g Two Steps View pattern. It is the first step producing logical display and second one final display, HTML presentation.

Two Steps View

  • One first step for each display, only one second step for the entire application
  • Decisions can be centralized facilitating changes and is appropriate when different screens share basic design
  • Introduces more complexity

Controller Patterns

  • Page Controller uses a Controller object for each page or action.
  • Front Controller isolates responsibilities to process and serve HTTP requests
  • Centralizes request management by receiving all requests and creating secondary objects

Mapping to Relational DB

  • Mapping to Relational DB is challenging because it stores objects in relational databases with different data structures to those in memory
  • Alternatives include Object DBs which are risky as they aren't as developed

RDB Architectural Patterns

  • Row Data Gateway, Table Data Gateway, Active Record, and Data Mapper map to relational databases

Gateway Pattern

  • It is a basic pattern for Row and Table Data Gateways, mapping DB tables to in-memory classes with a field per DB column, containing all mapping code not domain logic.

Patterns Based on Gateway

  • The choice is between Row and Table Data Gateways
  • Table Data Gateway is easier if the technology supports the Record Set data recovery pattern
  • Row Data Gateway works best otherwise
  • An object is used for each record

Active Record Pattern

  • Appropriate for when the domain model is similar to database schema.
  • Combining the Gateway with the domain object in one class, includes database access and business logic.
  • Separating these responsibilities is recommended

Data Mapper Pattern

  • More complex but more flexible than Active Record, with domain objects independent from DB schema
  • Is more complex, it is possible to reuse Object-Relational Mapping tools for complex mappings

Concurrence

  • Objects must be loaded/saved and changes tracked, guaranteeing persistence while avoiding object changes in the DB while loaded

Unit of Work

  • With Unit of Work loaded and modified objects are registered, and updates are managed to the database
  • In this case the domain layer decides when to read and write
  • Unit of Work pulls this behavior to a specific object.

Data Reading

  • Mapping classes encapsulate SQL for object-relational mapping, e.g search methods and SQL "SELECT" commands
  • Identity Map controls what is read
  • Identity Map is also maintained in the Unit of Work object

Mapping Data Structures

  • Mapping domain model objects to relational DB data has problems
  • Relational DBs use foreign keys instead of object references
  • Collections use one DB value per field
  • Identity Field keeps track of the object's identify and helps mapping between objects and relational DB keys

Data Mapping Structures

  • When reading a foreign key, and if it is not yet in the Identity Map, load object from DB using key.
  • When storing object, references are replaced by the referenced entity Identity Field
  • When reading or saving a collection, retrieve or store rows linked to the identifier of the object that includes the collection

Inheritance

  • Relational databases commonly lack an inheritance mechanism
  • Three Options: Single Table Inheritance, Concrete Table Inheritance or Class Table Inheritance.

Inheritance (Options)

  • Single Table Inheritance: A table to store all classes
  • Concrete Table Inheritance: A table for each concrete class
  • Class Table Inheritance: One table for per class, stored fields just in the corresponding table

Inheritance (Tradeoffs)

  • Choices involve duplication, flexibility and access speed tradeoffs.
  • Class Table Inheritance avoids duplication, but is inefficient, needs many JOINS and is very flexible
  • Concrete Table Inheritance has some duplication and less flexible as domain changes affect many tables but is more efficient because it uses less JOINS
  • Single Table Inheritance has a lot of duplication, is affected by each domain change, but is efficient and uses no JOINS

Mapping Metadata

  • Metadata Mapping facilitates reuse of mapping tools, informs the mapping process, how Columns correspond to object fields, and facilitates generating the mapping code
  • They are commonly used in commercial tools.

Concurrence

  • Multiple processes or threads manipulate the data
  • Within a transaction, Request/Response prevents currency issues
  • The issue happens in interactions among different transactions
  • Multiple request/responses lead to concurrency control spanning multiple transactions, interaction involving, called offline concurrency

Concurrency Problems

  • Lost Updates: User A edits, then user B edits the same file. B ends and then A, overwriting B's version
  • Inconsistent readings: data readings are correct separately but if simultaneously will produce incorrect results
  • These problems can be avoided with concurrency control mechanisms

Execution Contexts

  • Interaction contexts involve Requests from outside the system, sessions of related client-server interactions, and request/responses between logging in and logging out.
  • Processing contexts include processes (heavyweight, isolating data), threads (lightweight, sharing memory), and DB Access context, coordinate requests.

Isolation

  • Isolation is a mechanism to avoid concurrency problems resulting from multiple processes or threads accessing the same data by coordinating access
  • Operating system memory access mechanisms or file locks can be used

Concurrency Controls

  • Shared data means coordinate concurrent access
  • Measures of concurrency control is pessimistic and optimistic.
  • In the "2 users edit simultaneously" scenario, is used each of them

Concurrency Controls - optimistic locking

  • Focus on detecting conflict
  1. Both users copy and edit file freely
  2. When #2 tries to save, conflict detection occurs
  3. User #2 can't save, options: discard, merge, new file,...

Concurrency Controls - pessimistic locking

  • Focuses on preventing conflict
  1. User#1 starts and the file is blocked for others
  2. No one else can edit until #1 saves

Concurrency Control Preferences

  • Optimize when there is rare consequences/conflicts, higher concurrent degrees.
  • Pessimist when high risk due to conflicts.

Inconsistent readings

  • Pessimistic locks will avoid.
  • Reading requires read lock (shared by readers).
  • Writing requires write lock (exclusive).
  • Many users can read concurrently if someone is reading and no one can write.
  • The requested writing in Write block - no one can read/write.

Deadlock

  • Is a Pessimistic locking problem. Deadlocks:
  • Example: 2 users editing, completing work, needed files.
  • Options to avoid: -Deadlock detection. Can brake it. A victim will release all locks. -All Locks with expiry. -All locks obtained at user work session's beginning. Order blocks if desired.

Transactions

  • Is the general concurrency control implemented in enterprise APPs.
  • Is a certain amount of actions, with start and ending-points.
  • Applied to DBs, printers queues, message-queues etc.
  • A better performance if the amount of single request's transactions is small.

Transaction Properties

  • Atomicity: complete all actions, or none.

  • consistency: consistent resourced state during beginning and end.

  • Isolation: The full result not visible as successful completed is.

  • Persistence: successful results as full stored.

Business Transactions and System Transactions

  • System: the SQL commands to close transactions,

  • Business: Online system. A: selected account. B: payment made. C: OK Clicked.

Business Transactions Issues

  • Problems with concurrency to face.
  • Fitting Business between system ones.
  • More requests.
  • If time between requests; session locks for the system and prevent action.

Business Transactions (changes in sessions)

Atomicity and persistence: changing depends on agree of user.

  • Keep tracks of change if necessary.

  • Maintain consistency: application is responsible.

  • Isolation: no one overwrite other for the session done.

Offline Concurrency Issues - resolution

  • Concurrency request more and are patterns.
  • Optimal Offline lock. Business lock: optimistic. -More easy but detectable change.
  • Prevent of more easy. Loss occurs at the end.

Distribution Strategies (Contents)

  • Distribute for APPs, with communication with remote objects, Objects can be design APP during implementation with extra components. Everyone processed at separate nodes.

Local and Remote Interface

  • Distributed objects - the level of distribution - the efficiency is an problem,.

  • A call from a machine is more slower the 1 at one machine.

  • Differentiate to know the callable objects local and remote.

  • For local Interface: calls are lot with simple functionality and is not a problem. (e.g: the 3 addresses needed etc..)

  • For Remo Interface: call for certain action/functionality is provided in low calls and more efficient. Less calls. If flexible... . (e.g: One address Method.)

  • Avoid recommended calls and objects if is possible.

  • Alternative: the horizontal scalability ( computer replicas APPs a lot to serve the customers).

  • Objects into single Machine to avoid issues.

  • Multiple copied Machines to be executed during the APP using to everyone with that kind of action.

Distribution scenarios

  • Remote calls sometimes .Client to server - with two machines. .DB to APP - Issues for avoid - data share synchronization with improve performance. Use SQL -to minimize and is prepare everything

Distributed object pattens

  • "Remove facade" called remotely from an interface and builds above simpler in
  • the end ( local method )
  • Data with transfer to avoid more amount data and with a simple look is a local object.
  • To return objects to simple call ( remote )

Putting into practice

  • These patterns guideline to the dev business APP.
  • Layers
  • Platform's options

Domain Layer

  • The following can be used at layer:
  1. Script transaction: procedure + simple.
  2. Domain: Difficult to relation DB(complex/ easy). 3.Table to module. Medium with complex DB in DB

Data Layer

  • Depends on the choice of Domain: 1.DB/Trans Script( with a row table /DATA Gateway
  • Problems minimize.
  • Data load: to edit the solution is: offline lock ( Optimal and Apply)

Data layers

  • table module with table data-gateway module if is possible.
  • Records with Unit of Work for more control.

Data: layer of Models

  • model depending on the complexity of Models or Domain
  • for more complex extend a mapping and use tools of Unit -Work /DB

Presentation Layer

  • Client use APP web in a client and Server.
  • The server's side (APP simple templates,JSP )
  • The client's side (The API sends and data can be JSON)
  • More View and controller with Model

Layer-Controller

  • A page, in doc is simple(for simple the page and the client site.)
  • Front is when more actions are wanted.

Presentation :Layer -Views

  • templates (more client and side but servers 1).
  • Transform is when the XML input is more simple
  • Two complex for differents - inputs.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Software Architecture Fundamentals
16 questions
MVC and MVVM Patterns in Software Design
16 questions
Enterprise Software Architecture Patterns
48 questions
Use Quizgecko on...
Browser
Browser