Categories
Software Engineering

SOLID (object-oriented design)

This article is about the SOLID principles of object-oriented programming. For the fundamental state of matter, see Solid. For other uses, see Solid (disambiguation).

SOLID
Principles of Object-Oriented Design
SSingle responsibility principle – SRP
OOpen–closed
LLiskov substitution principle – LSP
IInterface segregation principle – ISP
DDependency inversion – DI

“In object-oriented computer programmingSOLID is a mnemonic acronym for five design principles intended to make software designs more understandable, flexible, and maintainable. The principles are a subset of many principles promoted by American software engineer and instructor Robert C. Martin,[1][2][3] first introduced in his 2000 paper Design Principles and Design Patterns.[2][4]” (WP)

The SOLID concepts are:

The SOLID acronym was introduced later, around 2004, by Michael Feathers.[11]

“Although the SOLID principles apply to any object-oriented design, they can also form a core philosophy for methodologies such as agile development or adaptive software development.[3]” (WP)

See also

References

  1. ^ Robert C. Martin“Principles Of OOD”butunclebob.com. Retrieved 2014-07-17.. (Note the reference to “the first five principles”, although the acronym is not used in this article.) Dates back to at least 2003.
  2. a b Robert C. Martin. “Getting a SOLID start”objectmentor.com. Retrieved 2013-08-19.
  3. a b Sandi Metz (May 2009). “SOLID Object-Oriented Design”. Retrieved 2019-08-13. Talk given at the 2009 Gotham Ruby Conference.
  4. a b c Martin, Robert C. (2000). “Design Principles and Design Patterns” (PDF). Archived from the original (PDF) on 2015-09-06.
  5. ^ “Single Responsibility Principle” (PDF). objectmentor.com. Archived from the original (PDF) on 2 February 2015.
  6. ^ Martin, Robert C. (2003). Agile Software Development, Principles, Patterns, and Practices. Prentice Hall. p. 95. ISBN 978-0135974445.
  7. ^ “Open/Closed Principle” (PDF). objectmentor.com. Archived from the original (PDF) on 5 September 2015.
  8. ^ “Liskov Substitution Principle” (PDF). objectmentor.com. Archived from the original (PDF) on 5 September 2015.
  9. ^ “Interface Segregation Principle” (PDF). objectmentor.com. 1996. Archived from the original (PDF) on 5 September 2015.
  10. ^ “Dependency Inversion Principle” (PDF). objectmentor.com. Archived from the original (PDF) on 5 September 2015.
  11. ^ Martin, Robert (2018). Clean Architecture: A Craftsman’s Guide to Software Structure and Design. p. 58. ISBN 9780134494166.

Categories

Sources:

Fair Use Sources:

Categories
C++ Cloud DevOps DevSecOps-Security-Privacy Software Engineering

Design Patterns: Elements of Reusable Object-Oriented Software, Gang of Four (GoF), 1994

See also: Head First Design Patterns: Building Extensible and Maintainable Object-Oriented Software, 2nd Edition, by Eric Freeman and Elisabeth Robson, 2021

Fair Use Source: B000SEIBB8 (GoF)

Design Patterns: Elements of Reusable Object-Oriented Software, 1st Edition, by Gamma Erich, Helm Richard, Johnson Ralph, Vlissides John

Design Patterns: Elements of Reusable Object-Oriented Software (1994) is a software engineering book describing software design patterns. The book was written by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, with a foreword by Grady Booch. The book is divided into two parts, with the first two chapters exploring the capabilities and pitfalls of object-oriented programming, and the remaining chapters describing 23 classic software design patterns. The book includes examples in C++ and Smalltalk.” (WP)

“It has been influential to the field of software engineering and is regarded as an important source for object-oriented design theory and practice. More than 500,000 copies have been sold in English and in 13 other languages. The authors are often referred to as the Gang of Four (GoF).[1]” (WP)

Capturing a wealth of experience about the design of object-oriented software, four top-notch designers present a catalog of simple and succinct solutions to commonly occurring design problems. Previously undocumented, these 23 patterns allow designers to create more flexible, elegant, and ultimately reusable designs without having to rediscover the design solutions themselves.

The authors begin by describing what patterns are and how they can help you design object-oriented software. They then go on to systematically name, explain, evaluate, and catalog recurring designs in object-oriented systems. With Design Patterns as your guide, you will learn how these important patterns fit into the software development process, and how you can leverage them to solve your own design problems most efficiently.

