Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,55 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Single-Responsibility Principle (SRP)"
"The Single-Responsibility Principle (SRP) is one of the core tenets of clean and maintainable software design, emphasizing that a class or module should have only one reason to change—essentially, one main job. This principle is not limited to code; it appears in everyday tools, technology, and human behavior. From multi-purpose keys on old feature phones to specialized smartphone interfaces, from the human misconception of multitasking to the contrast between a Swiss Army knife and dedicated tools, real-world examples help illustrate why focusing on a single responsibility often leads to greater clarity, efficiency, and usability. In this section, we explore several practical scenarios that bring SRP to life, showing how simplicity and specialization improve both software design and broader workflows."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"./images/solid/2.png\" width=\"800\">"
"## Real-World Examples of the Single-Responsibility"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What's the main idea behind SRP? It's simple:\n",
"### Multi-Purpose Keys in Old Phones vs. Single-Function Keys in Smartphones\n",
"\n",
"**A class should have just one job.**\n"
"Old feature phones—such as the Hope K19—relied on keys that served multiple purposes. A single button could type several letters, enter numbers, and even provide shortcuts depending on how long it was pressed. This design required users to adapt to a layered input system, where one key did the job of many.\n",
"\n",
"Modern smartphones, however, have transitioned to a single-function input model. Each on-screen key represents only one letter or number, and system functions are accessed through separate, dedicated buttons or gestures. This reflects a broader evolution in user experience: simplicity, clarity, and reduced cognitive load, replacing multitasking keys with more intuitive and direct interaction."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"./images/srp-velayati.jpeg\" width=\"800\">"
"<img src=\"./images/multi-purpose-keys-vs-single-function-keys.png\" width=\"800\">"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### The Illusion of Multitasking in Humans\n",
"\n",
"This means if your class is doing multiple things, it's time to split it up. For example, if you have a class that both reads files and zips them, you should have two separate classes: one for reading and one for zipping.\n"
"Humans often believe they can perform multiple tasks simultaneously, but research shows that true multitasking is largely a myth. Instead, the brain rapidly switches attention between tasks, which reduces efficiency and increases errors. In professional contexts, this highlights the importance of focusing on a single responsibility at a time, aligning with the Single-Responsibility Principle (SRP) to improve productivity and work quality."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"./images/srp-velayati.jpeg\" width=\"800\">"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Swiss Army Knife vs. Specialized Tools"
]
},
{
Expand All @@ -52,6 +69,37 @@
"<img src=\"./images/single-responsibility-principle.png\" width=\"500\">"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Single-Responsibility Principle (SRP)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"./images/solid/2.png\" width=\"800\">"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What's the main idea behind SRP? It's simple:\n",
"\n",
"**A class should have just one job.**\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"This means if your class is doing multiple things, it's time to split it up. For example, if you have a class that both reads files and zips them, you should have two separate classes: one for reading and one for zipping.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ Feel free to reach out to us!
- 💬 Telegram: [pytopia_ai](https://t.me/pytopia_ai)
- 🎥 YouTube: [pytopia](https://www.youtube.com/c/pytopia)
- 📸 Instagram: [pytopia.ai](https://www.instagram.com/pytopia.ai)
- 🎓 LinkedIn: [pytopia](https://www.linkedin.com/in/pytopia)
- 🎓 LinkedIn: [pytopia](https://www.linkedin.com/company/pytopia/)
- 🐦 Twitter: [pytopia_ai](https://twitter.com/pytopia_ai)
- 📧 Email: [pytopia.ai@gmail.com](mailto:pytopia.ai@gmail.com)