diff --git a/Lectures/05 Software Design Principles/02 Single-Responsibility Principle (SRP).ipynb b/Lectures/05 Software Design Principles/02 Single-Responsibility Principle (SRP).ipynb index 6922bb5..1118610 100644 --- a/Lectures/05 Software Design Principles/02 Single-Responsibility Principle (SRP).ipynb +++ b/Lectures/05 Software Design Principles/02 Single-Responsibility Principle (SRP).ipynb @@ -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": [ - "" + "## 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": [ - "" + "" ] }, { "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": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Swiss Army Knife vs. Specialized Tools" ] }, { @@ -52,6 +69,37 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Single-Responsibility Principle (SRP)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "" + ] + }, + { + "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": {}, diff --git a/Lectures/05 Software Design Principles/images/multi-purpose-keys-vs-single-function-keys.png b/Lectures/05 Software Design Principles/images/multi-purpose-keys-vs-single-function-keys.png new file mode 100644 index 0000000..b24e974 Binary files /dev/null and b/Lectures/05 Software Design Principles/images/multi-purpose-keys-vs-single-function-keys.png differ diff --git a/README.md b/README.md index 266d69e..6b59ff9 100644 --- a/README.md +++ b/README.md @@ -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)