Skip to the content.

Sustainable Software Architecture

Software architecture and sustainability

-> Important to notice that EVERY software has a architecture underline.

Origin of tech debt

And important concept to notice is that “software development” is unplannable (cannot be planned in advance).

Side Effects of tech debt

1) Types of technical debt 2) Architecture erosion 3) high-cost of mantainance (bugfix, add new feature, overall mantainance) 4) Continuos refactorings, improvements and related tasks

The graphic below show how the evolution of technical debt affect the evolution of a software product:

-> In the “Ideal World” we are situated at the bottom, where we had a team capacity and with each change or new feature, we can improve or fix a little of the architecture.

Types of Tech Debt

  1. Test Debt: Low test coverage leads to design and architectural debt. Without test we can’t improve the design or make refactors.
  2. Design and Architectural Debt: Poorly designed code structures become complex and “big ball of mud” situations.
  3. Implementation Debt: Code smells like long methods, large classes, and code duplication.

Managing Technical Debt

  1. Refactoring: Step-by-step improvement of code quality to reduce debt.
  2. Balance new features with architectural improvements.

SW architecture and cognitive psychology

First we will start understanding where the developers spend their time, the graphic below is an approximation:

The human brain has a limited capacity. The brain can only remember about 30,000 lines of code and that developers spend most of their time reading and understanding existing code.

That 70% explain why is so important to had a well defined architecture and behind that is a human reason: the human brain is trained to understand “structures”

Software architecture benefits from these principles: Techniques like modularity, layering, and design patterns mirror these cognitive processes, making code easier to understand and maintain.

Chunking

Chunking is a method of facilitating short-term memory by grouping individual pieces of information into larger, more familiar groups. When you chunk information, you break up long strings of data into smaller, more manageable units or “chunks.” These chunks are easier to commit to memory than a longer uninterrupted string of information.

Here’s how it works:

Hierarchies

The second structure building process is that our brain tries to form hierarchies to remember as much as possible. Cognitive scientists have done a lot of research and found out that our brain loves hierarchies. We can remember hierarchical structures much better than net-like structures without an order. In software, we have a suitable architectural principle, the layering or layered architectures. When we build our software in layers, we definitely support our brain.

Schemata

And finally, our brain has developed another structure building process, which is our ability to form schemata. And that’s really the best of all. Schema is an abstract idea of some part of the world. And it helps us to understand the world quickly. It’s a mental framework that allows us to fill in the gaps and make associations based on our existing knowledge.

Here’s a breakdown of the concept:

In software development, we have something that perfectly captures this principle of schemata. We have design and architecture patterns, but they only work if we use them consistently. So our well structured architecture with which we save time in maintenance and extension needs pattern consistency

Layered Architecture

Layered architectures are a design approach in software development, introduced for better organization and maintainability.

Types of Layering

Benefits of Layered Architectures

Example Systems

Poorly-Layered System: The second system (10 million lines of code), while technically layered, has a massive, tangled application/domain layer (“big ball of mud”). This leads to complex dependencies, difficult deployments, and reliance on a risky “forward-only” strategy.

Modularity

Modularity is a principle to create self-contained units (modules) with clear interfaces for interaction with other units.

Implementing Modularity:

Identifying Issues:

Design Patterns

Negative Example:

Benefits of Design Patterns:

Pattern Analysis:

Key Takeaways:

Cycles create technical debt

Examples:

Solutions:

Takeaway:

Ignoring cycles leads to an ever-growing burden of technical debt. Proactive management and proper architecture are crucial for maintaining a clean and maintainable codebase.

Last: what is a Big Ball of mud

A “big ball of mud” refers to a complex and poorly-organized codebase. It lacks a clear structure, making it difficult to understand, maintain, and modify.

The key characteristics of a “big ball of mud”:

The “big ball of mud” metaphor aptly depicts the situation as a tangled mess, similar to a ball of mud, where individual parts are difficult to distinguish and manipulate. This situation can arise due to various factors, such as:

The presence of a “big ball of mud” can significantly impact software development efforts by:

Software engineers aim to avoid “big ball of mud” situations by implementing good coding practices, utilizing appropriate design patterns, and focusing on code maintainability throughout the development process. Additionally, techniques like refactoring can help improve the structure and clarity of existing codebases that might be exhibiting signs of this anti-pattern.

Architecture Reviews

Purpose:

Process:

  1. Interviews: With stakeholders, development team, and architects.
  2. Transcripts the interviews to keep logs
  3. Document Review: Architecture documentation, coding guidelines, test coverage.
  4. Analysis Workshop:
    • Import code into analysis tool.
    • Discuss structure with development team and architects.
  5. Identify refactoring for violations.
  6. Quality Report:
    • Based on modularity, layering, and pattern consistency.
    • Includes a Modularity Maturity Index (MMI) score (0-10).
  7. Results and report to clients
    • Generate final quality reports
    • Generate a list of prioritized refactorings

The Modularity Maturity Index or MMI. This index makes it clear whether an architecture has a modular structure, and is therefore a maintainable and extendable architecture. The MMI ranks systems on a scale from zero to 10. Systems that have a score between zero and four are in poor condition. Systems between four and eight are in mediocre condition. And systems between eight and 10 are in very good condition.

MMI Scoring:

Key Takeaways:

Reference: