Software Architecture: How Much Design?

114
How much design? Òscar Vilaplana Paylogic, winter 2013

description

Large software projects cannot be built without some amount of analysis and design. But not all parts of the system require the same amount of design. Some may not require any upfront design at all. Others require a few minutes of architecture discussion; some require weeks of analysis, documents and review. A balance is necessary: too much design and you're delaying the project; too little and you will add technical debt which you'll have to pay in future rewrites and painful maintaining. How do we decide when design is needed and how much of it is needed? How do other Agile projects do it? In this talk I discuss what the Agile literature has to say about architecture and how we can answer this question.

Transcript of Software Architecture: How Much Design?

Page 1: Software Architecture: How Much Design?

How much design?

Òscar Vilaplana Paylogic, winter 2013

Page 2: Software Architecture: How Much Design?

How much talk?

Page 3: Software Architecture: How Much Design?

Know How Much & What It Means

What matters

Love the risks

Risks of Models

Architecture-Evident Code

Page 4: Software Architecture: How Much Design?

What matters

Page 5: Software Architecture: How Much Design?

-Paul Clemens

“The software architecture of a computing system is the set of structures needed to

reason about the system, which comprise software elements, relations among them, and

properties of both.”

Page 6: Software Architecture: How Much Design?

Issues

Organization of a system as a composition of components

Global control structures

Protocols

Physical distribution

Scaling, performance

Evolution

Design alternatives

Page 7: Software Architecture: How Much Design?

What Counts

Macroscopic parts of the design

Everything else is cover on detailed designs.

Not limited to the biggest parts in the system.

e.g. the naming pattern of a method may be architecturally significant.

e.g. prohibit threads, set time duration limitations on methods, require jobs to be scheduled…

Page 8: Software Architecture: How Much Design?

The Chain of Intentionality

Chain from high-level intentions or decisions to low-level details.

Most details left open to reasonable implementation, but not all!

Page 9: Software Architecture: How Much Design?

Why is it important?

Skeleton of the system

Influence on quality

Mismatch architecture/functionality: difficult to develop.

Imposes constraints

easy/possible for the system to evolve in a certain way

impossible to evolve in other ways

Page 10: Software Architecture: How Much Design?

Constraints?

Embody judgement: guide other engineers to acceptable solutions without transferring all knowledge of the domain.

Conceptual integrity. Reduce needless creativity.

Reduce complexity

Understand runtime behavior

Page 11: Software Architecture: How Much Design?

-Frederik P. Brooks

Conceptual integrity of a system is an important goal of system design.

A single good idea consistently applied is better than several brilliant ideas scattered

across a system.

Page 12: Software Architecture: How Much Design?

When is it important?

Small solution space, or it’s hard to design any acceptable solution.

High failure risk.

Difficult quality attributes, such as meeting a very high performance requirement.

New domain, even if it’s just new to you.

Product lines, in which all products must share a common architecture.

Page 13: Software Architecture: How Much Design?

When is it important?

How bad would it be to get the architecture wrong?

Page 14: Software Architecture: How Much Design?

Basic approaches

Ignore

Embrace

Hoist

Page 15: Software Architecture: How Much Design?

Architecture-indifferent design

Degrades.

No shared architectural visiaon.

Increasing complexity.

Page 16: Software Architecture: How Much Design?

Architecture-focused design

Seeks architectural solutions.

Entails reasoning.

Uses abstractions, views.

Page 17: Software Architecture: How Much Design?

Architecture hoisting

Choose a suitable architecture.

The architecture does the work for you.

Page 18: Software Architecture: How Much Design?

Example

Page 19: Software Architecture: How Much Design?

(made up)

Page 20: Software Architecture: How Much Design?

Requirement

The system must respond to requests within 50ms.

Page 21: Software Architecture: How Much Design?

Architecture-indifferent

Reuse the distributed architecture from another system.

If the communication is too slow:

Try to make the code more efficient.

Change the architecture.

Page 22: Software Architecture: How Much Design?

Architecture-focused

Analyze the rest of the requirements of the system.

Design an architecture that is compatible with them.

Measure: Prototype, stress test, profile.

Page 23: Software Architecture: How Much Design?

Architecture hoisting

How can the architecture ensure that a 50ms response is always achievable?

Peak demand times? Can we get additional processing from the cloud?

Page 24: Software Architecture: How Much Design?

Example

Page 25: Software Architecture: How Much Design?

(real)

Page 26: Software Architecture: How Much Design?

Example: Queue

Handle 10.000+ users per second.

Stability: keep working if a few (but not all) servers die.