Each pattern describes the circumstances in which it is applicable, when it can be applied in view of other design constraints, and the consequences and trade-offs of using the pattern within a larger design. All patterns are compiled from real systems and are based on real-world examples. Each pattern also includes code that demonstrates how it may be implemented in object-oriented programming languages like C++ or Smalltalk.

Editorial Reviews

Design Patterns is a modern classic in the literature of object-oriented development, offering timeless and elegant solutions to common problems in software design. It describes patterns for managing object creation, composing objects into larger structures, and coordinating control flow between objects. The book provides numerous examples where using composition rather than inheritance can improve the reusability and flexibility of code. Note, though, that it’s not a tutorial but a catalog that you can use to find an object-oriented design pattern that’s appropriate for the needs of your particular application–a selection for virtuoso programmers who appreciate (or require) consistent, well-engineered object-oriented designs

Book Details

  • ASIN: B000SEIBB8
  • Publisher: Addison-Wesley Professional; 1st edition (October 31, 1994)
  • Publication date: October 31, 1994
  • Print length: 568 pages

Sources:

Fair Use Sources:

Categories
Cloud DevOps DevSecOps-Security-Privacy Software Engineering

Head First Design Patterns

See also: Design Patterns: Elements of Reusable Object-Oriented Software, Gang of Four (GoF), 1994

Fair Use Source: B08P3X99QP (HFDP)

See: Head First Design Patterns: Building Extensible and Maintainable Object-Oriented Software, 2nd Edition, by Eric Freeman and Elisabeth Robson, Kathy Sierra, and Bert Bates, 2021

What will you learn from this book?

You know you don’t want to reinvent the wheel, so you look to Design Patterns: the lessons learned by those who’ve faced the same software design problems. With Design Patterns, you get to take advantage of the best practices and experience of others so you can spend your time on something more challenging. Something more fun. This book shows you the patterns that matter, when to use them and why, how to apply them to your own designs, and the object-oriented design principles on which they’re based. Join hundreds of thousands of developers who’ve improved their object-oriented design skills through Head First Design Patterns.

What’s so special about this book?

If you’ve read a Head First book, you know what to expect: a visually rich format designed for the way your brain works. With Head First Design Patterns, 2E you’ll learn design principles and patterns in a way that won’t put you to sleep, so you can get out there to solve software design problems and speak the language of patterns with others on your team.

Book Details

  • ASIN: B08P3X99QP
  • ISBN: 978-1-492-07800-5
  • Publisher: O’Reilly Media; 2nd edition (November 24, 2020)
  • Publication date: November 24, 2020
  • Print length: 1156 pages
  • Printing History: October 2004: First edition
  • December 2020: Second edition
  • Release History: 2020-11-10 First release

Dedication:

“To the Gang of Four, whose insight and expertise in capturing and communicating Design Patterns has changed the face of software design forever, and bettered the lives of developers throughout the world. But seriously, when are we going to see a second edition? After all, it’s been only twenty-five years.” (HFDP)

” (HFDP)

Sources:

Fair Use Sources:

Categories
Cloud DevOps DevSecOps-Security-Privacy Software Engineering

! Template Design Pattern

” (GoF)

” (WP)

Sources:

Fair Use Sources:

Categories
Cloud DevOps Software Engineering

DDD Domain-Driven Design

Return to Timeline of the History of Computers, Networking

Domain-driven design (DDD) is the concept that the structure and language of software code (class names, class methods, class variables) should match the business domain. For example, if a software processes loan applications, it might have classes such as LoanApplication and Customer, and methods such as AcceptOffer and Withdraw.

DDD connects the implementation to an evolving model.[1]

Domain-driven design is predicated on the following goals:

  • placing the project’s primary focus on the core domain and domain logic;
  • basing complex designs on a model of the domain;
  • initiating a creative collaboration between technical and domain experts to iteratively refine a conceptual model that addresses particular domain problems.

The term was coined by Eric Evans in his book of the same title.[2]

Concepts

Concepts of the model include:ContextThe setting in which a word or statement appears that determines its meaning;DomainA sphere of knowledge (ontology), influence, or activity. The subject area to which the user applies a program is the domain of the software;ModelA system of abstractions that describes selected aspects of a domain and can be used to solve problems related to that domain;Ubiquitous LanguageA language structured around the domain model and used by all team members to connect all the activities of the team with the software.

Strategic domain-driven design

Semantic network of patterns in strategic domain-driven design.

