MVC, MVP, MVVM, MVVM-C, and VIPER
So, let's talk about these software architecture patterns. Each one offers a different approach to organize your code and keep things clean and tidy.
MVC - the OG
This classic pattern divides your app into three parts: Model (the data), View (what your users see), and Controller (the glue that connects them). It's great for simple web apps where you want clear separation between data and presentation, but be careful not to overload the Controller with too much logic.
MVP - more control for presenters
Similar to MVC, but instead of a Controller, you have a Presenter that handles the logic and state management. This makes the View more passive, just displaying what the Presenter tells it to. MVP is perfect for complex interfaces where you need more control and easier testing.
MVVM - data binding
Here, the ViewModel takes center stage. This middleman handles data manipulation and logic. It binds your View directly to your Model. This means less code and a more straightforward way to build user interfaces, especially with modern frameworks.
MVVM-C - navigation made easy
When your MVVM app starts getting tangled with navigation logic, bring in the Coordinator. This component controls how your users move around your app. This keeps the ViewModel clean and focused on data.
VIPER - extreme modularity
This pattern is about clean separation of concerns. Each component has a specific job: View (display), Presenter (presentation logic), Interactor (business logic), Entity (data models), and Router (navigation). It's for complex apps where you need strict modularity for easier testing and maintenance.
Choosing the right pattern depends on your project's specific needs. Think about your team size, app complexity, and how important scalability is. Which pattern speaks to your needs the most?
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/kNfv0DVDdf
CAP, BASE, SOLID, KISS, What do these acronyms mean?
The diagram below explains the common acronyms in system designs.
🔹 CAP
CAP theorem states that any distributed data store can only provide two of the following three guarantees:
1. Consistency - Every read receives the most recent write or an error.
2. Availability - Every request receives a response.
3. Partition tolerance - The system continues to operate in network faults.
However, this theorem was criticized for being too narrow for distributed systems, and we shouldn’t use it to categorize the databases. Network faults are guaranteed to happen in distributed systems, and we must deal with this in any distributed systems.
You can read more on this in “Please stop calling databases CP or AP” by Martin Kleppmann.
🔹 BASE
The ACID (Atomicity-Consistency-Isolation-Durability) model used in relational databases is too strict for NoSQL databases. The BASE principle offers more flexibility, choosing availability over consistency. It states that the states will eventually be consistent.
🔹 SOLID
SOLID principle is quite famous in OOP. There are 5 components to it.
1. SRP (Single Responsibility Principle)
Each unit of code should have one responsibility.
2. OCP (Open Close Principle)
Units of code should be open for extension but closed for modification.
3. LSP (Liskov Substitution Principle)
A subclass should be able to be substituted by its base class.
4. ISP (Interface Segregation Principle)
Expose multiple interfaces with specific responsibilities.
5. DIP (Dependency Inversion Principle)
Use abstractions to decouple dependencies in the system.
🔹 KISS
"Keep it simple, stupid!" is a design principle first noted by the U.S. Navy in 1960. It states that most systems work best if they are kept simple.
Over to you: Have you invented any acronyms in your career?
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/uc5M7CdXXC
SOLID principles explained.
SOLID represents five principles of object-oriented programming. Whether or not you use OOP, knowing these principles gives you a lens into the foundations of clean code which can be applied to many areas of programming.
S — Single Responsibility Principle
O — Open/Closed Principle
L — Liskov Substitution Principle
I — Interface Segregation Principle
D — Dependency Inversion Principle
Let’s break down each principle:
1. Single Responsibility Principle (SRP)
Each unit of code should only have one job or responsibility. A unit can be a class, module, function, or component. This keeps code modular and removes the risk of tight coupling.
2. Open-Closed Principle (OCP)
Units of code should be open for extension but closed for modification. You should be able to extend functionality with additional code rather than modifying existing ones. This principle can be applied to component-based systems such as a React frontend.
3. Liskov Substitution Principle (LSP)
You should be able to substitute objects of a base class with objects of its subclass without altering the ‘correctness’ of the program.
An example of this is with a Bird base class. You might assume that it should have a ‘fly’ method. But what about the birds that can’t fly? Like a Penguin. In this example, having a ‘fly’ method in the Bird class would violate LSP.
4. Interface Segregation Principle (ISP)
Provide multiple interfaces with specific responsibilities rather than a small set of general-purpose interfaces. Clients shouldn’t need to know about the methods & properties that don't relate to their use case.
Complexity ↓
Code flexibility ↑
5. Dependency Inversion Principle (DIP)
You should depend on abstractions, not on concrete classes. Use abstractions to decouple dependencies between different parts of the systems. Direct calls between units of code shouldn’t be done, instead interfaces or abstractions should be used.
Understand Docker in 3 Easy Steps 🚀
Docker provides lightweight virtualization on your desktop using containers. Here's what happens when you "docker build", "docker pull", "docker run":
1. Docker Client talks to the Docker Daemon
2. Docker Daemon manages containers and images
3. Docker Registry stores images like on Docker Hub
When you "docker run" a container:
- Pull image from registry if not cached locally
- Create new container
- Give it a filesystem
- Connect to network
- Start container
Docker uses containerization, not hardware virtualization. Containers share the host kernel so a full OS image isn't needed.
Docker isolates resources with cgroups and namespaces without duplication. Containers get their own filesystem but don't duplicate the full OS.
The layered filesystems allow efficient use of storage and quick duplication of container environments.
Docker is a great packaging technology - bundling the app, libraries, dependencies - everything needed to run. This standardized packaging makes Docker images popular in the cloud, even when container runtimes like containerd or CRI-O are used instead of Docker itself.
So Docker provides lightweight virtualization on desktops, while also being an excellent packaging technology for apps in the cloud.
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/kNfv0DVDdf
SOLID principle is one of the most important design principles in OOP languages like Java, Python, C#, etc.
Sadly, most of the programmers find it super difficult to understand.
Here's the simplest guide to understand SOLID principles:
𝗗𝗲𝘃𝗢𝗽𝘀 𝗮𝘀 𝗮 𝗕𝘂𝗿𝗴𝗲𝗿 (𝗗𝗮𝗮𝗕)
What should the DevOps engineer roadmap look like:
𝟭. 𝗟𝗲𝗮𝗿𝗻 𝗮 𝗽𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 𝗹𝗮𝗻𝗴𝘂𝗮𝗴𝗲 (Python, Go, ...) to write automation scripts
𝟮. 𝗠𝗮𝘀𝘁𝗲𝗿 𝗼𝗻𝗲 𝗼𝗽𝗲𝗿𝗮𝘁𝗶𝗻𝗴 𝘀𝘆𝘀𝘁𝗲𝗺 (Linux) and its command-line interface (CLI)
𝟯. 𝗠𝗮𝘀𝘁𝗲𝗿 𝘀𝗲𝗿𝘃𝗲𝗿 𝗺𝗮𝗻𝗮𝗴𝗲𝗺𝗲𝗻𝘁, web servers, including proxies such as Nginx or IIS
𝟰. 𝗘𝘅𝗽𝗹𝗼𝗿𝗲 𝗰𝗼𝗻𝘁𝗮𝗶𝗻𝗲𝗿𝗶𝘇𝗮𝘁𝗶𝗼𝗻 𝘂𝘀𝗶𝗻𝗴 𝗗𝗼𝗰𝗸𝗲𝗿
𝟱. 𝗖𝗵𝗲𝗰𝗸 𝗰𝗼𝗻𝘁𝗮𝗶𝗻𝗲𝗿 𝗼𝗿𝗰𝗵𝗲𝘀𝘁𝗿𝗮𝘁𝗶𝗼𝗻 𝘄𝗶𝘁𝗵 𝗞𝘂𝗯𝗲𝗿𝗻𝗲𝘁𝗲𝘀
𝟲. 𝗨𝗻𝗹𝗼𝗰𝗸 𝗜𝗻𝗳𝗿𝗮𝘀𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲 𝗮𝘀 𝗖𝗼𝗱𝗲 (IaC) using tools like Terraform, Ansible, Chef, or Puppet for provisioning and configuration management
𝟳. 𝗨𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱 𝗻𝗲𝘁𝘄𝗼𝗿𝗸 𝗽𝗿𝗼𝘁𝗼𝗰𝗼𝗹𝘀: DNS, IP addresses, ports, and the OSI model
𝟴. 𝗘𝗺𝗯𝗿𝗮𝗰𝗲 𝗖𝗼𝗻𝘁𝗶𝗻𝘂𝗼𝘂𝘀 𝗜𝗻𝘁𝗲𝗴𝗿𝗮𝘁𝗶𝗼𝗻/𝗖𝗼𝗻𝘁𝗶𝗻𝘂𝗼𝘂𝘀 𝗗𝗲𝗽𝗹𝗼𝘆𝗺𝗲𝗻𝘁 (𝗖𝗜/𝗖𝗗) 𝗽𝗿𝗮𝗰𝘁𝗶𝗰𝗲𝘀 for automating app delivery and deployment stages
𝟵. 𝗠𝗮𝘀𝘁𝗲𝗿 𝗺𝗼𝗻𝗶𝘁𝗼𝗿𝗶𝗻𝗴 𝘁𝗲𝗰𝗵𝗻𝗶𝗾𝘂𝗲𝘀 for real-time oversight of applications, services, and infrastructure
𝟭𝟬. 𝗚𝗮𝗶𝗻 𝗵𝗮𝗻𝗱𝘀-𝗼𝗻 𝗲𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲 𝘄𝗶𝘁𝗵 𝗖𝗹𝗼𝘂𝗱 𝗽𝗿𝗼𝘃𝗶𝗱𝗲𝗿𝘀 like AWS and Azure.
To learn more about it, check out my complete DevOps roadmap for 2023 in the comments.
_______
If you like my posts, please follow me, @milan_milanovic, and hit the 🔔 on my profile to get a notification for all my new posts.
Grow with me 🚀!
#technology #softwareengineering #programming #techworldwithmilan #devops