CS 130


Welcome to Computer Science 130 - Software Engineering at UCLA

Design Patterns


Overview

In software engineering, a design pattern is a common, acceptable solution to a recurring design problem that arises within a specific context. The concept did not originate in computer science, but rather in architecture. Christopher Alexander, an architect who pioneered the idea, defined a pattern beautifully: “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice”.

In software development, design patterns refer to medium-level abstractions that describe structural and behavioral aspects of software. They sit between low-level language idioms (like how to efficiently concatenate strings in Java) and large-scale architectural patterns (like Model-View-Controller or client-server patterns). Structurally, they deal with classes, objects, and the assignment of responsibilities; behaviorally, they govern method calls, message sequences, and execution semantics.

Anatomy of a Pattern

A true pattern is more than simply a good idea or a random solution; it requires a structured format to capture the problem, the context, the solution, and the consequences. While various authors use slightly different templates, the fundamental anatomy of a design pattern contains the following essential elements:

  • Pattern Name: A good name is vital as it becomes a handle we can use to describe a design problem, its solution, and its consequences in a word or two. Naming a pattern increases our design vocabulary, allowing us to design and communicate at a higher level of abstraction.
  • Context: This defines the recurring situation or environment in which the pattern applies and where the problem exists.
  • Problem: This describes the specific design issue or goal you are trying to achieve, along with the constraints symptomatic of an inflexible design.
  • Forces: This outlines the trade-offs and competing concerns that must be balanced by the solution.
  • Solution: This describes the elements that make up the design, their relationships, responsibilities, and collaborations. It specifies the spatial configuration and behavioral dynamics of the participating classes and objects.
  • Consequences: This explicitly lists the results, costs, and benefits of applying the pattern, including its impact on system flexibility, extensibility, portability, performance, and other quality attributes.

GoF Design Patterns

Here are some examples of design patterns that we describe in more detail:

  • State: Encapsulates state-based behavior into distinct classes, allowing a context object to dynamically alter its behavior at runtime by delegating operations to its current state object.

  • Observer: Establishes a one-to-many dependency between objects, ensuring that a group of dependent objects is automatically notified and updated whenever the internal state of their shared subject changes.

Architectural Patterns

Here are some examples of architectural patterns that we describe in more detail:

  • Model-View-Controller (MVC): The Model-View-Controller (MVC) architectural pattern decomposes an interactive application into three distinct components: a model that encapsulates the core application data and business logic, a view that renders this information to the user, and a controller that translates user inputs into corresponding state updates

The Benefits of a Shared Toolbox

Just as a mechanic must know their toolbox, a software engineer must know design patterns intimately—understanding their advantages, disadvantages, and knowing precisely when (and when not) to use them.

  • A Common Language for Communication: The primary challenge in multi-person software development is communication. Patterns solve this by providing a robust, shared vocabulary. If an engineer suggests using the “Observer” or “Strategy” pattern, the team instantly understands the problem, the proposed architecture, and the resulting interactions without needing a lengthy explanation.
  • Capturing Design Intent: When you encounter a design pattern in existing code, it communicates not only what the software does, but why it was designed that way.
  • Reusable Experience: Patterns are abstractions of design experience gathered by seasoned practitioners. By studying them, developers can rely on tried-and-tested methods to build flexible and maintainable systems instead of reinventing the wheel.

Challenges and Pitfalls of Design Patterns

Despite their power, design patterns are not silver bullets. Misusing them introduces severe challenges:

  • The “Hammer and Nail” Syndrome: Novice developers who just learned patterns often try to apply them to every problem they see. Software quality is not measured by the number of patterns used. Often, keeping the code simple and avoiding a pattern entirely is the best solution.
  • Over-engineering vs. Under-engineering: Under-engineering makes software too rigid for future changes. However, over-applying patterns leads to over-engineering—creating premature abstractions that make the codebase unnecessarily complex, unreadable, and a waste of development time. Developers must constantly balance simplicity (fewer classes and patterns) against changeability (greater flexibility but more abstraction).
  • Implicit Dependencies: Patterns intentionally replace static, compile-time dependencies with dynamic, runtime interactions. This flexibility comes at a cost: it becomes harder to trace the execution flow and state of the system just by reading the code.
  • Misinterpretation as Recipes: A pattern is an abstract idea, not a snippet of code from Stack Overflow. Integrating a pattern into a system is a human-intensive, manual activity that requires tailoring the solution to fit a concrete context.

Context Tailoring

It is important to remember that the standard description of a pattern presents an abstract solution to an abstract problem. Integrating a pattern into a software system is a highly human-intensive, manual activity; patterns cannot simply be misinterpreted as step-by-step recipes or copied as raw code. Instead, developers must engage in context tailoring—the process of taking an abstract pattern and instantiating it into a concrete solution that perfectly fits the concrete problem and the concrete context of their application.

Because applying a pattern outside of its intended problem space can result in bad design (such as the notorious over-use of the Singleton pattern), tailoring ensures that the pattern acts as an effective tool rather than an arbitrary constraint.

