Member-only story

Single Responsibility Principle in Swift

Do yourself a SOLID

Steven Curtis
3 min readJan 28, 2021
Photo by dylan nolte on Unsplash

SOLID is a mnemonic acronym for five design principles intended to make software designs more understandable. Now applying them to Swift can be a little tricky, and this article has been written to make the Single Responsibility Principle easy to understand for new Swift Programmers.

This article also has a supporting YouTube video: https://youtu.be/e5ne2xnlMuI

Solid.

Difficulty: Beginner | Easy | Normal | Challenging

Terminology

Class: An object that defines properties and methods in common

Single Responsibility Principle: every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class, module or function

SOLID: a mnemonic acronym for five design principles intended to make software designs more understandable

The Single Responsibility Principle (SRP)

A class should only have a single reason to change.

In other words that means the following:

  1. A particular class should only do one thing

--

--

Responses (1)