Architecture: decentralized, identical nodes.

Lower level: distributed synchronization.

Benefits: easy scale up with load. Ensure fast response.

Fairness with waiting times (within limits).

Accepted tradeoffs: difficult to estimate waiting time, difficult to develop and test, limited fairness.

Page 27: Software Architecture: How Much Design?

Example: Queue, Improved

Keep working even if ALL servers die (with reduced functionality).

Recover from errors, don’t fail to the customers.

Architecture: client-server

Tradeoffs: the client becomes a SPF: requires additional testing, protective coding.

Page 28: Software Architecture: How Much Design?

Recap

Page 29: Software Architecture: How Much Design?

Software architecture deals with the large-scale decisions and macroscopic elements. These decisions have a deep impact into the code.

The archictecture choices are important because the architecture asks as a skeleton of the system and influences all its attributes: if the architecture is suitable for the desired features, it will be easier to build them; if it’s unsuitable, you will struggle.

Architecture is just one of many things that require attention. It’s helpful to know ho much attention to pay to it.

Architecture is important enough to understand and choose deliberately.

Page 30: Software Architecture: How Much Design?

Software Architecture

Deals with the large-scale decisions and macroscopic elements.

The decisions have a deep impact into the code.

The archictecture choices are important.

Architecture acts as a skeleton of the system and influences all its attributes.

Architecture is important enough to understand and choose deliberately.

Page 31: Software Architecture: How Much Design?

How much?

Page 32: Software Architecture: How Much Design?

Love the risks

Page 33: Software Architecture: How Much Design?

The concept of failure is central to

the design process,

and it is by thinking in terms of

obviating failure

that successful designs are achieved.

Page 34: Software Architecture: How Much Design?

Failure considerations

and proactive failure analysis

are essential for achieving success.

Page 35: Software Architecture: How Much Design?

It is precisely

when such considerations and analyses are

incorrect or incomplete

that design errors are introduced

and actual failures occur.

- Petroski, Henry Design Paradigms: Case Histories of Error and Judgment in Engineering.

Page 36: Software Architecture: How Much Design?

Common approaches

No front-up design

Yardstick

Upfront documentation

Ad-hoc

Risk-driven

Page 37: Software Architecture: How Much Design?

No up-front design

Just write code.

Design happens together with coding.

Impractical when failure risks are high.

Page 38: Software Architecture: How Much Design?

Yardstick

Define percentages of time that should be spent an design, coding, integration…

Can help plan architecture effort

Does not help you choose techniques.

Page 39: Software Architecture: How Much Design?

Upfront documentation

Choose appropriate design techiques.

Write a design documentation upfront.

Impractical when failure risks are low.

Page 40: Software Architecture: How Much Design?

Ad-hoc

React to the project needs.

Decide on the spot how much design to do.

Subjective.

No enduring lessons.

Page 41: Software Architecture: How Much Design?

Risk-driven

Risks are considered as seriously as features.

Identify and prioritize risks.

Select and apply techniques.

Evaluate risk reduction.

Page 42: Software Architecture: How Much Design?

Are you risk-driven?

What are your primary failure risks and corresponding engineering techniques?

Page 43: Software Architecture: How Much Design?

What are risks?

Page 44: Software Architecture: How Much Design?

What are risks?

risk = perceived probability of failure × perceived impact

Page 45: Software Architecture: How Much Design?

Risk descriptions

Actionable.

Testable failure scenarios.

Page 46: Software Architecture: How Much Design?

Engineering Risks

Analysis

Design

Implementation

Page 47: Software Architecture: How Much Design?

Project Management Risks

Schedules

Sequencing of work

Delivery

Team size

Page 48: Software Architecture: How Much Design?

Shared vocabulary

Product may not understand why something doesn’t work.

They will understand the risk of its failure.

Engineering helps Product understand.

Reverse true.

Page 49: Software Architecture: How Much Design?

Treating risks with agility

1. Identify risks.

2. Evaluate mitigation.

3. Write remaining risks in testable form.

4. Prioritize risks together with features.

Page 50: Software Architecture: How Much Design?

Identifying risks

Qualities difficult to achieve.

Incomplete requirements?

Quality Attribute Workshop

Taxonomy-Based Questionnaire

Accept risks.

Page 51: Software Architecture: How Much Design?

Prototypical risks

Risks inherent in the domain.

Checklist.

Know them.

Notice when deviating from the norm.

Page 52: Software Architecture: How Much Design?

Prioritizing risks

Priority to stakeholders.

Perceived difficulty by developers.