The Tailoring Process: The Measuring Tape and the Scissors

Context tailoring can be understood through the metaphor of making a custom garment, which requires two primary steps: using a “measuring tape” to observe the context, and using “scissors” to make the necessary adjustments.

1. Observation of Context

Before altering a design pattern, you must thoroughly observe and measure the environment in which it will operate. This involves analyzing three main areas:

  • Project-Specific Needs: What kind of evolution is expected? What features are planned for the future, and what frameworks is the system currently relying on?
  • Desired System Properties: What are the overarching goals of the software? Must the architecture prioritize run-time performance, strict security, or long-term maintainability?
  • The Periphery: What is the complexity of the surrounding environment? Which specific classes, objects, and methods will directly interact with the pattern’s participants?

2. Making Adjustments

Once the context is mapped, developers must “cut” the pattern to fit. This requires considering the broad design space of the pattern and exploring its various alternatives and variation points. After evaluating the context-specific consequences of these potential variations, the developer implements the most suitable version. Crucially, the design decisions and the rationale behind those adjustments must be thoroughly documented. Without documentation, future developers will struggle to understand why a pattern deviates from its textbook structure.

Dimensions of Variation

Every design pattern describes a broad design space containing many distinct variations. When tailoring a pattern, developers typically modify it along four primary dimensions:

Structural Variations

These variations alter the roles and responsibility assignments defined in the abstract pattern, directly impacting how the system can evolve. For example, the Factory Method pattern can be structurally varied by removing the abstract product class entirely. Instead, a single concrete product is implemented and configured with different parameters. This variation trades the extensibility of a massive subclass hierarchy for immediate simplicity.

Behavioral Variations

Behavioral variations modify the interactions and communication flows between objects. These changes heavily impact object responsibilities, system evolution, and run-time quality attributes like performance. A classic example is the Observer pattern, which can be tailored into a “Push model” (where the subject pushes all updated data directly to the observer) or a “Pull model” (where the subject simply notifies the observer, and the observer must pull the specific data it needs).

Internal Variations

These variations involve refining the internal workings of the pattern’s participants without necessarily changing their external structural interfaces. A developer might tailor a pattern internally by choosing a specific list data structure to hold observers, adding thread-safety mechanisms, or implementing a specialized sorting algorithm to maximize performance for expected data sets.

Language-Dependent Variations

Modern programming languages offer specific constructs that can drastically simplify pattern implementations. For instance, dynamically typed languages can often omit explicit interfaces, and aspect-oriented languages can replace standard polymorphism with aspects and point-cuts. However, there is a dangerous trap here: using language features to make a pattern entirely reusable as code (e.g., using include Singleton in Ruby) eliminates the potential for context tailoring. Design patterns are fundamentally about design reuse, not exact code reuse.

The Global vs. Local Optimum Trade-off

While context tailoring is essential, it introduces a significant challenge in large-scale software projects. Perfectly tailoring a pattern to every individual sub-problem creates a “local optimum”. However, a large amount of pattern variation scattered throughout a single project can lead to severe confusion due to overloaded meaning.

If developers use the textbook Observer pattern in one module, but highly customized, structurally varied Observers in another, incoming developers might falsely assume identical behavior simply because the classes share the “Observer” naming convention. To mitigate this, large teams must rely on project conventions to establish pattern consistency. Teams must explicitly decide whether to embrace diverse, highly tailored implementations (and name them distinctly) or to enforce strict guidelines on which specific pattern variants are permitted within the codebase.

Pattern Compounds

In software design, applying individual design patterns is akin to utilizing distinct compositional techniques in photography—such as symmetry, color contrast, leading lines, and a focal object. Simply having these patterns present does not guarantee a masterpiece; their deliberate arrangement is crucial. When leading lines intentionally point toward a focal object, a more pleasing image emerges. In software architecture, this synergistic combination is known as a pattern compound.

A pattern compound is a reoccurring set of patterns with overlapping roles from which additional properties emerge. Notably, pattern compounds are patterns in their own right, complete with an abstract problem, an abstract context, and an abstract solution. While pattern languages provide a meta-level conceptual framework or grammar for how patterns relate to one another, pattern compounds are concrete structural and behavioral unifications.

The Anatomy of Pattern Compounds

The core characteristic of a pattern compound is that the participating domain classes take on multiple superimposed roles simultaneously. By explicitly connecting patterns, developers can leverage one pattern to solve a problem created by another, leading to a new set of emergent properties and consequences.

Solving Structural Complexity: The Composite Builder

The Composite pattern is excellent for creating unified tree structures, but initializing and assembling this abstract object structure is notoriously difficult. The Builder pattern, conversely, is designed to construct complex object structures. By combining them, the Composite’s Component acts as the Builder’s AbstractProduct, while the Leaf and Composite act as ConcreteProducts.

This compound yields the emergent properties of looser coupling between the client and the composite structure and the ability to create different representations of the encapsulated composite. However, as a trade-off, dealing with a recursive data structure within a Builder introduces even more complexity than using either pattern individually.

