Slide 1

Slide 1 text

Software Architecture Patterns Ulugbek Miniyarov Chief Software Architect @ ENUYGUN

Slide 2

Slide 2 text

Purpose of using Patterns - Proven layout in different business logic - Ease of use among multiple developers - Keep things in order

Slide 3

Slide 3 text

Agenda - Service-Oriented Architecture - Domain Driven Development - Command Query Responsibility Segregation - Event Source

Slide 4

Slide 4 text

Service-Oriented Architecture - Separation of Service Interface from underlying implementation of Business Logic (Loose Coupling) - Promotes service reuse through Discoverable and Self-describing services - Services are coarse-grained, composable and rely on standards based infrastructure (RESTful, Web Service, WebRPC, XML PRC, gRPC)

Slide 5

Slide 5 text

Service-Oriented Architecture Pros: - Easily reuse codes and recompose services - Easy to start for new developers - Easy for PMs to manage Cons: - Hard to deploy dependent services - Can be messy with lots of services - Service discoverability and meshing can be painful

Slide 6

Slide 6 text

Domain-Driven Development (DDD) Domain-Driven Design, or DDD, is an approach for building high-quality software that meets core business objectives. It emphasizes collaboration among domain experts, developers, UX designers and other disciplines to create a domain model that reflects the needs of the business. DDD Concepts: - Ubiquitous Language (essential for Domain Experts, Developers, UX Designers, Testers and others) - Domain Model (essential for Domain Experts, Developers, UX Designers, Testers and others) - Bounded Context (For developers) - Command-Query Separation (For developers) - Layered Architecture (For developers) - Domain Layer (For developers)

Slide 7

Slide 7 text

DDD - Ubiquitous Language - Developer are developers -> always thinks in terms of codes, classes, methods - Domain experts -> knows how business logic works - To overcome this difference in communication we build common language on domain called: Ubiquitous Language

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

DDD - Domain Model - Entity - Value Objects - Entities and Value Object Relations

Slide 12

Slide 12 text

DDD - Bounded Context - Large projects can contain lots of concepts: Account, Order, Order Execution, Payment - Large domains can be divided for simpler management: Domain models are bounded within contexts - No magical way to divide, group together models that are related

Slide 13

Slide 13 text

DDD - Command Query Separation - Simplify Designs - Improve Performance - Eventually Consistent - Details in Command-Query Responsibility Segregation

Slide 14

Slide 14 text

DDD - Layered Architecture - Separation of Concerns - Easer to Maintain - Multiple teams can work altogether

Slide 15

Slide 15 text

DDD - Domain Layer - Entities - Value Objects - Domain Services - Domain Events - Aggregates

Slide 16

Slide 16 text

DDD - Summary ● Use Domain-Driven Design to collaborate among all project disciplines and clearly understand the business requirements. ● Establish a Ubiquitous Language to discuss domain related concepts. ● Use Bounded Contexts to break down complex domains into manageable parts. ● Use Command-Query Separation to simplify your designs and improve performance. ● Implement a Layered Architecture to focus on different aspects of the application.

Slide 17

Slide 17 text

Command Query Responsibility Segregation Command Query Responsibility Segregation (CQRS), comes from CQS (Command Query Separation) introduced by Bertrand Meyer in Object Oriented Software Construction. - Every method should be a Command or Query - Command: States a change - Query: Returns a value

Slide 18

Slide 18 text

CQRS

Slide 19

Slide 19 text

Event Source - Easy to understand events in a domain - Event history is kept immutable - Can replay events to mimic user actions

Slide 20

Slide 20 text

CQRS + ES Pros: - Work with large teams - Simpler business logic - Scalable thanks to eventually consistent architecture Cons: - Overkill CRUD operations - More moving parts - Event sources can be hard for analyts and BI unit

Slide 21

Slide 21 text

CAP Theorem in CQRS Computer scientist Eric Brewer, states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees: Consistency: Every read receives the most recent write or an error Availability: Every request receives a (non-error) response – without the guarantee that it contains the most recent write Partition Tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes

Slide 22

Slide 22 text

PACELC (extension of CAP) In theoretical computer science, the PACELC theorem is an extension to the CAP theorem. It states that in case of network partitioning (P) in a distributed computer system, one has to choose between availability (A) and consistency (C) (as per the CAP theorem), but else (E), even when the system is running normally in the absence of partitions, one has to choose between latency (L) and consistency (C).

Slide 23

Slide 23 text

Eventually Consistent vs Strongly Consistent Eventually Consistent: offers low latency but may reply to read requests with stale data since all nodes of the database may not have the updated data. Strongly Consistent: offers up-to-date data but at the cost of high latency.

Slide 24

Slide 24 text

Thank you. References: - Mastering PHP Design Patterns Book - ArchFirst (https://archfirst.org/) - CQRS (https://en.wikipedia.org/wiki/Command%E2%80%93query_separation) - CAP Theorem (https://en.wikipedia.org/wiki/CAP_theorem) - PACELC Theorem (https://en.wikipedia.org/wiki/PACELC_theorem)