Design Patterns Review


Design Patterns Review

Simon
Welcome to the final design patterns lecture. Today we are doing two things: first, a summary of the whole course, and then a practice exam so everyone can experience the exam setting before next week.

Maria
And after that, students are asked to complete the course evaluation. They can give final feedback about what should be kept, what should change in future years, and any other comments they have.

Simon
There is also an optional quiz from the Institute for Software Technology. It asks participants to evaluate software pattern or software report information, such as whether something relates to memory or configuration management. It belongs to a research project and is not part of this design patterns lecture.

Maria
The course began with a word cloud showing patterns students already knew. The interesting conclusion is that, after the course, students should recognize nearly every pattern in that cloud. One exception mentioned was God Class, which is an antipattern and was not covered in the lecture.

Simon
The course covered a large number of patterns through lecture videos and interactive quizzes. Early live programming sessions did not work as well as hoped, so the course shifted toward feedback-based interactive quizzes, where unclear points and student questions could be discussed.

Maria
The historical starting point was Christopher Alexander. In 1977, he wrote the architecture book A Pattern Language, which established the foundation for describing patterns: a context, a problem, the forces that make the problem difficult, a solution, and the consequences of choosing that solution.

Simon
Alexander began in architecture, but the pattern movement later spread to software development and software architecture. The most famous software book is Design Patterns: Elements of Reusable Object-Oriented Software, written by the Gang of Four: Ralph Johnson, Erich Gamma, Richard Helm, and John Vlissides.

Maria
Other important works include the Pattern-Oriented Software Architecture, or POSA, books. Douglas Schmidt, one of the authors associated with those books, also contributed many of the pattern videos used in the course. The course patterns came mainly from the Gang of Four book and the POSA books.

Simon
Let's organize the patterns by their broad roles. Wrapping patterns add another layer of abstraction around something. The adapter changes an interface, the proxy controls access, the decorator adds responsibilities, and the facade presents a simpler interface to a more complicated subsystem.

Maria
Creational patterns focus on creating objects. The builder supports a multistep construction process, the prototype provides a template from which objects can be created, and the singleton controls creation so that only one instance exists. In these cases, object creation is separated from the application developer or made more systematic.

Simon
Behavioral patterns change or implement object behavior. Strategy represents an algorithm abstractly and makes it possible to exchange algorithms, even at runtime. Command packages a method call, along with its environment, into an object that can be stored, invoked later, or undone.

Maria
State is especially useful when an object behaves like a state machine. The object's response depends on its current state, so changing the state changes what actions it performs and how it reacts. State is often combined or confused with other patterns, but its central idea is behavior that varies with state.

Simon
Architectural patterns influence an entire application. Examples include layers, broker, master-slave, client-server, pipes and filters, and Model-View-Controller. MVC separates responsibilities among the model, the view, and the controller, and it defines how those roles communicate and how data and control flow through the application.

Maria
Some patterns work particularly well with collections. The iterator gives a standard way to traverse a collection without exposing all of its internal representation. Different programming languages implement iterators differently, but the general pattern remains recognizable.

Simon
Communication patterns help objects exchange information. They can decouple a sender from a receiver, encapsulate information in a message, and send that message across a network or between components. Broker is an important example, but it should not automatically be used everywhere; its communication structure and overhead must fit the situation.

Maria
Concurrency patterns address coordination between activities that run concurrently. The course included locks, monitors, active objects, futures, scoped locking, and async-await. These patterns help control synchronization and make concurrent behavior more manageable.

Simon
Resource patterns focus on acquiring and releasing resources correctly. The goal is to decide when a resource should be acquired and to avoid forgetting to release it. Examples include garbage collection, leasing, and scoped resources, where the scope helps define the period during which the resource is held.

Maria
The course also covered patterns that do not fit neatly into one group. Memento preserves information about an object's state, while a counted pointer, also called a smart pointer in this context, counts references and keeps an object in memory until nobody needs it anymore. Chain of Responsibility and Interpreter were also included, with Interpreter closely connected to abstract syntax trees.

Simon
Knowing pattern names and their basic ideas has a practical benefit: it gives developers a shared vocabulary. Saying, 'We could use a monitor here' or 'This looks like a command pattern' makes it easier to discuss a recurring design problem with other developers and students.

Maria
The central learning goal was to understand what design patterns are and why they are useful, along with the principles behind them, how to describe them, and how to apply them. Students also studied roughly fifty patterns in varying levels of detail, including their contexts, benefits, drawbacks, and appropriate use cases.

Simon
A design pattern is a proven solution for a recurring problem. It is a solution template or solution idea that has been used successfully in multiple projects. It is not a concrete piece of code, and merely suggesting an untested idea is not enough; the pattern must represent experience that has already been applied.

Maria
A proper pattern description starts with a memorable name, such as Adapter, Broker, or Active Object. It then explains the context in which the pattern applies, because patterns exist in many domains, including software, hardware, architecture, and social situations. A software pattern should be applied in a software-development context, not transferred blindly to an unrelated domain.

Simon
The description must state the problem. It should not be a trivial situation with an obvious answer. A difficult problem usually contains conflicting or antagonistic forces: constraints that pull the design in different directions. In embedded development, for example, limited memory, CPU capacity, or energy can strongly influence which solution is feasible.

Maria
The solution should be generic rather than a single concrete implementation. It normally describes the static participants, such as the classes and objects involved, and the dynamic behavior: how those participants are created, who communicates with whom, and which calls occur at runtime.

Simon
After applying the solution, we describe the consequences, sometimes called the rationale. These include benefits, liabilities, limitations, and trade-offs. A broker may decouple communication, but it can also introduce communication overhead, require additional processes or machines, and force clients or services to register before they can interact.