Managing Operations: The Composite Visitor and Composite Command

Pattern compounds frequently emerge when scaling behavioral patterns to handle structural complexity:

  • Composite Visitor: If a system requires many custom operations to be defined on a Composite structure without modifying the classes themselves (and no new leaves are expected), a Visitor can be superimposed. This yields the emergent property of strict separation of concerns, keeping core structural elements distinct from use-case-specific operations.
  • Composite Command: When a system involves hierarchical actions that require a simple execution API, a Composite Command groups multiple command objects into a unified tree. This allows individual command pieces to be shared and reused, though developers must manage the consequence of execution order ambiguity.

Communicating Design Intent and Context Tailoring

Pattern compounds also naturally arise when tailoring patterns to specific contexts or when communicating highly specific design intents.

  • Null State / Null Strategy: If an object enters a “do nothing” state, combining the State pattern with the Null Object pattern perfectly communicates the design intent of empty behavior. (Note that there is no Null Decorator, as a decorator must fully implement the interface of the decorated object).
  • Singleton State: If State objects are entirely stateless—meaning they carry behavior but no data, and do not require a reference back to their Context—they can be implemented as Singletons. This tailoring decision saves memory and eases object creation, though it permanently couples the design by removing the ability to reference the Context in the future.

The Advantages of Compounding Patterns

The primary advantage of pattern compounds is that they make software design more coherent. Instead of finding highly optimized but fragmented patchwork solutions for every individual localized problem, compounds provide overarching design ideas and unifying themes. They raise the composition of patterns to a higher semantic abstraction, enabling developers to systematically foresee how the consequences of one pattern map directly to the context of another.

Challenges and Pitfalls

Despite their power, pattern compounds introduce distinct architectural and cognitive challenges:

  • Mixed Concerns: Because pattern compounds superimpose overlapping roles, a single class might juggle three distinct concerns: its core domain functionality, its responsibility in the first pattern, and its responsibility in the second. This can severely overload a class and muddle its primary responsibility.
  • Obscured Foundations: Tightly compounding patterns can make it much harder for incoming developers to visually identify the individual, foundational patterns at play.
  • Naming Limitations: Accurately naming a class to reflect its domain purpose alongside multiple pattern roles (e.g., a “PlayerObserver”) quickly becomes unmanageable, forcing teams to rely heavily on external documentation to explain the architecture.
  • The Over-Engineering Trap: As with any design abstraction, possessing the “hammer” of a pattern compound does not make every problem a nail. Developers must constantly evaluate whether the resulting architectural complexity is truly justified by the context.

Advanced Concepts

Patterns Within Patterns: Core Principles

When analyzing various design patterns, you will begin to notice recurring micro-architectures. Design patterns are often built upon fundamental software engineering principles:

  • Delegation over Inheritance: Subclassing can lead to rigid designs and code duplication (e.g., trying to create an inheritance tree for cars that can be electric, gas, hybrid, and also either drive or fly). Patterns like Strategy, State, and Bridge solve this by extracting varying behaviors into separate classes and delegating responsibilities to them.
  • Polymorphism over Conditions: Patterns frequently replace complex if/else or switch statements with polymorphic objects. For instance, instead of conditional logic checking the state of an algorithm, the Strategy pattern uses interchangeable objects to represent different execution paths.
  • Additional Layers of Indirection: To reduce strong coupling between interacting components, patterns like the Mediator or Facade introduce an intermediate object to handle communication. While this centralizes logic and improves changeability, it can create long traces of method calls that are harder to debug.

Domain-Specific and Application-Specific Patterns

The Gang of Four patterns are generic to object-oriented programming, but patterns exist at all levels.

  • Domain-Specific Patterns: Certain industries (like Game Development, Android Apps, or Security) have their own highly tailored patterns. Because these patterns make assumptions about a specific domain, they generally carry fewer negative consequences within their niche, but they require the team to actually possess domain expertise.
  • Application-Specific Patterns: Every distinct software project will eventually develop its own localized patterns—agreed-upon conventions and structures unique to that team. Identifying and documenting these implicit patterns is one of the most critical steps when a new developer joins an existing codebase, as it massively improves program comprehension.

Conclusion

Design patterns are the foundational building blocks of robust software architecture. However, they are a substitute for neither domain expertise nor critical thought. The mark of an expert engineer is not knowing how to implement every pattern, but possessing the wisdom to evaluate trade-offs, carefully observe the context, and know exactly when the simplest code is actually the smartest design.

Observer


Problem 

In software design, you frequently encounter situations where one object’s state changes, and several other objects need to be notified of this change so they can update themselves accordingly.

If the dependent objects constantly check the core object for changes (polling), it wastes valuable CPU cycles and resources. Conversely, if the core object is hard-coded to directly update all its dependent objects, the classes become tightly coupled. Every time you need to add or remove a dependent object, you have to modify the core object’s code, violating the Open/Closed Principle.

