In a nutshell, the main difference between Single Responsibility Principle and Separation of Concerns is that SRP is isolated in a class in the form of one function, where as SoC is more spread out to how an MVC is structured. This quick video gives you a better idea of what this actually means. With each module focusing on just one task, this makes the flow of data more efficient and again easy to maintain. Each section is divided by modules, and each module should be in charge of a task. Visualize a Model View Controller (MVC) pattern, if you will. Separation of Concerns (SoC) also known as Aspect-Oriented Programming is a design principle for separating programming into distinctive sections so each section addresses a specific concern. This in turn makes your code more modular. So, let’s discuss some code smells which could indicate a violation of the ISP. Whether working solo or in larger teams, it helps to identify problems in code early. Code Smells for ISP Violations and How to Fix Them. And by and large, your definition of a concern may not match someone elses. Violating the ISP also leads to violation of other principles like the Single Responsibility Principle. do this, you ask? It gives a function in a class only ONE reason to change, which is the sole responsibility that that function has. A concern is simply defined as an area of interest in the application. The end goal is always striving for maintainable code. It's an extremely useful thing to remember for early stage developers like myself. ring a bell? Well, it stands for the "S" in S.O.L.I.D. Single responsibility principle (S.R.P.) is one of the five principles of object oriented programming (O.O.P.). Let's go back to the basics and try to review both of what these two major principles stand for. I was thinking out loud the other day and was wondering what the difference between single responsibility and separation of concerns is.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |