WHAT & WHY ?
SOLID principles are the guidelines or standards which can help to develop a software codebase which is

  • Easy to read and understand logically
  • Easy to modify/change
  • Easy to maintain

When we develop any software we create components like classes, interfaces, structs, functions etc, this SOLID principles give us a valid reason where and when to employ them.

And if we don’t use them our decisions for writing code for these entities will have arbitrariness. …


Robert C. Martin’s defined the of the DIP as below with two parts

High-level modules should not depend on low-level modules. Both should depend on abstractions.

Abstractions should not depend on details. Details should depend on abstractions.

What is High-level and Low-level?

High level meaning the business requirement and low-level means the technical details, how that is implemented. For example Payment Processing can called higher level of module and how it is done technically using Visa’s framework, Internet banking etc are the lower level details.

Here is one more example, Loading the feed depending on the Network which is a…


“No client should be forced to depend on methods it does not use.”

Real World Analogy: Suppose, you go to a market to buy a charger for your iPhone.And you purchased a charger which has iPhone plug but also has Samsung, Nokia and Moto plugs too, which you never gonna use. That’s what an ISP solves, making sure you get an iPhone charger only.

Sometimes when we create interfaces we see the

  • Empty implementations
  • Big Interface with too many methods
  • Methods are not relevant to each other (Low Cohesion)

This all indicates the violation of ISP.

To understand this lets…


LSV is actually an extension to OCP.
Meaning, it helps to correct your OCP implementation correct way.

If S is a subtype of T, then objects of type T may be replaced with objects of type S, without breaking the program

Inheritance:
Objects of a super class should be replaceable with the object of Sub Classes

Let understand this with a violation

class DeliveryProvider {
func deliver(to address: String) {
print("Package delviered to: \(address)")
}
} class ExpressDeliveryProvider { override func deliver(to address: String) { print("Package received, Press 1 key to proceed") // Wait for the user input waitForUserInput() {…

When a single change to a program results in a cascade of changes to modules using it, that sound like there is a “bad” design element, leading a program to become fragile, rigid, and un-reusable.

OCP attacks this in a very straightforward way.

An software entity should be open for an extension but close for the modification.

Means, It says that you should design modules that never change.When requirements change, you extend the behaviour of such modules by adding new code, not by changing old code that already works.

For example,

class CoreDataHelper { func save(_ data: String) { //…

A software entity should have only one responsibility or have only one reason to change.

Have you ever get confused or scratching your head 🤔, to find a proper name for a class, or method, etc.

If yes, It is the clear indication of the entity doing more than it is intended to do or have multiple responsibilities. aka Violating SRP guideline.

For Example, There is a ProductListScreen class have a function which should render product catalogue.

class ProductListScreen { func makeProductList() { // 1. Data Loading let productsArray = APIService.getProducts() // 2. Prepare UI element let productListView = ProductListView()…


This is the first part of the navigation in SwiftUI series. This post covers the implementation of NavigationView with title

Before we jump right into the how to build navigation and different use cases for the navigation, let’s warm up a bit first.

Navigation in any app is a very important component as it represents the screen, just like a container, in the navigation hierarchy. It is used to push and pop screens easily.
(Same thing as UINavigationController if you are familiar with UIKit)

Let’s start with a new application in XCode -> SwiftUI application

Basic NavigationView

All the SwiftUI component must…

Mohshin Shah

iOS Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store