Page 53: Software Architecture: How Much Design?

Reduce Risks

Page 54: Software Architecture: How Much Design?

Risk reduction process

Explicit.

Repeatable.

Choose technique based on risk.

Risk cannot be avoided.

Understand the problem.

Page 55: Software Architecture: How Much Design?

Models: Analogic vs Analytic

Analogic: each element has an analogue in the domain.

Analytic: direct computational analysis.

Page 56: Software Architecture: How Much Design?

Choose model based on risk

Understanding relationship between domain entities: Analogic.

Calculate response time distributions: Analytic.

Page 57: Software Architecture: How Much Design?

Stop!

Page 58: Software Architecture: How Much Design?

Know when to stop

effort ∝ risk

Desing risky parts

Subjective evaluation

Page 59: Software Architecture: How Much Design?

Evolutionary vs Planned

Page 60: Software Architecture: How Much Design?

Planned design

Detail before construction.

Not sure it can be built.

Shared architecture.

Page 61: Software Architecture: How Much Design?

Minimal planned design

Plan to address biggest risks

Evolve rest

Page 62: Software Architecture: How Much Design?

Evolutionary design

Grows with system.

Refactoring.

Test-driven design.

Continuous Integration.

Page 63: Software Architecture: How Much Design?

Plan or Evolve?

Planning

Global properties

Avoid dead ends

Team coordination

Easier to make mistakes

Evolutionary

See it working earlier.

Identify mistakes.

Agile.

Page 64: Software Architecture: How Much Design?

Fun with Models

Page 65: Software Architecture: How Much Design?

Focus on risks

Trade-off architecture risks vs time, acceptance…

Map risks and techniques.

Page 66: Software Architecture: How Much Design?

Understand

Why did you take this decision?

Why did you follow this process?

Page 67: Software Architecture: How Much Design?

Distribute architecture skills

Engineering concern!

Efficient communication.

Answer questions, relate them to architecture models.

Small code details can be architecturally significant.

Stick to architecture vs raise flag for change.

Architect doesn’t compensate for developer knowledge.

Page 68: Software Architecture: How Much Design?

Choices

Design involves tradeoffs.

Align tradeoffs align with quality attribute priorities.

Follow pattern that:

Helps understand reasoning

Can be evaluated to check if decisions align with priorities

Page 69: Software Architecture: How Much Design?

X is a priority, so we chose design Y

and accepted downside Z

Page 70: Software Architecture: How Much Design?

Risks of Big Design Up Front

Unnecessary documentation.

Coding starts → new risks or requirements found → documentation outdated.

!

Address critical risks.

Prototype / implement.

Instead:

Page 71: Software Architecture: How Much Design?

Risks of Top-Down Design

Lower-level patterns ignored.

Incompatibility top-level / lower levels.

Lost oportunity for great solutions due to premature top-level decisions.

Page 72: Software Architecture: How Much Design?

Example

Page 73: Software Architecture: How Much Design?

Risks

Extensibility supporting new use cases part of the domain requires changing the API.

Knowledgeunderstanding the domain is not enough to understand the API.

Discoverability clients need to implement API- or domain- logic in order to use the API.

Page 74: Software Architecture: How Much Design?

Risks, Addressed

Extensibility, KnowledgeChoice of resources and actions: follow domain, don’t restrict to use cases.

Discoverability Consistency of resources, representations, actions.Machine- (and human-) readable documentation for each entry point.

Page 75: Software Architecture: How Much Design?

Tradeoffs

Efficiency

Interface segregation.

Page 76: Software Architecture: How Much Design?

–Robert C. Martin

Many client specific interfaces are better than one general purpose interface

Page 77: Software Architecture: How Much Design?

Risks

Extensibility supporting new use cases part of the domain requires changing the API.

Knowledgeunderstanding the domain is not enough to understand the API.

Discoverability clients need to implement API- or domain- logic in order to use the API.

Page 78: Software Architecture: How Much Design?

Tradeoffs

Efficiency

Interface segregation.

Page 79: Software Architecture: How Much Design?

Risks

Extensibility: Adding a custom API for a client (e.g for efficiency purposes) requires rewriting the business logic.

Page 80: Software Architecture: How Much Design?

Communication

HTTP APIHTTP interface

PTAPython simple types interface

Paylogic Core InterfaceInterface to the core, guarantee business rules

Paylogic Core

Page 81: Software Architecture: How Much Design?

Communication’

Fast Frontoffice HTTP APIPython interface that provides an efficient HTTP interface for the Frontoffice

PTA

Paylogic Core Interface

Paylogic Core