Ideally, it would be preferable to have a single, unified model. While this is a noble goal, in reality it typically fragments into multiple models. It is useful to recognize this fact of life and work with it.

Strategic Design is a set of principles for maintaining model integrity, distilling the Domain Model, and working with multiple models.[citation needed]

Bounded context

Multiple models are in play on any large project. Yet when code based on distinct models is combined, software becomes buggy, unreliable, and difficult to understand. Communication among team members becomes confusing. It is often unclear in what context a model should not be applied.

Therefore: Explicitly define the context within which a model applies. Explicitly set boundaries in terms of team organization, usage within specific parts of the application, and physical manifestations such as code bases and database schemas. Keep the model strictly consistent within these bounds, but don’t be distracted or confused by issues outside and inside.

Continuous integration

When a number of people are working in the same bounded context, there is a strong tendency for the model to fragment. The bigger the team, the bigger the problem, but as few as three or four people can encounter serious problems. Yet breaking down the system into ever-smaller contexts eventually loses a valuable level of integration and coherency.

Therefore: Institute a process of merging all code and other implementation artifacts frequently, with automated tests to flag fragmentation quickly. Relentlessly exercise the ubiquitous language to hammer out a shared view of the model as the concepts evolve in different people’s heads.

Context map

An individual bounded context leaves some problems in the absence of a global view. The context of other models may still be vague and in flux.

People on other teams won’t be very aware of the context bounds and will unknowingly make changes that blur the edges or complicate the interconnections. When connections must be made between different contexts, they tend to bleed into each other.

Therefore: Identify each model in play on the project and define its bounded context. This includes the implicit models of non-object-oriented subsystems. Name each bounded context, and make the names part of the ubiquitous language. Describe the points of contact between the models, outlining explicit translation for any communication and highlighting any sharing. Map the existing terrain.

Building blocks

In the book Domain-Driven Design,[2] a number of high-level concepts and practices are articulated, such as ubiquitous language meaning that the domain model should form a common language given by domain experts for describing system requirements, that works equally well for the business users or sponsors and for the software developers. The book is very focused on describing the domain layer as one of the common layers in an object-oriented system with a multilayered architecture. In DDD, there are artifacts to express, create, and retrieve domain models:EntityAn object that is not defined by its attributes, but rather by a thread of continuity and its identity.Example: Most airlines distinguish each seat uniquely on every flight. Each seat is an entity in this context. However, Southwest Airlines, EasyJet and Ryanair do not distinguish between every seat; all seats are the same. In this context, a seat is actually a value object.Value objectAn object that contains attributes but has no conceptual identity. They should be treated as immutable.Example: When people exchange business cards, they generally do not distinguish between each unique card; they are only concerned about the information printed on the card. In this context, business cards are value objects.AggregateA collection of objects that are bound together by a root entity, otherwise known as an aggregate root. The aggregate root guarantees the consistency of changes being made within the aggregate by forbidding external objects from holding references to its members.Example: When you drive a car, you do not have to worry about moving the wheels forward, making the engine combust with spark and fuel, etc.; you are simply driving the car. In this context, the car is an aggregate of several other objects and serves as the aggregate root to all of the other systems.Domain EventA domain object that defines an event (something that happens). A domain event is an event that domain experts care about.ServiceWhen an operation does not conceptually belong to any object. Following the natural contours of the problem, you can implement these operations in services. See also Service (systems architecture).RepositoryMethods for retrieving domain objects should delegate to a specialized Repository object such that alternative storage implementations may be easily interchanged.FactoryMethods for creating domain objects should delegate to a specialized Factory object such that alternative implementations may be easily interchanged.

Disadvantages

In order to help maintain the model as a pure and helpful language construct, the team must typically implement a great deal of isolation and encapsulation within the domain model. Consequently, a system based on domain-driven design can come at a relatively high cost. While domain-driven design provides many technical benefits, such as maintainability, Microsoft recommends that it be applied only to complex domains where the model and the linguistic processes provide clear benefits in the communication of complex information, and in the formulation of a common understanding of the domain.[3]

Relationship to other ideas