The core problem is: How can a one-to-many dependency between objects be maintained efficiently without making the objects tightly coupled?

Context

The Observer pattern is highly applicable in scenarios requiring distributed event handling systems or highly decoupled architectures. Common contexts include:

  • User Interfaces (GUI): A classic example is the Model-View-Controller (MVC) architecture. When the underlying data (Model) changes, multiple UI components (Views) like charts, tables, or text fields must update simultaneously to reflect the new data.

  • Event Management Systems: Applications that rely on events—such as user button clicks, incoming network requests, or file system changes—where an unknown number of listeners might want to react to a single event.

  • Social Media/News Feeds: A system where users (observers) follow a specific creator (subject) and need to be notified instantly when new content is posted.

Solution

The Observer design pattern solves this by establishing a one-to-many subscription mechanism.

It introduces two main roles: the Subject (the object sending updates after it has changed) and the Observer (the object listening to the updates of Subjects).

Instead of objects polling the Subject or the Subject being hard-wired to specific objects, the Subject maintains a dynamic list of Observers. It provides an interface for Observers to attach and detach themselves at runtime. When the Subject’s state changes, it iterates through its list of attached Observers and calls a specific notification method (e.g., update()) defined in the Observer interface.

This creates a loosely coupled system: the Subject only knows that its Observers implement a specific interface, not their concrete implementation details.

Design Decisions

Push vs. Pull Model:

Push Model: The Subject sends the detailed state information to the Observer as arguments in the update() method, even if the Observer doesn’t need all data. This keeps the Observer completely decoupled from the Subject but can be inefficient if large data is passed unnecessarily.

Pull Model: The Subject sends a minimal notification, and the Observer is responsible for querying the Subject for the specific data it needs. This requires the Observer to have a reference back to the Subject, slightly increasing coupling, but it is often more efficient.

Factory Method


Context

In software construction, we often find ourselves in situations where a “Creator” class needs to manage a lifecycle of actions—such as preparing, processing, and delivering an item—but the specific type of item it handles varies based on the environment.

For example, imagine a PizzaStore that needs to orderPizza(). The store follows a standard process: it must prepare(), bake(), cut(), and box() the pizza. However, the specific type of pizza (New York style vs. Chicago style) depends on the store’s physical location. The “Context” here is a system where the high-level process is stable, but the specific objects being acted upon are volatile and vary based on concrete subclasses.

Problem: The “Switch Statement” Trap

Without a creational pattern, developers often resort to “Big Upfront Logic” using complex conditional statements. You might see code like this:

public Pizza orderPizza(String type) {
    Pizza pizza;
    if (type.equals("cheese")) { pizza = new CheesePizza(); }
    else if (type.equals("greek")) { pizza = new GreekPizza(); }
    // ... more if-else blocks ...
    pizza.prepare();
    pizza.bake();
    return pizza;
}

This approach presents several critical challenges:

  1. Violation of Single Responsibility Principle: This single method is now responsible for both deciding which pizza to create and managing the baking process.
  2. Divergent Change: Every time the menu changes or the baking process is tweaked, this method must be modified, making it a “hot spot” for bugs.
  3. Tight Coupling: The store is “intimately” aware of every concrete pizza class, making it impossible to add new regional styles without rewriting the store’s core logic.

Solution: Deferring Instantiation

The Factory Method Pattern solves this by defining an interface for creating an object but letting subclasses decide which class to instantiate. It effectively “defers” the responsibility of creation to subclasses.

In our PizzaStore example, we make the createPizza() method abstract within the base PizzaStore class. This abstract method is the “Factory Method”. We then create concrete subclasses like NYPizzaStore and ChicagoPizzaStore, each implementing createPizza() to return their specific regional variants.

The structure involves four key roles:

  • Product: The common interface for the objects being created (e.g., Pizza).
  • Concrete Product: The specific implementation (e.g., NYStyleCheesePizza).
  • Creator: The abstract class that contains the high-level business logic (the “Template Method”) and declares the Factory Method.
  • Concrete Creator: The subclass that implements the Factory Method to produce the actual product.

Consequences: Decoupling and Complexity

The primary benefit of this pattern is decoupling: the high-level “Creator” code is completely oblivious to which “Concrete Product” it is actually using. This allows the system to evolve independently; you can add a LAPizzaStore without touching a single line of code in the original PizzaStore base class.

However, there are trade-offs:

  • Boilerplate Code: It requires creating many new classes (one for each product type and one for each creator type), which can increase the “static” complexity of the code.
  • Program Comprehension: While it reduces long-term maintenance costs, it can make the initial learning curve steeper for new developers who aren’t familiar with the pattern.

Abstract Factory


Context

In complex software systems, we often encounter situations where we must manage multiple categories of related objects that need to work together consistently. Imagine a software framework for a pizza franchise that has expanded into different regions, such as New York and Chicago. Each region has its own specific set of ingredients: New York uses thin crust dough and Marinara sauce, while Chicago uses thick crust dough and plum tomato sauce. The high-level process of preparing a pizza remains stable across all locations, but the specific “family” of ingredients used depends entirely on the geographical context.

Problem

The primary challenge arises when a system needs to be independent of how its products are created, but those products belong to families that must be used together. Without a formal creational pattern, developers might encounter the following issues:

  • Inconsistent Product Groupings: There is a risk that a “rogue” franchise might accidentally mix New York thin crust with Chicago deep-dish sauce, leading to a product that doesn’t meet quality standards.
  • Parallel Inheritance Hierarchies: You often end up with multiple hierarchies (e.g., a Dough hierarchy, a Sauce hierarchy, and a Cheese hierarchy) that all need to be instantiated based on the same single decision point, such as the region.
  • Tight Coupling: If the Pizza class directly instantiates concrete ingredient classes, it becomes “intimate” with every regional variation, making it incredibly difficult to add a new region like Los Angeles without modifying existing code.

Solution

The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. It essentially acts as a “factory of factories,” or more accurately, a single factory that contains multiple Factory Methods.

The design pattern involves these roles:

  1. Abstract Factory Interface: Defining an interface (e.g., PizzaIngredientFactory) with a creation method for each type of product in the family (e.g., createDough(), createSauce()).
  2. Concrete Factories: Implementing regional subclasses (e.g., NYPizzaIngredientFactory) that produce the specific variants of those products.
  3. Client: The client (e.g., the Pizza class) no longer knows about specific ingredients. Instead, it is passed an IngredientFactory and simply asks for its components, remaining completely oblivious to whether it is receiving New York or Chicago variants.

Consequences

Applying the Abstract Factory pattern results in several significant architectural trade-offs:

  • Isolation of Concrete Classes: It decouples the client code from the actual factory and product implementations, promoting high information hiding.
  • Promoting Consistency: It ensures that products from the same family are always used together, preventing incompatible combinations.
  • Ease of Adding New Families: Adding a new look-and-feel or a new region is a “pure addition”—you simply create a new concrete factory and new product implementations without touching existing code.
  • The “Rigid Interface” Drawback: While adding new families is easy, adding new types of products to the family is difficult. If you want to add “Pepperoni” to your ingredient family, you must change the Abstract Factory interface and modify every single concrete factory subclass to implement the new method.

Design Principles


Information Hiding

Description

SOLID

Description

Information Hiding


In the realm of software engineering, few principles are as foundational or as frequently misunderstood as Information Hiding (IH). While often confused with simply making variables “private,” IH is a sophisticated strategy for managing the overwhelming complexity inherent in modern software systems.

Historical Context

To understand why we hide information, we must look back to the mid-1960s. During the Apollo missions, lead software engineer Margaret Hamilton noted that software complexity had already surpassed hardware complexity. By 1968, the industry reached a “Software Crisis” where projects were consistently over budget, behind schedule, and failing to meet specifications. In response, David Parnas published a landmark paper in 1972 proposing a new way to decompose systems. He argued that instead of breaking a program into steps (like a flowchart), engineers should identify “difficult design decisions” or “decisions likely to change” and encapsulate each one within its own module.

The Core Principle: Secrets and Interfaces

The Information Hiding principle states that design decisions likely to change independently should be the “secrets” of separate modules. A module is defined as an independent work unit—such as a function, class, directory, or library—that can be assigned to a single developer. Every module consists of two parts:

  • The Interface (API): A stable contract that describes what the module does. It should only reveal assumptions that are unlikely to change.
  • The Implementation: The “secret” code that describes how the module fulfills its contract. This part can be changed freely without affecting the rest of the system, provided the interface remains the same.

A classic real-world example is the power outlet. The interface is the standard two or three-prong socket. As a user, you do not need to know if the power is generated by solar, wind, or nuclear energy; you only care that it provides electricity. This allows the “implementation” (the power source) to change without requiring you to replace your appliances.

Common “Secrets” to Hide

Successful modularization requires identifying which details are volatile. Common secrets include:

  • Data Structures: Whether data is stored in an array, a linked list, or a hash map.
  • Data Storage: Whether information is stored on a local disk, in a SQL database, or in the cloud.
  • Algorithms: The specific steps of a computation, such as using A* versus Dijkstra for pathfinding.
  • External Dependencies: The specific libraries or frameworks used, such as choosing between Axios or Fetch for network requests.

Software Process


Agile

For decades, software development was dominated by the Waterfall model, a sequential process where each phase—requirements, design, implementation, verification, and maintenance—had to be completed entirely before the next began. This “Big Upfront Design” approach assumed that requirements were stable and that designers could predict every challenge before a single line of code was written. However, this led to significant industry frustrations: projects were frequently delayed, and because customer feedback arrived only at the very end of the multi-year cycle, teams often delivered products that no longer met the user’s changing needs.

Agile Manifesto