Maria
Observer illustrates another trade-off. It can notify interested objects when data changes, but if ten million objects observe one change and notification is synchronous, the application can become very slow. So knowing a pattern is not enough; you must decide whether its consequences are acceptable for the requirements.

Simon
Known users are the real-world examples of a pattern. A pattern becomes a pattern through repeated application: people use the solution again and again, observe that it works, and record that experience. Known users therefore provide the evidence that the pattern is not merely an untested proposal.

Maria
The course used a pattern-house metaphor. The roof represents the context, the inside contains the problem and its forces together with the solution and consequences, and the foundation represents known users. The name stands above everything, while all the parts are connected: forces make the problem difficult, the solution addresses the problem, and the consequences follow from the solution.

Simon
Design patterns are guided by broader design principles, including the SOLID principles. The Single Responsibility Principle says that a class should have one responsibility and therefore one main reason to change.

Maria
The Open-Closed Principle says that behavior should be open to extension but closed to modification. Strategy and State can help achieve this: the original state-machine implementation can remain unchanged while new states, transitions, or configurations alter its behavior.

Simon
The Liskov Substitution Principle says that derived classes should be usable wherever their base classes are expected. The Interface Segregation Principle says to create fine-grained interfaces specific to clients rather than forcing a client to depend on capabilities it does not need. A useful summary is to make interfaces easy to use and hard to use incorrectly.

Maria
Dependency Inversion means depending on abstractions, such as interfaces or abstract classes, rather than concrete classes. That makes it easier for another developer to provide a different implementation and helps decouple parts of the system.

Simon
The course also emphasized decomposition, abstraction, decoupling, usability, and simplicity. Decomposition breaks a large problem into smaller tasks, just as a thesis can be divided into chapters and individual work packages. Abstraction hides unnecessary details behind a simpler layer, so an application developer can send a network message without needing to understand every detail of the underlying frames and headers.

Maria
Decoupling delays decisions and reduces direct dependencies. Instead of hard-coding every communication partner, objects can connect through abstractions or be combined at runtime. This means a small change in one part of a system does not necessarily require recompiling the entire source base.

Simon
Usability and simplicity mean providing intuitive interfaces, following users' expectations, and avoiding premature optimization. Implement what is needed now while thinking reasonably ahead, but do not build an unnecessarily complicated solution. Code should also follow the conventions of its context, including the programming language, coding style, development environment, and tools used by the team.

Maria
The pattern categories are partly artificial. Architectural patterns influence the whole application, classical design patterns influence several components, and idioms solve much smaller, language-specific problems. Scoped resources, scoped locking, and Python's 'if name equals main' structure are examples of ideas that can be treated as idioms rather than broad, language-independent design patterns.

Simon
The Gang of Four patterns covered in the course represented nearly the entire book, while the POSA material also contributed patterns such as master-slave, proxy, Blackboard, command processor, MVC, Presentation-Abstraction-Control, whole-part, and counted pointer. Some patterns were intentionally omitted, including reflection, Half-Sync/Half-Async, and Extension Interface.

Maria
Reflection would allow a program to discover information about an object or class at runtime, such as which methods and attributes it has. Half-Sync/Half-Async coordinates synchronous and asynchronous worlds, while Extension Interface offers a simple interface or a more advanced interface depending on what level of configuration the user needs.

Simon
A major learning goal was language independence. Design patterns should generally describe software-design solutions independently of a particular programming language. Language-specific solutions are called idioms, whereas a design pattern in the broader sense can be transferred between languages.

Maria
Students should also be able to compare consequences and make design decisions. For example, they might evaluate whether Mediator or Observer is more appropriate for a particular use case. The aim is to balance the forces, benefits, and drawbacks against the requirements, avoid over-engineering, and avoid misusing patterns in simple programs where they add unnecessary complexity.

Simon
Patterns are not something to apply mechanically. A simple script or a Hello World program usually does not need a collection of design patterns. A larger project may benefit from them because they can make architecture more flexible, avoid common problems, and prevent developers from reinventing solutions that already have a history of successful use.

Maria
The final philosophical point was that patterns make knowledge explicit, findable, understandable, and applicable. We write knowledge down, publish it in books, papers, conferences, and videos, structure it so others can understand it, and most importantly, learn how to apply it to real problems rather than merely memorizing names.

Simon
That connects with the quoted advice from Richard Feynman: study what interests you in an independent and original way. The practical message is not to follow a lecturer's path blindly, but to test ideas in your own problems, projects, and contexts. Applying patterns yourself is how the knowledge becomes useful.

Maria
For the practice exam, the exam is activated in the teaching center after the summary. Students can use today's session to try the exam environment and join the BigBlueButton session with a smartphone to test the required setup.

Simon
Next week's assessment is a closed-book exam. Students must work alone, cannot use lecture materials, and will be supervised. The smartphone should be placed beside the desktop so that the screen and the student's hands on the keyboard can be seen, and today's practice is an opportunity to make sure that arrangement works.

Maria
And for students interested in continuing academically, the Institute of Technical Informatics offers seminar projects, ten-ECTS projects, bachelor's and master's theses, and possible doctoral paths. Information is available through the institute's webpage and Discord server, where new topics and opportunities are posted.

Simon
So the essential message of the course is this: recognize recurring problems, understand their conflicting forces, choose a proven and appropriate solution, and evaluate its consequences. Use patterns as a shared design language and as reusable experience, but always make the final decision based on the actual context and requirements.

Ask anything
We've read this whole study set, so questions about it get the best answers.