Design Principles vs Design Patterns vs Architecture Design
Understanding what is Design Principles, Design Patterns, Architecture Design with examples.
Table of contents
Design Principles
Design principles are high-level guidelines that help us make sound design decisions. They provide general rules and best practices to follow during the development of software. Think of them as the "whys" of design.
Example: The Single Responsibility Principle (SRP) is a design principle. It suggests that a class should have only one reason to change. If we have a class responsible for handling user authentication, it should focus solely on authentication, not on unrelated tasks like user profile management.
Design Patterns
Design patterns are specific, reusable solutions to common design problems. They offer proven templates for addressing recurring issues in software design. Design patterns provide the "hows" of design by offering well-established solutions.
Example: The Factory Pattern is a design pattern. It's like a recipe for flexibly creating objects. Suppose we're developing a game, and you need different types of characters. The Factory Pattern helps you create instances of characters (e.g., warriors, mages, or archers) based on the input we provide.
Architecture Design
Architecture design is about creating a high-level structure for our entire software system. It defines how different components of our application interact, how data flows, and how various design patterns and principles fit together. It's like planning the layout of a house before building it.
Example: In a mobile application, we might use the Model-View-ViewModel (MVVM) architectural pattern. The Model would handle tasks, their statuses, and the logic for adding, deleting, or updating tasks. The View would be the user interface where tasks are displayed. The ViewModel would connect the Model to the View, handling things like displaying the list of tasks from the Model in the View, and updating the Model when a user adds or completes a task.
Learning
Design Principles: are general guidelines for making good design decisions.
Design Patterns: are specific solutions to common design problems.
Architectural Design: is the high-level plan for organizing your software system.
In simple: Design principles provide the theory, design patterns provide the solutions, and architecture design provides the overall structure.
That's it for today. Happy Coding...