Object-oriented analysis and designAlthough, in theory, the general idea of DDD need not be restricted to object-oriented approaches, in practice DDD seeks to exploit the advantages that object-oriented techniques make possible. These include entities/aggregate roots as receivers of commands/method invocations and the encapsulation of state within foremost aggregate roots and on a higher architectural level, bounded contexts.Model-driven engineering (MDE) and Model-driven architecture (MDA)While DDD is compatible with MDA/MDE (where MDE can be regarded as a superset of MDA) the intent of the two concepts is somewhat different. MDA is concerned more with the means of translating a model into code for different technology platforms than with the practice of defining better domain models. The techniques provided by MDE (to model domains, to create DSLs to facilitate the communication between domain experts and developers,…) facilitate the application of DDD in practice and help DDD practitioners to get more out of their models. Thanks to the model transformation and code generation techniques of MDE, the domain model can be used not only to represent the domain but also to generate the actual software system that will be used to manage it. This picture shows a possible representation of DDD and MDE combined.Plain Old Java Objects (POJOs) and Plain Old CLR Objects (POCOs)POJOs and POCOs are technical implementation concepts, specific to Java and the .NET Framework respectively. However, the emergence of the terms POJO and POCO reflect a growing view that, within the context of either of those technical platforms, domain objects should be defined purely to implement the business behaviour of the corresponding domain concept, rather than be defined by the requirements of a more specific technology framework.The naked objects patternBased on the premise that if you have a good enough domain model, the user interface can simply be a reflection of this domain model; and that if you require the user interface to be a direct reflection of the domain model then this will force the design of a better domain model.[4]Domain-specific modeling (DSM)DSM is DDD applied through the use of Domain-specific languages.Domain-specific language (DSL)DDD does not specifically require the use of a DSL, though it could be used to help define a DSL and support methods like domain-specific multimodeling.Aspect-oriented programming (AOP)AOP makes it easy to factor out technical concerns (such as security, transaction management, logging) from a domain model, and as such makes it easier to design and implement domain models that focus purely on the business logic.Command Query Responsibility Segregation (CQRS)CQRS is an architectural pattern for separation of reads from writes, where the former is a Query and the latter is a Command. Commands mutate state and are hence approximately equivalent to method invocation on aggregate roots/entities. Queries read state but do not mutate it. CQRS is a derivative architectural pattern from the design pattern called Command and Query Separation (CQS) which was coined by Bertrand Meyer. While CQRS does not require DDD, domain-driven design makes the distinction between commands and queries explicit, around the concept of an aggregate root. The idea is that a given aggregate root has a method that corresponds to a command and a command handler invokes the method on the aggregate root. The aggregate root is responsible for performing the logic of the operation and yielding either a number of events or a failure (exception or execution result enumeration/number) response OR (if Event Sourcing (ES) is not used) just mutating its state for a persister implementation such as an ORM to write to a data store, while the command handler is responsible for pulling in infrastructure concerns related to the saving of the aggregate root’s state or events and creating the needed contexts (e.g. transactions).Event Sourcing (ES)An architectural pattern which warrants that your entities (as per Eric Evans’ definition) do not track their internal state by means of direct serialization or O/R mapping, but by means of reading and committing events to an event store. Where ES is combined with CQRS and DDD, aggregate roots are responsible for thoroughly validating and applying commands (often by means having their instance methods invoked from a Command Handler), and then publishing a single or a set of events which is also the foundation upon which the aggregate roots base their logic for dealing with method invocations. Hence, the input is a command and the output is one or many events which are transactionally (single commit) saved to an event store, and then often published on a message broker for the benefit of those interested (often the views are interested; they are then queried using Query-messages). When modeling your aggregate roots to output events, you can isolate the internal state even further than would be possible when projecting read-data from your entities, as is done in standard n-tier data-passing architectures. One significant benefit from this is that tooling such as axiomatic theorem provers (e.g. Microsoft Contracts and CHESS[5]) are easier to apply, as the aggregate root comprehensively hides its internal state. Events are often persisted based on the version of the aggregate root instance, which yields a domain model that synchronizes in distributed systems around the concept of optimistic concurrency.

Fair Use Sources:

Categories
Cloud Data Science - Big Data DevOps DevSecOps-Security-Privacy History Operating Systems Software Engineering

Software Design

Return to Timeline of the History of Computers, Networking

Software design is the process by which an agent creates a specification of a software artifact intended to accomplish goals, using a set of primitive components and subject to constraints.[1] Software design may refer to either “all the activity involved in conceptualizing, framing, implementing, commissioning, and ultimately modifying complex systems” or “the activity following requirements specification and before programming, as … [in] a stylized software engineering process.”[2]

Software design usually involves problem-solving and planning a software solution. This includes both a low-level component and algorithm design and a high-level, architecture design.

Fair Use Sources: