Básicamente “divide y vencerás”
Introducción
Principios SOLID en C# y .NET
Prerrequisitos
¿Qué son las buenas prácticas y el código limpio?
¿Qué son los principios SOLID?
Principio de responsabilidad única
Conociendo el principio de responsabilidad única
Aplicando el principio de responsabilidad única
Principio de abierto/cerrado
Conociendo el principio de abierto/cerrado
Aplicando el principio abierto/cerrado
Principio de sustitución de Liskov
Conociendo el principio de sustitución de Liskov
Aplicando el principio de sustitución de Liskov
Principio de segregación de la interfaz
Conociendo el principio de segregación de interfaces
Aplicando el principio de segregación de la interfaz
Principio de inversión de la dependencia
Conociendo el principio de inversión de la dependencia
Aplicando el principio de inversión de la dependencia - Parte I
Aplicando el principio de inversión de la dependencia - Parte II
Cierre
Resumen y cierre del curso de principios SOLID en C#
You don't have access to this class
Keep learning! Join and start boosting your career
The SOLID framework is fundamental to object-oriented programming and one of its cornerstones is the Single Responsibility Principle. This principle, known as the Single Responsibility Principle (SRP), states that each component within a system must have a single responsibility. This rule is crucial to ensure code cohesion and modularity, offering advantages such as increased maintainability and ease of testing.
When you implement the single responsibility principle in C# or any other language that supports object-oriented programming, each class or method must perform a specific task.
The single responsibility principle applies not only to methods and classes, but extends to other system components:
Let's analyze the following requirement: as a user, after confirming a purchase, I expect to receive a confirmation message, to be able to download an invoice and to receive a confirmation email. At first glance, this user demands three simultaneous actions, which, from a programming point of view, does not imply that we should create a single class or method that covers all these functions.
Instead of creating a monolithic solution, we should separate these actions into different components or services, each with its own defined responsibility.
In the course we will analyze a demo with a class called StudentRepository
. This class does not currently comply with the single responsibility principle. This will be a practical exercise to identify its deficiencies and refactor the code to comply with the SRP, ensuring that each part of the system maintains a single specific task.
In conclusion, effective use of the Single Responsibility Principle not only improves code structure and maintainability, but also paves the way for future extensions, making them less error prone and easier to update. Keep learning and improving your programming skills!
Contributions 7
Questions 1
Básicamente “divide y vencerás”
Con este principio todo se hace más fácil, el manejo y la gestión
Single responsability principle
Se trata de distribuir las responsabilidades de un software en un grupo de componentes, haciendo que cada componente tenga una única responsabilidad. Aplica para:
Pincipio de responsabilidad unica
Distribuir las responsabilidades de un sistema entre sus componentes, donde cada uno solo tengo una responsabilidad.
Pudiera parecer que a la larga pudiéramos llenarnos de muchos archivos o componentes, pero en la experiencia que tengo, es mucho mejor tener dividido y apoyado de un buen naming, será muy sencillo administrarlo.
Buen curso
Want to see more contributions, questions and answers from the community?