In 2001, a group of software experts met in Utah to address these failures, resulting in the Agile Manifesto. Rather than a rigid rulebook, the manifesto proposed a shift in values:

  • Individuals and interactions over processes and tools
  • Working software over comprehensive documentation
  • Customer collaboration over contract negotiation
  • Responding to change over following a plan While the authors acknowledged value in the items on the right, they insisted that the items on the left were more critical for success in complex environments.

Core Principles

The heart of Agility lies in iterative and incremental development. Instead of one long cycle, work is broken into short, time-boxed periods—often called Sprints—typically lasting one to four weeks. At the end of each sprint, the team delivers a “Working Increment” of the product, which is demonstrated to the customer to gather rapid feedback. This ensures the team is always building the “right” system and can pivot if requirements evolve. Key principles supporting this include:

  • Customer Satisfaction: Delivering valuable software early and continuously.
  • Simplicity: The art of maximizing the amount of work not done.
  • Technical Excellence: Continuous attention to good design to enhance long-term agility.
  • Self-Organizing Teams: Empowering developers to decide how to best organize their own work rather than acting as “coding monkeys”.

Common Agile Processes

The most common agile processes include:

  • Scrum: The most popular framework using roles like Scrum Master, Product Owner, and Developers.
  • Extreme Programming (XP): Focused on technical excellence through “extreme” versions of good practices, such as Test-Driven Development (TDD), Pair Programming, Continuous Integration, and Collective Code Ownership
  • Lean Software Development: Derived from Toyota’s manufacturing principles, Lean focuses on eliminating waste

Scrum


AI Audio Summary:

While many organizations claim to be “Agile”, the vast majority (roughly 63%) implement the Scrum framework.

Scrum Theory

Scrum is a management framework built on the philosophy of Empiricism. This philosophy asserts that in complex environments like software development, we cannot rely on detailed upfront predictions. Instead, knowledge comes from experience, and decisions must be based on what is actually observed and measured in a “real” product.

To make empiricism actionable, Scrum rests on three core pillars:

  • Transparency: Significant aspects of the process must be visible to everyone responsible for the outcome. “The work is on the wall”, meaning stakeholders and developers alike should see exactly where the project stands via artifacts like Kanban boards.
  • Inspection: The team must frequently and diligently check their progress toward the Sprint Goal to detect undesirable variances.
  • Adaptation: If inspection reveals that the process or product is unacceptable, the team must adjust immediately to minimize further issues. It is important to realize that Scrum is not a fixed process but one designed to be tailored to a team’s specific domain and needs.

Scrum Roles

AI Audio Summary:

Scrum defines three specific roles that are intentionally designed to exist in tension to ensure both speed and quality:

  • The Product Owner (The Value Navigator): This role is responsible for maximizing the value of the product resulting from the team’s work. They “own” the product vision, prioritize the backlog, and typically communicate requirements through user stories.
  • The Developers (The Builders): Developers in Scrum are meant to be cross-functional and self-organizing. This means they possess all the skills needed—UI, backend, testing—to create a usable increment without depending on outside teams. They are responsible for adhering to a Definition of Done to ensure internal quality.
  • The Scrum Master (The Coach): Misunderstood as a “project manager”, the Scrum Master is actually a servant-leader. Their primary objective is to maximize team effectiveness by removing “impediments” (blockers like legal delays or missing licenses) and coaching the team on Scrum values.

Scrum Artifacts

Scrum manages work through three primary artifacts:

  • Product Backlog: An emergent, ordered list of everything needed to improve the product.
  • Sprint Backlog: A subset of items selected for the current iteration, coupled with an actionable plan for delivery.
  • The Increment: A concrete, verified stepping stone toward the Product Goal. An increment is only “born” once a backlog item meets the team’s Definition of Done—a checklist of quality measures like functional testing, documentation, and performance benchmarks.

Scrum Events

The framework follows a specific rhythm of time-boxed events:

  • The Sprint: A 1–4 week period of uninterrupted development.
  • Sprint Planning: The entire team collaborates to define why the sprint is valuable (the goal), what can be done, and how it will be built.
  • Daily Standup (Daily Scrum): A 15-minute sync where developers discuss what they did yesterday, what they will do today, and any obstacles in their way.
  • Sprint Review: A working session at the end of the sprint where stakeholders provide feedback on the working increment. A good review includes live demos, not just slides.
  • Sprint Retrospective: The team reflects on their process and identifies ways to increase future quality and effectiveness.

Scaling Scrum with SAFe

When a product is too massive for a single team of 7–10 people, organizations often use the Scaled Agile Framework (SAFe). SAFe introduces the Agile Release Train (ART)—a “team of teams” that synchronizes their sprints. It operates on Program Increments (PI), typically lasting 8–12 weeks, which align multiple teams toward quarterly goals. While SAFe provides predictability for Fortune 500 companies, critics sometimes call it “Scrum-but-for-managers” because it can reduce individual team autonomy through heavy planning requirements.

Extreme Programming (XP)


Overview