Page 82: Software Architecture: How Much Design?

Communication’

Frontoffice HTTP LayerSimple HTTP layer

Fast Frontoffice APIPython interface that provides an efficient API for the Frontoffice

Paylogic Core Interface

Paylogic Core

Page 83: Software Architecture: How Much Design?

Remaining Challenges

Page 84: Software Architecture: How Much Design?

Estimating Risks

Unforeseen risks (checklists help).

Risk priority.

Page 85: Software Architecture: How Much Design?

Evaluating Alternatives

Costly.

Balance of detail:

Enough detail to represent usefulness.

Work required.

Page 86: Software Architecture: How Much Design?

Reusability of models

Not always possible.

Safely ignored details may be important when reusing.

Page 87: Software Architecture: How Much Design?

Issues Spanning Other Teams

Dilemma:

Solve problem in Engineering, or

Buy tool for Customer Support to solve on their own.

Page 88: Software Architecture: How Much Design?

Risks of Models

Page 89: Software Architecture: How Much Design?

Solving Problems

Sometimes abstractions are needed.

Sometimes they aren’t.

Good choice: efficiency + good results!

Page 90: Software Architecture: How Much Design?

Abstractions

Size, complexity.

Focus on essence.

Reason about system qualities.

Page 91: Software Architecture: How Much Design?

-George E. P. Box

All models are wrong,

but some are useful.

Page 92: Software Architecture: How Much Design?

Reasoning

One model, different purposes.

Amplify reasoning.

Standards: spot errors.

Question first!

What to ask?

Details

Abstraction level

Page 93: Software Architecture: How Much Design?
Page 94: Software Architecture: How Much Design?
Page 95: Software Architecture: How Much Design?

Risks of Model Everything

Wasted effort.

Analysis paralysis.

Page 96: Software Architecture: How Much Design?

Not every project needs models

Models help solve problems and mitigate risks.

Some problems are best solved with models.

Other problems are best solved directly.

Page 97: Software Architecture: How Much Design?

Don’t Blindly Model Thoroughly

Is there a reason?

Is there a risk?

Page 98: Software Architecture: How Much Design?

Code first?

Reveal risks.

Prototype, test, measure.

Page 99: Software Architecture: How Much Design?

Models

Domain: Truths.

Design: System. Commitments (incomplete)

Code: Implementation structure. Commitments (complete).

Business: What the business does, why. Goals.

Page 100: Software Architecture: How Much Design?
Page 101: Software Architecture: How Much Design?

Common objections

Already know the domain.

Too simple.

Irrelevant for architecture.

Someone else’s job.

Learn by coding.

Analysis paralysis.

Page 102: Software Architecture: How Much Design?

Common objections

Already know the domain: Details!

Too simple: Details!

Irrelevant for architecture: How do you know!

Someone else’s job: Your insight!

Learn by coding: Impractical!

Analysis paralysis: Indeed, but <next slide>!

Page 103: Software Architecture: How Much Design?

Avoid Paralysis

Begin with questions

…about failure risks!

Decide ahead depth and breadth

Know when to stop.

Page 104: Software Architecture: How Much Design?

Architecture Evident

Code

Page 105: Software Architecture: How Much Design?

Code-Model Gap

Abstraction

Commitments

Intensional elements

Page 106: Software Architecture: How Much Design?

Work Through the Gap

Understand both the architecture models and the code.

Keep models and code in sync.

Write architecture-evident code.

Page 107: Software Architecture: How Much Design?

When to update the model?

Page 108: Software Architecture: How Much Design?

Architecture Evident Code

Code: solution.

Decisions?

Embed architectural intent.

Go beyond “it works”.

Page 109: Software Architecture: How Much Design?

Why?

Evolution.

Maintainability.

Developer efficiency.

Lower documentation burden.

Easy to get started.

Page 110: Software Architecture: How Much Design?

Hints

Intent: cancel a basket.

Not evident: db.query(‘update ord_orders where…’)

Evident: pta.basket.cancel(…). As in the domain:

Basket resource.

Cancel operation.

Page 111: Software Architecture: How Much Design?

Model In Code

Types and relationships of the domain are still valid in the code.

Makes sense in the domain: it makes sense in the code.

Easier to allocate responsibilities.

Easier to learn about the domain by reading the code.

Page 112: Software Architecture: How Much Design?

Conclusion

Page 113: Software Architecture: How Much Design?

Care About

Architecture.

Risks.

Right measure.

Re-evaluate.

Sync model and code.

Make model evident.

Page 114: Software Architecture: How Much Design?

Thanks!