Design Patterns in Software EngineeringIntroduction
They work like ready-made blueprints that you may alter to address a persistent design issue in your code. It is not as simple as using pre-made routines or libraries to import a pattern you find into your program. The pattern is a broad idea for handling a specific scenario rather than a unique function. Patterns are standard responses to typical problems in object-oriented design. A solution eventually gets a name and a thorough discussion when applied to several projects. That's basically how a pattern gets found. How do Software Engineers Use Design Patterns?A software design pattern is a generic, repeatable fix for a problem frequently occurring in a particular setting. These are models for resolving typical software engineering issues, showcasing some of the best techniques seasoned object-oriented programmers employ. A design pattern addresses a common design problem in object-oriented systems by methodically describing and explaining a generic design. It discusses the issue, the solution when to apply it, and the consequences. It also offers examples and implementation guidelines. What Kind of Describes a Pattern?In object-oriented programming, a pattern might contain information on the particular objects and object classes that will be used, their attributes and dependencies, and the general approach to problem-solving. The majority of patterns include formal descriptions that enable replication under different conditions. The sections that are usually included in a pattern description are as follows:
Algorithms vs PatternsSince patterns and algorithms are common solutions to well-known problems, they can occasionally be misunderstood. Compared to an algorithm, which continually defines a predetermined sequence of actions that can accomplish a goal, a pattern provides a higher-level description of a solution. The code in two different programs may differ for the same pattern. An algorithm and a cookery recipe require specific steps to achieve the desired outcome. Conversely, a pattern is more like a blueprint; you can see the final product and its attributes but decide how to execute it in a certain sequence. The Gang of Four (GoF)The notion of design patterns in software development gained popularity in 1994 when Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides released a book titled "Design Patterns - Elements of Reusable Object-Oriented Software." The Gang of Four (GOF) is the moniker given to these writers. These authors claim that the following object-oriented design principles serve as the fundamental foundation for design patterns:
Within the software engineering community, their book is regarded as a classic. Even though it was released more than 25 years ago, software engineers still find it extremely useful and a must-read. It categorized twenty-three design patterns into behavioural, structural, and creative. Use of Design Patterns in Software EngineeringSoftware development uses design patterns primarily for two purposes.
Types of Software Engineering Design PatternsThe complexity, depth of detail, and extent to which a design pattern may be applied to the overall system under consideration vary. Let's use this example for road construction: you may increase the safety of a junction by adding traffic signals or by constructing a multi-level interchange that includes pedestrian tunnels below ground. Twenty-three design patterns fall into creational, structural, and behavioural categories, according to the book "Design Patterns - Elements of Reusable Object-Oriented Software." Let's take a closer look at each of them. 1. Creational PatternsThese patterns offer a variety of object-generation methods that improve code reuse and flexibility. All of these design patterns involve creating objects or instantiating classes. Class-creational and object-creational patterns are further categories into which these patterns may be separated. Object-creation patterns leverage delegation in the instantiation process more successfully than class-creation patterns, which use inheritance. The Factory Method, Abstract Factory, Builder, Singleton, Object Pool, and Prototype are examples of creational design patterns. 2. Structural PatternsThese patterns offer a variety of object-generation methods that improve code reuse and flexibility. These design patterns aim to combine different classes and objects into bigger structures that provide additional functionality. Structural design patterns include Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Private Class Data, and Proxy. 3. Behavioural PatternsAlgorithms and the distribution of duties among objects are the subjects of behavioural patterns. These design patterns aim to identify and realize typical ways that things communicate with one another. Behavioural patterns include the Chain of Duty, Command, Interpreter, Iterator, Mediator, Memento, Null Object, Observer, State, Strategy, Template method, and Visitor. Conclusion
Next TopicModularity in Software Engineering
|