Extreme Programming, or XP, emerged as one of the most influential Agile frameworks, originally proposed by software expert Kent Beck. Unlike traditional “Waterfall” models that rely on “Big Upfront Design” and assume stable requirements, XP is built for environments where requirements evolve rapidly as the customer interacts with the product. The core philosophy is to identify software engineering practices that work well and push them to their purest, most “extreme” form.

The primary objectives of XP are to maximize business value, embrace changing requirements even late in development, and minimize the inherent risks of software construction through short, feedback-driven cycles.

Applicability and Limitations

XP is specifically designed for small teams (ideally 4–10 people) located in a single workspace where working software is needed constantly. While it excels at responsiveness, it is often difficult to scale to massive organizations of thousands of people, and it may not be suitable for systems like spacecraft software where the cost of failure is absolute and working software cannot be “continuously” deployed in flight.

XP Practices

The success of XP relies on a set of loosely coupled practices that synergize to improve software quality and team responsiveness.

The Planning Game (and Planning Poker)

The goal of the Planning Game is to align business needs with technical capabilities. It involves two levels of planning:

  • Release Planning: The customer presents user stories, and developers estimate the effort required. This allows the customer to prioritize features based on a balance of business value and technical cost.
  • Iteration Planning: User stories are broken down into technical tasks for a short development cycle (usually 1–4 weeks).

To facilitate estimation, teams often use Planning Poker. Each member holds cards with Fibonacci numbers representing “story points”—imaginary units of effort. If estimates differ wildly, the team discusses the reasoning (e.g., a hidden complexity or a helpful library) until a consensus is reached.

Small Releases

XP teams maximize customer value by releasing working software early, often, and incrementally. This provides rapid feedback and reduces risk by validating real-world assumptions in short cycles rather than waiting years for a final delivery.

Test-Driven Development (TDD)

In XP, testing is not a final phase but a continuous activity. TDD follows a strict “Red-Green-Refactor” rhythm:

  • Red: Write a tiny, failing test for a new requirement.
  • Green: Write the simplest possible code to make that test pass, even taking shortcuts.
  • Refactor: Clean the code and improve the design while ensuring the tests still pass.

TDD ensures high test coverage and results in “living documentation” that describes exactly what the code should do.

Pair Programming

Two developers work together on a single machine. One acts as the Driver (hands on the keyboard, focusing on local implementation), while the other is the Navigator (watching for bugs and thinking about the high-level architecture). Research suggests this improves product quality, reduces risk, and aids in knowledge management.

Continuous Integration (CI)

To avoid the “integration hell” that occurs when developers wait too long to merge their work, XP mandates integrating and testing the entire system multiple times a day. A key benchmark is the 10-minute build: if the build and test process takes longer than 10 minutes, the feedback loop becomes too slow.

Collective Code Ownership

In XP, there are no individual owners of modules; the entire team owns all the code. This increases the bus factor—the number of people who can disappear before the project stalls—and ensures that any team member can fix a bug or improve a module.

Coding Standards

To make collective ownership feasible, the team must adhere to strict coding standards so that the code looks unified, regardless of who wrote it. This reduces the cognitive load during code reviews and maintenance.

Critical Perspectives: Design vs. Agility

A common critique of XP is that focusing solely on implementing features can lead to a violation of the Information Hiding principle. Because TDD focuses on the immediate requirements of a single feature, developers may fail to step back and structure modules around design decisions likely to change.

To mitigate this, XP advocates for “Continuous attention to technical excellence”. While working software is the primary measure of progress, a team that ignores good design will eventually succumb to technical debt—short-term shortcuts that make future changes prohibitively expensive.

Testing


In our quest to construct high-quality software, testing stands as the most popular and essential quality assurance activity. While other techniques like static analysis, model checking, and code reviews are valuable, testing is often the primary pillar of industry-standard quality assurance.

Test Classifications

Regression Testing

As software evolves, we must ensure that new features don’t inadvertently break existing functionality. This is the purpose of regression testing—the repetition of previously executed test cases. In a modern agile environment, these are often automated within a Continuous Integration (CI) pipeline, running every time code is changed

Black-Box and White-Box

When we design tests, we usually adopt one of two mindsets. Black-box testing treats the system as a “black box” where the internal workings are invisible; tests are derived strictly from the requirements or specification to ensure they don’t overfit the implementation. In contrast, white-box testing requires the tester to be aware of the inner workings of the code, deriving tests directly from the implementation to ensure high code coverage.

The Testing Pyramid: Levels of Execution

A robust testing strategy requires a mix of tests at different levels of abstraction.

These levels include:

  • Unit Testing: The execution of a complete class, routine, or small program in isolation.
  • Component Testing: The execution of a class, package, or larger program element, often still in isolation.
  • Integration Testing: The combined execution of multiple classes or packages to ensure they work correctly in collaboration.
  • System Testing: The execution of the software in its final configuration, including all hardware and external software integrations.

Testability

Quality Attributes


While functionality describes exactly what a software system does, quality attributes describe how well the system performs those functions. Quality attributes measure the overarching “goodness” of an architecture along specific dimensions, encompassing critical properties such as extensibility, availability, security, performance, robustness, interoperability, and testability.

