SlideShare ist ein Scribd-Unternehmen logo
1 von 99
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Universidad de Oviedo 
Software Architecture 
Part II. Architecture classifications 
3 - Modularity 
2014 Jose Emilio Labra Gayo
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modularity
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Big Ball of Mud 
Hierarchical decomposition 
Dependencies 
Generalization 
Layers 
Aspect Oriented decomposition 
Domain based decomposition
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Big Ball of Mud 
Big Ball of Mud 
Described by Foote & Yoder, 1997 
Elements 
Lots of entities intertwined 
Constraints 
None
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Big Ball of Mud 
Advantages 
Quick-start 
It is possible to start without defining an architecture 
Solve problems on demand 
Cheap solution for short-term projects 
It can be OK for some projects
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Big Ball of Mud 
Problems 
High Maintenance costs 
Low flexibility from a given point 
At start it can be very flexible 
After some time, a change can be dramatic 
Inertia 
When the system becomes a Big Ball of Mud it is very 
difficult to convert it to another thing 
A few prestigious developers know where to touch 
Clean developers run away from these systems
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Big Ball of Mud 
Some reasons 
Throwaway code: 
You need an immediate fix for a small problem, a 
quick prototype or proof of concept 
When it is good enough, you ship it 
Piecemeal growth 
Cut/Paste reuse 
Bad code is reproduced in lots of places 
Anti-patterns 
Bad smells 
Code/Architecture
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modular decomposition 
Elements 
Modules 
Each module has an interface and a body 
Relationships "is part of" between modules
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modular decomposition 
Definitions 
Module: 
Piece of software the offers a set of responsabilities 
It makes sense at development time (no runtime) 
Separates interface from body 
Interface 
Describes what is a module 
How to use it  Contract 
Body 
How it is implemented 
Interface 
Body 
(Implementation) 
Module
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modular decomposition 
Quality attributes 
Commnication 
Communicates the general aspect of the system 
Minimizes complexity 
A module only exposes an interface 
Extensibility, maintenance 
Facilitates changes and extensions 
Localized functionality 
Reusability 
Modules can be used in other contexts 
Product lines 
Independence 
Modules can be developed by different teams
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modular decomposition 
Challenges 
Bad decomposition can augment complexity 
Decission: Develop vs buy 
COTS modules 
Dependency management 
Third parties modules can affect evolution 
Team organization 
Modular decomposition can affect team development 
and organization
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modular decomposition 
Constraints 
No cycles are allowed 
A module can only have one parent 
System 
Subsystem 
A 
Subsystem 
B 
Subsystem 
B1 
Subsystem 
B2 
Subsystem 
A2 
Subsystem 
A1
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modular decomposition 
Some recommendations 
High cohesion 
Low coupling 
SOLID principles 
Demeter's Law 
Fluid interfaces
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modularity recommendations 
High cohesion 
Cohesion = Coherence of a module 
Each module must solve one functionality 
DRY (Don't Repeat Yourself) Principle 
Intention must be declared in only one place 
It should be possible to test each module separately
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modularity recommendations 
Low coupling 
Coupling = Interaction degree between modules 
Low coupling  Improves modifiability 
Independent deployment of each module 
Stability against changes in other modules
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Modularity recommendations 
SOLID principles 
They can be used to define clases and modules 
SRP (Single Responsability Principle) 
OCP (Open-Closed Principle) 
LSP (Liskov Substitution Principle) 
ISP (Interface Seggregation Principle) 
DIP (Dependency Injection Principle)
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(S)ingle Responsibility 
A module must have one responsibility 
Responsibility = A reason to change 
No more than one reason to change a module 
Otherwise, responsibilities are mixed and coupling increases 
vs
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(S)ingle Resposibility 
class Employee { 
def calculatePay(): Money = { ??? } 
def saveDB() { ??? } 
def reportWorkingHours(): String = { ??? } 
Responsible departments 
http://blog.8thlight.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html 
} 
Financial department 
Operations 
Management 
There can be multiple reasons to change the Employee class 
Solution: Separate concerns 
Gather together the things that change for the same reasons. 
Separate those things that change for different reasons.
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(O)pen/Closed principle 
Open for extension 
The module must adapt to new changes 
Change/adapt the behavior of a module 
Closed for modification 
Changes can be done without changing the module 
Without modifying source code, binaries, etc 
It should be easy to change the behaviour of a module without 
changing the source code of that module 
http://blog.8thlight.com/uncle-bob/2013/03/08/AnOpenAndClosedCase.html
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(O)pen/Closed principle 
Example: 
class SelectProducts { 
def filterByColor(products: List[Product], 
color: Color): List[Product] = { 
??? 
} 
If you need to filter by height, you need to change the source code 
Another solution: 
def filter(products: List[Product], 
predicate: Product => Boolean): List[Product] = { 
??? 
} 
Now, it is possible to filter by any predicate without changing the module
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(L)iskov Substitution 
Subtypes must follow supertypes contract 
A type B is a subtype of A when: 
xA, if there is a property Q such that Q(x) 
then yB, Q(y) 
A 
B 
"Derived types must be completely substitutable by their base types" 
Common mistakes: 
Inherit and modify behaviour of base class 
Add functionality to supertypes that subtypes don't follow
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(L)iskov Substitution 
Duck 
haceCuak 
tieneFormaPato 
respira) 
doCuak 
hasShapeDuck 
breathes) 
X 
Example 
DuckInPark RubberDucky
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(I)nterface Segregation 
Clients must not depend on unused methods 
Better to have small and cohesive interfaces 
Otherwise  non desired dependencies 
If a module depends on non-used functionalities and these 
functionalities change, the module can be effected 
ClientA 
ClientB 
InterfaceA 
methodA1 
methodA2 
InterfaceB 
methodB1 
methodB2 
Service 
mehtodA1 
methodA2 
methodB1 
methodB2 
... 
<<uses>> 
<<uses>>
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(D)ependency Inversion 
Invert conventional dependencies 
High-level modules should not depend on low-level modules 
Both should depend on abstractions 
Abstractions should not depend upon details. 
Details should depend upon abstractions 
Can be accomplished using dependency injection or 
several patterns like plugin, service locator, etc. 
http://www.objectmentor.com/resources/articles/dip.pdf 
http://martinfowler.com/articles/dipInTheWild.html
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
(D)ependency Inversion 
Lowers coupling 
Facilitates unit testing 
Substituting low level modules by test doubles 
Related with: 
Dependency injection and Inversion of Control 
Frameworks: Spring, Guice, etc.
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Demeter's Law 
Principle of less knowledge 
Modules only communicates with near modules 
Goal: low coupling 
Lower number of invoked methods 
Tradeoff solution 
It is not always possitive 
It can augment number of methods in modules 
Symptoms of bad design: 
Using more than one dot... 
a.b.method(...)  

Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Fluent APIs 
Improve readability and usability of interfaces 
Advantages 
Can lead to domain specific languages 
Auto-complete facilities by IDEs
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Fluent APIs 
Methods that modify return the same object 
class Product { 
... 
public Product setPrice(double price) { 
this.price = price; 
return this; 
}; 
Several methods can be chained 
Example: 
Product p = new Product(). 
setName("Pepe"). 
setPrice(23); 
It does not contradict Demeter's Law because it acts on the same object
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Other modularity recommendations 
Facilitate external configuration of a module 
Create an external configuration module 
Create a default implementation 
GRASP Principles 
General Responsibility Assignment Software Patterns
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Module Systems 
In Java: 
OSGi 
Module = bundle 
Controls encapsulation 
It allows to install, start, stop and deinstall modules 
during runtime 
Used in Eclipse 
Modules = Micro-services 
Several implementations: Apache Felix, Equinox 
Jigsaw Project (Java 9) 
In .Net: Assemblies
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Module Dependencies 
Relationship "uses" 
One module uses (depends on) other module
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Module Dependencies 
Elementes 
Modules 
Relationships "depends on" between modules 
Constraints 
Module M1 depends on M2 if correct behavior of M1 
depends on correct behavior of M2
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Module Dependencies 
Advantages: 
Incremental development 
Implement part of the functionality 
Debugging, testing 
Facilitates impact analysis upon changes
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Module dependencies 
Challenges 
Dependency management 
Avoid cyclic dependencies 
Modules that depend on a lot of modules 
Limits incremental development 
Bad separation of concerns
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Generalization/specialization 
Elements 
Modules 
Relationships (is-a) between 
modules 
Constraints: 
Parent is more general than 
children
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Generalization/Specialization 
Advantages 
Facilitates extensión and architecture evolution 
Notion of inheritance in OO design 
Captures common parts with variations = children 
Change and local variation 
Reuse
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Generalization/Specialization 
Challenges 
Complexity to identify relationships 
Exceptions 
Multiple inheritance implications
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Generalization/Specialization 
Applications 
Application frameworks
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Divide software modules in layers 
Order between layers 
Each layer exposes an interface that can be used 
by higher layers 
Layer N 
Layer N - 1 
. . . 
Layer 1
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Elements 
Layer: set of functionalities exposed through an 
interface at a level N 
Order relationship between layers 
Layer N 
Layer N - 1 
. . . 
Layer 1
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Capas 
Constraints 
Each software block belongs to one layer 
There are at least 2 layers 
A layer can be: 
Client: consumes services from below layers 
Server: provides services to upper layers 
2 variants: 
Strict: Layer N uses only functionality from layer N-1 
Lax: Layer N uses functionalities from layers 1 to N - 1 
No cycles
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Example 
User interface 
Application 
Domain 
Infrastructure
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Layers ≠ Modules 
A layer can be a module... 
...but modules can be decomposed in other modules 
(layers can't) 
Dividing a layer, it is posible to obtain modules
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Layers ≠ Tiers 
Layer: conceptual separation Tier: physical separation 
Presentation 
Business 
Data 
3-Layers 
External 
Applications 
Legacy 
systems 
Database 
Business 
logic 
Firewall 
Thin 
client 
RIA 
Presentation Business Data 
3-tiers
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Advantages 
Separates different abstraction levels 
Loose coupling: independent evolution of each layer 
It is possible to offer different implementations of a 
layer that keep the same interface 
Reusability 
Changes in a layer affects only to the layer that is 
above or below it. 
It is possible to create standard interfaces as libraries 
or application frameworks
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Challenges 
It is notalways possible to apply it 
Not always do we have different abstraction levels 
Performance 
Access through layers can slow the system 
Shortcuts 
Sometimes, it may be necessary to skip some layers
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Example: Android
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Layers 
Variants: 
Virtual machines, APIs 
3-layers, N-layers
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Virtual machine 
Virtual machine = Opaque layer 
Hides a specific OS implementation 
One can only get Access through the public API 
Program 
API 
Virtual Machine 
Operating 
System
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Virtual machines 
Advantages 
Portability 
Simplifies software development 
Higher-level programming 
Facilitates emulation 
Challenges 
Performance 
JIT techniques 
Computational overload generated by the new layer
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Virtual machine 
Applications 
Programming languages 
JVM: Java Virtual Machine 
CLR .Net 
Emulation software
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
3-layers (N-layers) 
Conceptual decomposition 
Presentation 
Business logic 
Data 
Presentation 
Business 
Data
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Aspects: 
Modules that implement crosscutting features 
Presentation 
Business 
Data 
Security 
Monitorization 
Logging 
Aspects 
Interntionalization
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Elements: 
Crosscutting concern 
Functionality that is required in several places of an 
application 
Examples: logging, monitorization, i18n, security,... 
Generate tangling code 
Aspect. Captures a crosscutting-concern in a module
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Example: Book flight seats 
Several methods to do the booking: 
Book a seat 
Book a row 
Book two consecutive seats 
... 
En each method: 
Check permission (security) 
Concurrence (block seats) 
Transactions (do the whole operation in one step) 
Create a log of the operation 
...
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Traditional solution 
class Plane { 
void bookSeat(int row, int number) { 
// ... Log book petition 
// ... check autorization 
// ... check free seat 
// ... block seat 
// ... start transition 
// ... log start of operation 
// ... Do booking 
// ... Log end of operation 
// ... Execute transaction or rollback 
// ... Unblock 
} 
... 
public void bookRow(int row) { 
// ... More or less the same!!!! 
... 
Concurrence 
Logging 
Security 
Transaction
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Structure 
Core 
Application 
Logic 
Crosscutting 
Crosscutting 
Crosscutting 
concern 
concern 
concern 
(aspect) 
Aspect 
compiler 
(weaving) 
Final 
application
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Definitions 
Join point: Point where an aspect 
can be inserted 
Aspect: 
Contains: 
Advice: defines the job of the aspect 
Pointcut: where the aspect will be 
introduced 
It can match one or more join points 
Join points 
Pointcut 
Running 
Program 
Advice
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Aspect example in @Aspectj 
@Aspect 
public class Security { 
@Pointcut("execution(* org.example.Flight.book*(..))") 
public void safeAccess() {} 
@Before("safeAccess()") 
public void authenticate(JoinPoint joinPoint) { 
// Does the authentication 
} 
} 
Methods book* 
It is executed before 
to invoke those 
methods 
It can Access to 
information of the 
joinPoint
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Constraints: 
An aspect can affect one or more traditional modules 
An aspect captures all the definitions of a 
crosscutting-concern 
The aspect must be inserted in the code 
Tools for automatic introduction
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Advantages 
Simpler design 
Basic application is clean of crosscutting concerns 
Facilitates system modifiability and maintenance 
Crosscutting concerns are localized in a single module 
Reuse 
Crosscutting concerns can be reused in other systems
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Challenges 
External tools are needed 
Aspects compiler. Example: AspectJ 
Other tools: Spring, JBoss 
Debugging is more complex 
A bug in one aspect module can have unknown 
consequences in other modules 
Program flow is more complex 
Team development needs new skills 
Not every developer knows aspect oriented programming
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Aspect Oriented 
Applications 
AspectJ = Java extension with AOP 
Guice = Dependency injection Framework 
Spring = Enterprise framework with dependency 
injection and AOP 
Variants 
DCI (Data-Context-Interaction): It is centered in 
the identification of roles from use cases
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Domain based 
Domain driven design 
Hexagonal architecture 
Data centered 
Patterns 
CQRS 
Event sourcing 
Naked Objects
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Data model vs domain model 
Data models 
Physical: 
Data representation 
Tables, columns, keys, ... 
Logical: 
Data structure 
Entities and relationships 
Domain models 
Conceptual model of a 
domain 
Vocabulary and context 
Entities, relationships 
Behavior 
Business rules
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Domain based 
Centered on the domain and the business logic 
Goal: Anticipate and handle changes in domain 
Collaboration between developers and domain 
experts
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Domain based 
Elements 
Domain model: formed by: 
Context 
Entities 
Relationships 
Application 
Manipulates domain elements
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Domain based 
Constraints 
Domain model is a clearly identified module 
separated from other modules 
Domain centered application 
Application must adapt to domain model changes 
No topological constraints
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Domain based 
Advantages: 
Facilitates team communication 
Ubiquitous language 
Reflects domain structure 
Address domain changes 
Share and reuse models 
Reinforce data quality and consistency 
Facilitates system testing 
It is possible to create testing doubles with fake 
domain data
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Domain based 
Challenges: 
Collaboration with domain experts 
Stalled analysis phase 
It is necessary to establish context boundaries 
Technological dependency 
Avoid domain models that depend on some specific 
persistence technologies 
Synchronization 
Synchronize system with domain changes
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Domain based 
Variants 
DDD - Domain driven design 
Hexagonal style 
Data centered 
N-Layered Domain Driven Design 
Related patterns: 
CQRS (Command Query Responsibility Segregation) 
Event Sourcing 
Naked Objects
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
DDD - Domain Driven Design 
General approach to software development 
Proposed by Eric Evans (2004) 
Connect the implementation to an evolving domain 
Collaboration between technical and domain experts 
Ubiquitous language 
Common vocabulary shared by the experts and the 
development team
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
DDD - Domain Driven Design 
Elements 
Bounded context 
Specifies the boundaries of the domain 
Entities 
An object with an identity 
Value objects 
Contain attributes but no identity 
Aggregates 
Collection of objects bound together by some root entity 
Services 
External operations
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
DDD - Domain Driven Design 
Constraints 
Entities inside aggregates are only accessible 
through the root entity 
Value objects contain only attributes (immutables)
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
DDD - Domain driven design 
Advantages 
Code organization 
Identification of the main parts 
Maintenance/evolution of the system 
Facilitates refactoring 
It adapts to Behaviour Driven Development 
Team communication 
Problem space 
Domain experts 
Solution space 
Development team 
Ubiquitous language
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
DDD - Domain driven design 
Challenges 
Involve domain experts in development 
It is not always possible 
Apparent complexity 
It adds some constraints to development 
Useful for complex, non-trivial domains
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Hexagonal style 
Other names: 
ports and adapters, onion, clean, etc. 
Based on a clean Domain model 
Infrastructures and frameworks are outside 
Access through ports and adapters 
Application 
Adapter 
Adapter 
Adapter 
Adapter 
Adapter 
Domain 
model 
port 
port 
http://alistair.cockburn.us/Hexagonal+architecture 
http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html 
Adapter
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Hexagonal style 
Example 
Traditional application in layers 
Incorporates new services 
Testing DB 
Application 
Adapter UI 
DB 
MySQL 
Adapter DB2 
Adapter 
REST 
Adapter 
printer 
Adapter DB1 
External 
Application 
Domain 
Model 
API port 
data port 
DB 
MongoDB 
Adapter 
DB testing
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Hexagonal style 
Elements 
Domain model 
Represents business logic: Entities and relationships 
Plain Objects (POJOs: Plain Old Java Objects) 
Ports 
Communication interface 
It can be: User, Database 
Adapters 
One adapter by each external element 
Examples: REST, User, DB SQL, DB mock,...
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Hexagonal style 
Advantages 
Understanding 
Improves domain understanding 
Timelessness 
Less dependency on technologies and frameworks 
Adaptability (time to market) 
It is easier to adapt the application to changes in the 
domain 
Testability 
It is possible to substitute real databases by mock databases
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Hexagonal style 
Challenges 
It can be difficult to separate domain from the 
persistence system 
Lots of frameworks combine both 
Asymmetry of ports & adapters 
Not all are equal 
Active ports (user) vs passive ports (logger)
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Data centered 
Simple domains based on data 
CRUD (Create-Retrieve-Update-Delete) operations 
Advantages: 
Semi-automatic generation (scaffolding) 
Rapid development (time-to-market) 
Challenges 
Evolution to more complex domains 
Anemic domains 
Classes that only contain getters/setters 
Objects without behaviour (delegated to other layers) 
Can be like procedural programming 
Anemic Models: https://www.link-intersystems.com/blog/2011/10/01/anemic-vs-rich-domain-models/
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Domain based styles 
3 patterns related 
CQRS 
Event Sourcing 
Naked Objects
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
CQRS 
Command Query Responsibility Segregation 
Separate models in 2 parts 
Command: Does changes (updates information) 
Query: Only queries (get information) 
Application 
Model 
User 
Interface 
Data 
Base
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
CQRS 
Command Query Responsibility Segregation 
Separate models in 2 parts 
Command: Does changes (updates information) 
Query: Only queries (get information) 
Application 
Query 
User 
Interface 
Data 
Base 
Command
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
CQRS 
Advantages 
Scalability 
Optimize queries (read-only) 
Asynchronous commands 
Facilitates team decomposition and organization 
1 team for read access (queries) 
1 team for read/write access (command)
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
CQRS 
Challenges 
Hybrid operations (both query and command) 
Example: pop() in a stack 
Complexity 
For simple CRUD applications it can be too complex 
Synchronization 
Possibility of queries over non-updated data 
Applications 
Axon Framework
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Event Sourcing 
All changes to application state are stored as a 
sequence of events 
Every change is captured in an event store 
It is possible to trace and undo changes 
Write 
-------------------- -------------------- -------------------- ---------- 
Event 
store 
Event 
Driver 
Read 
snapshots
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Event Sourcing 
Elements 
Events: something that has happened, in the past 
Event store: Events are always added (append-only) 
Event driver: handles the different events 
Snapshots of aggragated state (optional) 
Write 
-------------------- -------------------- -------------------- ---------- 
Event 
store 
Event 
Driver 
Read 
snapshots
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Event Sourcing 
Advantages 
Fault tolerance 
Traceability 
Determine the state of the application at any time 
Rebuild and event-replay 
It is possible to discard an application state and re-run 
the events to rebuild a new state 
Scalability 
Append-only DB can be optimized
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Event Sourcing 
Challenges 
Event handling 
Synchronization, consistency 
Complexity of development 
It addes a new indirection level 
Resource management 
Event granularity 
Event storage grows with time 
Snapshots can be used for optimization
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Event Sourcing 
Applications 
Database systems 
Datomic 
EventStore
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Naked Objects 
Domain objects contain all business logic 
User interface = Direct representation of domain 
objects 
It can be automatically generated 
Automatic generation of: 
User interfaces 
REST APIs 
Domain 
Object 
Domain 
Object 
Domain 
Object 
persistence 
services 
remoting 
UI 
REST
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo 
Naked Objects 
Advantages 
Adaptability to domain 
Maintenance 
Challenges 
It may be difficult to adapt interface to special cases 
Applications 
Naked Objects (.Net), Apache Isis (Java)
Arquitectura del Software 
Escuela de Ingeniería Informática Universidad de Oviedo

Weitere ähnliche Inhalte

Was ist angesagt?

[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigmsIvano Malavolta
 
Oose unit 3 ppt
Oose unit 3 pptOose unit 3 ppt
Oose unit 3 pptDr VISU P
 
Learning uml 2_part_1
Learning uml 2_part_1Learning uml 2_part_1
Learning uml 2_part_1Mark Gaad
 
Oose unit 5 ppt
Oose unit 5 pptOose unit 5 ppt
Oose unit 5 pptDr VISU P
 
Oose unit 4 ppt
Oose unit 4 pptOose unit 4 ppt
Oose unit 4 pptDr VISU P
 
On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...University of l'aquila
 
COCOMO methods for software size estimation
COCOMO methods for software size estimationCOCOMO methods for software size estimation
COCOMO methods for software size estimationPramod Parajuli
 
The role of MDE in Software Architecture Descriptions
The role of MDE in Software Architecture DescriptionsThe role of MDE in Software Architecture Descriptions
The role of MDE in Software Architecture DescriptionsHenry Muccini
 
[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software Architecture[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software ArchitectureIvano Malavolta
 
Software Engineering: What is That?
Software Engineering: What is That?Software Engineering: What is That?
Software Engineering: What is That?Henry Muccini
 
Software Architecture vs design
Software Architecture vs design Software Architecture vs design
Software Architecture vs design Arslan Anwar
 
Web technologies: Model Driven Engineering
Web technologies: Model Driven EngineeringWeb technologies: Model Driven Engineering
Web technologies: Model Driven EngineeringPiero Fraternali
 
[2016/2017] Modern development paradigms
[2016/2017] Modern development paradigms [2016/2017] Modern development paradigms
[2016/2017] Modern development paradigms Ivano Malavolta
 
[2015/2016] Architectural languages
[2015/2016] Architectural languages[2015/2016] Architectural languages
[2015/2016] Architectural languagesIvano Malavolta
 
National%20 online%20examination%20system%20an%20architectural%20perspective
National%20 online%20examination%20system%20an%20architectural%20perspectiveNational%20 online%20examination%20system%20an%20architectural%20perspective
National%20 online%20examination%20system%20an%20architectural%20perspectivekalimullahmohd89
 
Introduction to ARCHITECTURAL LANGUAGES
Introduction to ARCHITECTURAL LANGUAGESIntroduction to ARCHITECTURAL LANGUAGES
Introduction to ARCHITECTURAL LANGUAGESIvano Malavolta
 
Software Architecture: views and viewpoints
Software Architecture: views and viewpointsSoftware Architecture: views and viewpoints
Software Architecture: views and viewpointsHenry Muccini
 
Model-Driven Development of Web Applications
Model-Driven Development of Web ApplicationsModel-Driven Development of Web Applications
Model-Driven Development of Web Applicationsidescitation
 

Was ist angesagt? (20)

[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms
 
Oose unit 3 ppt
Oose unit 3 pptOose unit 3 ppt
Oose unit 3 ppt
 
Arch java
Arch javaArch java
Arch java
 
Learning uml 2_part_1
Learning uml 2_part_1Learning uml 2_part_1
Learning uml 2_part_1
 
Oose unit 5 ppt
Oose unit 5 pptOose unit 5 ppt
Oose unit 5 ppt
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
 
Oose unit 4 ppt
Oose unit 4 pptOose unit 4 ppt
Oose unit 4 ppt
 
On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...
 
COCOMO methods for software size estimation
COCOMO methods for software size estimationCOCOMO methods for software size estimation
COCOMO methods for software size estimation
 
The role of MDE in Software Architecture Descriptions
The role of MDE in Software Architecture DescriptionsThe role of MDE in Software Architecture Descriptions
The role of MDE in Software Architecture Descriptions
 
[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software Architecture[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software Architecture
 
Software Engineering: What is That?
Software Engineering: What is That?Software Engineering: What is That?
Software Engineering: What is That?
 
Software Architecture vs design
Software Architecture vs design Software Architecture vs design
Software Architecture vs design
 
Web technologies: Model Driven Engineering
Web technologies: Model Driven EngineeringWeb technologies: Model Driven Engineering
Web technologies: Model Driven Engineering
 
[2016/2017] Modern development paradigms
[2016/2017] Modern development paradigms [2016/2017] Modern development paradigms
[2016/2017] Modern development paradigms
 
[2015/2016] Architectural languages
[2015/2016] Architectural languages[2015/2016] Architectural languages
[2015/2016] Architectural languages
 
National%20 online%20examination%20system%20an%20architectural%20perspective
National%20 online%20examination%20system%20an%20architectural%20perspectiveNational%20 online%20examination%20system%20an%20architectural%20perspective
National%20 online%20examination%20system%20an%20architectural%20perspective
 
Introduction to ARCHITECTURAL LANGUAGES
Introduction to ARCHITECTURAL LANGUAGESIntroduction to ARCHITECTURAL LANGUAGES
Introduction to ARCHITECTURAL LANGUAGES
 
Software Architecture: views and viewpoints
Software Architecture: views and viewpointsSoftware Architecture: views and viewpoints
Software Architecture: views and viewpoints
 
Model-Driven Development of Web Applications
Model-Driven Development of Web ApplicationsModel-Driven Development of Web Applications
Model-Driven Development of Web Applications
 

Ähnlich wie Software Architecture Taxonomies - modularity

Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principlesdeonpmeyer
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net coreSam Nasr, MCSA, MVP
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionKnoldus Inc.
 
Design principles to modularise a monolith codebase.pptx
Design principles to modularise a monolith codebase.pptxDesign principles to modularise a monolith codebase.pptx
Design principles to modularise a monolith codebase.pptxPrashant Kalkar
 
Best practices for creating modular Web applications
Best practices for creating modular Web applicationsBest practices for creating modular Web applications
Best practices for creating modular Web applicationspeychevi
 
Dependency Injection in .NET
Dependency Injection in .NETDependency Injection in .NET
Dependency Injection in .NETssusere19c741
 
Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementationthe_wumberlog
 
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsVolodymyr Voytyshyn
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_pptagnes_crepet
 
Software engineering
Software engineeringSoftware engineering
Software engineeringFahe Em
 
Software engineering
Software engineeringSoftware engineering
Software engineeringFahe Em
 
Architecting for Change: An Agile Approach
Architecting for Change: An Agile ApproachArchitecting for Change: An Agile Approach
Architecting for Change: An Agile ApproachBen Stopford
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile projectHarald Soevik
 

Ähnlich wie Software Architecture Taxonomies - modularity (20)

Day1
Day1Day1
Day1
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
Design pattern
Design patternDesign pattern
Design pattern
 
MDA
MDAMDA
MDA
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
Design principles to modularise a monolith codebase.pptx
Design principles to modularise a monolith codebase.pptxDesign principles to modularise a monolith codebase.pptx
Design principles to modularise a monolith codebase.pptx
 
Solid
SolidSolid
Solid
 
L02 Architecture
L02 ArchitectureL02 Architecture
L02 Architecture
 
Best practices for creating modular Web applications
Best practices for creating modular Web applicationsBest practices for creating modular Web applications
Best practices for creating modular Web applications
 
Dependency Injection in .NET
Dependency Injection in .NETDependency Injection in .NET
Dependency Injection in .NET
 
Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementation
 
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design Patterns
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Architecting for Change: An Agile Approach
Architecting for Change: An Agile ApproachArchitecting for Change: An Agile Approach
Architecting for Change: An Agile Approach
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile project
 

Mehr von Jose Emilio Labra Gayo

Introducción a la investigación/doctorado
Introducción a la investigación/doctoradoIntroducción a la investigación/doctorado
Introducción a la investigación/doctoradoJose Emilio Labra Gayo
 
Challenges and applications of RDF shapes
Challenges and applications of RDF shapesChallenges and applications of RDF shapes
Challenges and applications of RDF shapesJose Emilio Labra Gayo
 
Legislative data portals and linked data quality
Legislative data portals and linked data qualityLegislative data portals and linked data quality
Legislative data portals and linked data qualityJose Emilio Labra Gayo
 
Validating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectivesValidating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectivesJose Emilio Labra Gayo
 
Legislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologiesLegislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologiesJose Emilio Labra Gayo
 
Como publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazadosComo publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazadosJose Emilio Labra Gayo
 
Arquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el ServidorArquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el ServidorJose Emilio Labra Gayo
 

Mehr von Jose Emilio Labra Gayo (20)

Publicaciones de investigación
Publicaciones de investigaciónPublicaciones de investigación
Publicaciones de investigación
 
Introducción a la investigación/doctorado
Introducción a la investigación/doctoradoIntroducción a la investigación/doctorado
Introducción a la investigación/doctorado
 
Challenges and applications of RDF shapes
Challenges and applications of RDF shapesChallenges and applications of RDF shapes
Challenges and applications of RDF shapes
 
Legislative data portals and linked data quality
Legislative data portals and linked data qualityLegislative data portals and linked data quality
Legislative data portals and linked data quality
 
Validating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectivesValidating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectives
 
Wikidata
WikidataWikidata
Wikidata
 
Legislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologiesLegislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologies
 
ShEx by Example
ShEx by ExampleShEx by Example
ShEx by Example
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Introducción a la Web Semántica
Introducción a la Web SemánticaIntroducción a la Web Semántica
Introducción a la Web Semántica
 
RDF Data Model
RDF Data ModelRDF Data Model
RDF Data Model
 
2017 Tendencias en informática
2017 Tendencias en informática2017 Tendencias en informática
2017 Tendencias en informática
 
RDF, linked data and semantic web
RDF, linked data and semantic webRDF, linked data and semantic web
RDF, linked data and semantic web
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
19 javascript servidor
19 javascript servidor19 javascript servidor
19 javascript servidor
 
Como publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazadosComo publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazados
 
16 Alternativas XML
16 Alternativas XML16 Alternativas XML
16 Alternativas XML
 
XSLT
XSLTXSLT
XSLT
 
XPath
XPathXPath
XPath
 
Arquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el ServidorArquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el Servidor
 

Kürzlich hochgeladen

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Software Architecture Taxonomies - modularity

  • 1. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Universidad de Oviedo Software Architecture Part II. Architecture classifications 3 - Modularity 2014 Jose Emilio Labra Gayo
  • 2. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modularity
  • 3. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Big Ball of Mud Hierarchical decomposition Dependencies Generalization Layers Aspect Oriented decomposition Domain based decomposition
  • 4. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Big Ball of Mud Big Ball of Mud Described by Foote & Yoder, 1997 Elements Lots of entities intertwined Constraints None
  • 5. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Big Ball of Mud Advantages Quick-start It is possible to start without defining an architecture Solve problems on demand Cheap solution for short-term projects It can be OK for some projects
  • 6. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Big Ball of Mud Problems High Maintenance costs Low flexibility from a given point At start it can be very flexible After some time, a change can be dramatic Inertia When the system becomes a Big Ball of Mud it is very difficult to convert it to another thing A few prestigious developers know where to touch Clean developers run away from these systems
  • 7. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Big Ball of Mud Some reasons Throwaway code: You need an immediate fix for a small problem, a quick prototype or proof of concept When it is good enough, you ship it Piecemeal growth Cut/Paste reuse Bad code is reproduced in lots of places Anti-patterns Bad smells Code/Architecture
  • 8. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modular decomposition Elements Modules Each module has an interface and a body Relationships "is part of" between modules
  • 9. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modular decomposition Definitions Module: Piece of software the offers a set of responsabilities It makes sense at development time (no runtime) Separates interface from body Interface Describes what is a module How to use it  Contract Body How it is implemented Interface Body (Implementation) Module
  • 10. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modular decomposition Quality attributes Commnication Communicates the general aspect of the system Minimizes complexity A module only exposes an interface Extensibility, maintenance Facilitates changes and extensions Localized functionality Reusability Modules can be used in other contexts Product lines Independence Modules can be developed by different teams
  • 11. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modular decomposition Challenges Bad decomposition can augment complexity Decission: Develop vs buy COTS modules Dependency management Third parties modules can affect evolution Team organization Modular decomposition can affect team development and organization
  • 12. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modular decomposition Constraints No cycles are allowed A module can only have one parent System Subsystem A Subsystem B Subsystem B1 Subsystem B2 Subsystem A2 Subsystem A1
  • 13. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modular decomposition Some recommendations High cohesion Low coupling SOLID principles Demeter's Law Fluid interfaces
  • 14. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modularity recommendations High cohesion Cohesion = Coherence of a module Each module must solve one functionality DRY (Don't Repeat Yourself) Principle Intention must be declared in only one place It should be possible to test each module separately
  • 15. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modularity recommendations Low coupling Coupling = Interaction degree between modules Low coupling  Improves modifiability Independent deployment of each module Stability against changes in other modules
  • 16. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Modularity recommendations SOLID principles They can be used to define clases and modules SRP (Single Responsability Principle) OCP (Open-Closed Principle) LSP (Liskov Substitution Principle) ISP (Interface Seggregation Principle) DIP (Dependency Injection Principle)
  • 17. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (S)ingle Responsibility A module must have one responsibility Responsibility = A reason to change No more than one reason to change a module Otherwise, responsibilities are mixed and coupling increases vs
  • 18. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (S)ingle Resposibility class Employee { def calculatePay(): Money = { ??? } def saveDB() { ??? } def reportWorkingHours(): String = { ??? } Responsible departments http://blog.8thlight.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html } Financial department Operations Management There can be multiple reasons to change the Employee class Solution: Separate concerns Gather together the things that change for the same reasons. Separate those things that change for different reasons.
  • 19. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (O)pen/Closed principle Open for extension The module must adapt to new changes Change/adapt the behavior of a module Closed for modification Changes can be done without changing the module Without modifying source code, binaries, etc It should be easy to change the behaviour of a module without changing the source code of that module http://blog.8thlight.com/uncle-bob/2013/03/08/AnOpenAndClosedCase.html
  • 20. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (O)pen/Closed principle Example: class SelectProducts { def filterByColor(products: List[Product], color: Color): List[Product] = { ??? } If you need to filter by height, you need to change the source code Another solution: def filter(products: List[Product], predicate: Product => Boolean): List[Product] = { ??? } Now, it is possible to filter by any predicate without changing the module
  • 21. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (L)iskov Substitution Subtypes must follow supertypes contract A type B is a subtype of A when: xA, if there is a property Q such that Q(x) then yB, Q(y) A B "Derived types must be completely substitutable by their base types" Common mistakes: Inherit and modify behaviour of base class Add functionality to supertypes that subtypes don't follow
  • 22. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (L)iskov Substitution Duck haceCuak tieneFormaPato respira) doCuak hasShapeDuck breathes) X Example DuckInPark RubberDucky
  • 23. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (I)nterface Segregation Clients must not depend on unused methods Better to have small and cohesive interfaces Otherwise  non desired dependencies If a module depends on non-used functionalities and these functionalities change, the module can be effected ClientA ClientB InterfaceA methodA1 methodA2 InterfaceB methodB1 methodB2 Service mehtodA1 methodA2 methodB1 methodB2 ... <<uses>> <<uses>>
  • 24. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (D)ependency Inversion Invert conventional dependencies High-level modules should not depend on low-level modules Both should depend on abstractions Abstractions should not depend upon details. Details should depend upon abstractions Can be accomplished using dependency injection or several patterns like plugin, service locator, etc. http://www.objectmentor.com/resources/articles/dip.pdf http://martinfowler.com/articles/dipInTheWild.html
  • 25. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo (D)ependency Inversion Lowers coupling Facilitates unit testing Substituting low level modules by test doubles Related with: Dependency injection and Inversion of Control Frameworks: Spring, Guice, etc.
  • 26. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Demeter's Law Principle of less knowledge Modules only communicates with near modules Goal: low coupling Lower number of invoked methods Tradeoff solution It is not always possitive It can augment number of methods in modules Symptoms of bad design: Using more than one dot... a.b.method(...)  
  • 27. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Fluent APIs Improve readability and usability of interfaces Advantages Can lead to domain specific languages Auto-complete facilities by IDEs
  • 28. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Fluent APIs Methods that modify return the same object class Product { ... public Product setPrice(double price) { this.price = price; return this; }; Several methods can be chained Example: Product p = new Product(). setName("Pepe"). setPrice(23); It does not contradict Demeter's Law because it acts on the same object
  • 29. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Other modularity recommendations Facilitate external configuration of a module Create an external configuration module Create a default implementation GRASP Principles General Responsibility Assignment Software Patterns
  • 30. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Module Systems In Java: OSGi Module = bundle Controls encapsulation It allows to install, start, stop and deinstall modules during runtime Used in Eclipse Modules = Micro-services Several implementations: Apache Felix, Equinox Jigsaw Project (Java 9) In .Net: Assemblies
  • 31. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo
  • 32. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Module Dependencies Relationship "uses" One module uses (depends on) other module
  • 33. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Module Dependencies Elementes Modules Relationships "depends on" between modules Constraints Module M1 depends on M2 if correct behavior of M1 depends on correct behavior of M2
  • 34. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Module Dependencies Advantages: Incremental development Implement part of the functionality Debugging, testing Facilitates impact analysis upon changes
  • 35. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Module dependencies Challenges Dependency management Avoid cyclic dependencies Modules that depend on a lot of modules Limits incremental development Bad separation of concerns
  • 36. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo
  • 37. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Generalization/specialization Elements Modules Relationships (is-a) between modules Constraints: Parent is more general than children
  • 38. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Generalization/Specialization Advantages Facilitates extensión and architecture evolution Notion of inheritance in OO design Captures common parts with variations = children Change and local variation Reuse
  • 39. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Generalization/Specialization Challenges Complexity to identify relationships Exceptions Multiple inheritance implications
  • 40. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Generalization/Specialization Applications Application frameworks
  • 41. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo
  • 42. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Divide software modules in layers Order between layers Each layer exposes an interface that can be used by higher layers Layer N Layer N - 1 . . . Layer 1
  • 43. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Elements Layer: set of functionalities exposed through an interface at a level N Order relationship between layers Layer N Layer N - 1 . . . Layer 1
  • 44. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Capas Constraints Each software block belongs to one layer There are at least 2 layers A layer can be: Client: consumes services from below layers Server: provides services to upper layers 2 variants: Strict: Layer N uses only functionality from layer N-1 Lax: Layer N uses functionalities from layers 1 to N - 1 No cycles
  • 45. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Example User interface Application Domain Infrastructure
  • 46. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Layers ≠ Modules A layer can be a module... ...but modules can be decomposed in other modules (layers can't) Dividing a layer, it is posible to obtain modules
  • 47. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Layers ≠ Tiers Layer: conceptual separation Tier: physical separation Presentation Business Data 3-Layers External Applications Legacy systems Database Business logic Firewall Thin client RIA Presentation Business Data 3-tiers
  • 48. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Advantages Separates different abstraction levels Loose coupling: independent evolution of each layer It is possible to offer different implementations of a layer that keep the same interface Reusability Changes in a layer affects only to the layer that is above or below it. It is possible to create standard interfaces as libraries or application frameworks
  • 49. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Challenges It is notalways possible to apply it Not always do we have different abstraction levels Performance Access through layers can slow the system Shortcuts Sometimes, it may be necessary to skip some layers
  • 50. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Example: Android
  • 51. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Layers Variants: Virtual machines, APIs 3-layers, N-layers
  • 52. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Virtual machine Virtual machine = Opaque layer Hides a specific OS implementation One can only get Access through the public API Program API Virtual Machine Operating System
  • 53. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Virtual machines Advantages Portability Simplifies software development Higher-level programming Facilitates emulation Challenges Performance JIT techniques Computational overload generated by the new layer
  • 54. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Virtual machine Applications Programming languages JVM: Java Virtual Machine CLR .Net Emulation software
  • 55. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo 3-layers (N-layers) Conceptual decomposition Presentation Business logic Data Presentation Business Data
  • 56. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo
  • 57. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Aspects: Modules that implement crosscutting features Presentation Business Data Security Monitorization Logging Aspects Interntionalization
  • 58. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Elements: Crosscutting concern Functionality that is required in several places of an application Examples: logging, monitorization, i18n, security,... Generate tangling code Aspect. Captures a crosscutting-concern in a module
  • 59. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Example: Book flight seats Several methods to do the booking: Book a seat Book a row Book two consecutive seats ... En each method: Check permission (security) Concurrence (block seats) Transactions (do the whole operation in one step) Create a log of the operation ...
  • 60. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Traditional solution class Plane { void bookSeat(int row, int number) { // ... Log book petition // ... check autorization // ... check free seat // ... block seat // ... start transition // ... log start of operation // ... Do booking // ... Log end of operation // ... Execute transaction or rollback // ... Unblock } ... public void bookRow(int row) { // ... More or less the same!!!! ... Concurrence Logging Security Transaction
  • 61. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Structure Core Application Logic Crosscutting Crosscutting Crosscutting concern concern concern (aspect) Aspect compiler (weaving) Final application
  • 62. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Definitions Join point: Point where an aspect can be inserted Aspect: Contains: Advice: defines the job of the aspect Pointcut: where the aspect will be introduced It can match one or more join points Join points Pointcut Running Program Advice
  • 63. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Aspect example in @Aspectj @Aspect public class Security { @Pointcut("execution(* org.example.Flight.book*(..))") public void safeAccess() {} @Before("safeAccess()") public void authenticate(JoinPoint joinPoint) { // Does the authentication } } Methods book* It is executed before to invoke those methods It can Access to information of the joinPoint
  • 64. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Constraints: An aspect can affect one or more traditional modules An aspect captures all the definitions of a crosscutting-concern The aspect must be inserted in the code Tools for automatic introduction
  • 65. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Advantages Simpler design Basic application is clean of crosscutting concerns Facilitates system modifiability and maintenance Crosscutting concerns are localized in a single module Reuse Crosscutting concerns can be reused in other systems
  • 66. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Challenges External tools are needed Aspects compiler. Example: AspectJ Other tools: Spring, JBoss Debugging is more complex A bug in one aspect module can have unknown consequences in other modules Program flow is more complex Team development needs new skills Not every developer knows aspect oriented programming
  • 67. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Aspect Oriented Applications AspectJ = Java extension with AOP Guice = Dependency injection Framework Spring = Enterprise framework with dependency injection and AOP Variants DCI (Data-Context-Interaction): It is centered in the identification of roles from use cases
  • 68. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Domain based Domain driven design Hexagonal architecture Data centered Patterns CQRS Event sourcing Naked Objects
  • 69. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Data model vs domain model Data models Physical: Data representation Tables, columns, keys, ... Logical: Data structure Entities and relationships Domain models Conceptual model of a domain Vocabulary and context Entities, relationships Behavior Business rules
  • 70. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Domain based Centered on the domain and the business logic Goal: Anticipate and handle changes in domain Collaboration between developers and domain experts
  • 71. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Domain based Elements Domain model: formed by: Context Entities Relationships Application Manipulates domain elements
  • 72. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Domain based Constraints Domain model is a clearly identified module separated from other modules Domain centered application Application must adapt to domain model changes No topological constraints
  • 73. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Domain based Advantages: Facilitates team communication Ubiquitous language Reflects domain structure Address domain changes Share and reuse models Reinforce data quality and consistency Facilitates system testing It is possible to create testing doubles with fake domain data
  • 74. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Domain based Challenges: Collaboration with domain experts Stalled analysis phase It is necessary to establish context boundaries Technological dependency Avoid domain models that depend on some specific persistence technologies Synchronization Synchronize system with domain changes
  • 75. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Domain based Variants DDD - Domain driven design Hexagonal style Data centered N-Layered Domain Driven Design Related patterns: CQRS (Command Query Responsibility Segregation) Event Sourcing Naked Objects
  • 76. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo DDD - Domain Driven Design General approach to software development Proposed by Eric Evans (2004) Connect the implementation to an evolving domain Collaboration between technical and domain experts Ubiquitous language Common vocabulary shared by the experts and the development team
  • 77. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo DDD - Domain Driven Design Elements Bounded context Specifies the boundaries of the domain Entities An object with an identity Value objects Contain attributes but no identity Aggregates Collection of objects bound together by some root entity Services External operations
  • 78. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo DDD - Domain Driven Design Constraints Entities inside aggregates are only accessible through the root entity Value objects contain only attributes (immutables)
  • 79. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo DDD - Domain driven design Advantages Code organization Identification of the main parts Maintenance/evolution of the system Facilitates refactoring It adapts to Behaviour Driven Development Team communication Problem space Domain experts Solution space Development team Ubiquitous language
  • 80. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo DDD - Domain driven design Challenges Involve domain experts in development It is not always possible Apparent complexity It adds some constraints to development Useful for complex, non-trivial domains
  • 81. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Hexagonal style Other names: ports and adapters, onion, clean, etc. Based on a clean Domain model Infrastructures and frameworks are outside Access through ports and adapters Application Adapter Adapter Adapter Adapter Adapter Domain model port port http://alistair.cockburn.us/Hexagonal+architecture http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html Adapter
  • 82. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Hexagonal style Example Traditional application in layers Incorporates new services Testing DB Application Adapter UI DB MySQL Adapter DB2 Adapter REST Adapter printer Adapter DB1 External Application Domain Model API port data port DB MongoDB Adapter DB testing
  • 83. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Hexagonal style Elements Domain model Represents business logic: Entities and relationships Plain Objects (POJOs: Plain Old Java Objects) Ports Communication interface It can be: User, Database Adapters One adapter by each external element Examples: REST, User, DB SQL, DB mock,...
  • 84. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Hexagonal style Advantages Understanding Improves domain understanding Timelessness Less dependency on technologies and frameworks Adaptability (time to market) It is easier to adapt the application to changes in the domain Testability It is possible to substitute real databases by mock databases
  • 85. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Hexagonal style Challenges It can be difficult to separate domain from the persistence system Lots of frameworks combine both Asymmetry of ports & adapters Not all are equal Active ports (user) vs passive ports (logger)
  • 86. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Data centered Simple domains based on data CRUD (Create-Retrieve-Update-Delete) operations Advantages: Semi-automatic generation (scaffolding) Rapid development (time-to-market) Challenges Evolution to more complex domains Anemic domains Classes that only contain getters/setters Objects without behaviour (delegated to other layers) Can be like procedural programming Anemic Models: https://www.link-intersystems.com/blog/2011/10/01/anemic-vs-rich-domain-models/
  • 87. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Domain based styles 3 patterns related CQRS Event Sourcing Naked Objects
  • 88. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo CQRS Command Query Responsibility Segregation Separate models in 2 parts Command: Does changes (updates information) Query: Only queries (get information) Application Model User Interface Data Base
  • 89. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo CQRS Command Query Responsibility Segregation Separate models in 2 parts Command: Does changes (updates information) Query: Only queries (get information) Application Query User Interface Data Base Command
  • 90. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo CQRS Advantages Scalability Optimize queries (read-only) Asynchronous commands Facilitates team decomposition and organization 1 team for read access (queries) 1 team for read/write access (command)
  • 91. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo CQRS Challenges Hybrid operations (both query and command) Example: pop() in a stack Complexity For simple CRUD applications it can be too complex Synchronization Possibility of queries over non-updated data Applications Axon Framework
  • 92. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Event Sourcing All changes to application state are stored as a sequence of events Every change is captured in an event store It is possible to trace and undo changes Write -------------------- -------------------- -------------------- ---------- Event store Event Driver Read snapshots
  • 93. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Event Sourcing Elements Events: something that has happened, in the past Event store: Events are always added (append-only) Event driver: handles the different events Snapshots of aggragated state (optional) Write -------------------- -------------------- -------------------- ---------- Event store Event Driver Read snapshots
  • 94. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Event Sourcing Advantages Fault tolerance Traceability Determine the state of the application at any time Rebuild and event-replay It is possible to discard an application state and re-run the events to rebuild a new state Scalability Append-only DB can be optimized
  • 95. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Event Sourcing Challenges Event handling Synchronization, consistency Complexity of development It addes a new indirection level Resource management Event granularity Event storage grows with time Snapshots can be used for optimization
  • 96. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Event Sourcing Applications Database systems Datomic EventStore
  • 97. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Naked Objects Domain objects contain all business logic User interface = Direct representation of domain objects It can be automatically generated Automatic generation of: User interfaces REST APIs Domain Object Domain Object Domain Object persistence services remoting UI REST
  • 98. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo Naked Objects Advantages Adaptability to domain Maintenance Challenges It may be difficult to adapt interface to special cases Applications Naked Objects (.Net), Apache Isis (Java)
  • 99. Arquitectura del Software Escuela de Ingeniería Informática Universidad de Oviedo