Important quality attributes include:

  • Interoperability: the degree to which two or more systems or components can usefully exchange meaningful information via interfaces in a particular context.

UML


Class Diagrams 

Class diagrams represent classes and their interactions.

Classes

Classes are displayed as rectangles with one to three different sections that are each separated by a horizontal line.

The top section is always the name of the class. If the class is abstract, the name is in italics. 

The middle section indicates attributes of the class (i.e., member variables). 

The bottom section should include all methods that are implemented in this class (i.e., for which the implementation of the class contains a method definition). 

Inheritance is visualized using an arrow with an empty triage pointing to the super class. 

Attributes and methods can be marked as public (+), private (-), or protected (#), to indicate the visibility. Hint: Avoid public attributes, as this leads to bad design. (Public means every class has access, private means only this class has access, protected means this class and its sub classes have access) 

When a class uses an association, the name and visibility of the attribute can be written either next to the association or in the attribute section, or both (but only if it is done consistently). Writing it on the Association is more common since it increases the readability of the diagram.

Please include types for arguments and a meaningful parameter name. Include return types in case the method returns something (e.g., + calculateTax(income: int): int

Interfaces

Interfaces are classes that do not have any method definitions and no attributes. Interfaces only contain method declarations. Interfaces are visualized using the <<interface>> stereotype

To realize an interface, use then arrow with an empty triage pointing to the interface and a dashed line.

Sequence Diagrams 

Sequence diagrams display the interaction between concrete objects (or component instances). 

They show one particular example of interactions (potentially with optional, alternative, or looped behavior when necessary). Sequence diagrams are not intended to show ALL possible behaviors since this would become very complex and then hard to understand.

Objects / component instances are displayed in rectangles with the label following this pattern: objectName: ClassName. If the name of the object is irrelevant, then you can just write : Classname

When showing interactions between objects then all arrows in the sequence diagram represent method calls being made between the two objects. So an arrow from the client object with the name handleInput to the state objects means that somewhere in the code of the class of which client is an instance of, there is a method call to the handleInput method on the object state. Important: These are interactions between particular objects, not just generally between classes. It’s always on concrete instance of this class. 

The names shown on the arrows have to be consistent with the method names shown in the class diagram, including the number or arguments, order of arguments, and types of arguments. Whenever an arrow with method x and arguments of type Y and Z are received by an object o, then either the class of which o is an instance of or one of its super classes needs to have an implementation of x(Y,Z).     

It is a modeling choice to decide whether you want to include concrete values (e.g., caclulateTax(1400)) or meaningful variable names (e.g., calculateTax(income)). If you reference a real variable that has been used before, please make sure to ensure it is the same one and it has the right type. 

State Machine Diagrams 

State machines model the transitions between different states. States are modeled either as oval, rectangles with rounded corners, or circles. 

Transitions follow the patter [condition] trigger / action

State machines always need an initial state but don’t always need a final state. 

User Stories


User stories are the most commonly used format to specify requirements in a light-weight, informal way (particulalry in Agile projects). Each user story is a high-level description of a software feature written from the perspective of the end-user.

Unlike formal specifications, user stories are meant to be “negotiable”—they act as placeholders for a conversation between the technical team and the “business” side to ensure both parties understand the why behind a feature

Format

User stories follow this format:


As a [user role],

I want [to perform an action]

so that [I can achieve a goal]


This structure makes the team to identify not just the “what”, but also the “who” and — most importantly — the “why”.

Acceptance Criteria

While the story itself is informal, we make it actionable using Acceptance Criteria. They define the boundaries of the feature and act as a checklist to determine if a story is “done”. Acceptance criteria define the scope of a user story.

They follow this format:


Given [pre-condition / initial state]

When [action]

Then [post-condition / outcome]


INVEST

To evaluate if a user story is well-written, we apply the INVEST criteria:

  • Independent: Stories should not depend on each other so they can be implemented and released in any order.
  • Negotiable: They capture the essence of a need without dictating specific design decisions (like which database to use).
  • Valuable: The feature must deliver actual benefit to the user, not just the developer.
  • Estimable: The scope must be clear enough for developers to predict the effort required.
  • Small: A story should be a manageable chunk of work that isn’t easily split into smaller, still-valuable pieces.
  • Testable: It must be verifiable through its acceptance criteria.

We will not look at these criteria in more detail below.

Independent

Negotiable

This user story violates negotiable: “As a student, I want the website to use HTTPS so that my data is safe.” HTTPS is a design decision, not a requirement. So this user story leaves the space of requirements, which it should nopt. A better version would focus on the need for encrypted data: “As a student, I want the website to keep data I send and receive confidential so that my privacy is ensured.”

Valuable

Estimable

Small

Testable

Applicability

User stories are ideal for iterative, customer-centric projects where requirements might change frequently.

Limitations

User stories can struggle to capture non-functional requirements like performance, security, or reliability, and they are generally considered insufficient for safety-critical systems like spacecraft or medical devices