Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

S.O.L.I.D principles and compilation? [closed]

For example , regarding Single Responsibility principle :

Let's talk about a Radio class :

enter image description here

One could argue that the Radio class has two responsibilities, being volume and station management. These operations will be called from completely different areas of the client using it.

hence we have this :

enter image description here

All fine.

But I always see sentences like these :

So now when we need a change , all the code depending on the broken component don’t even need to be recompiled.

Wait a minute !

If I need to change the VolumeManager class - I will not have to recompile Radio and StationManager. But I will have to stop ( in web) the iis in order for the application to use the new DLL, and it will cause the application down.

Also , in console , I will have to terminate the whole program in order to change the dll since it is locked by the process ( you cant change dll when the app is running - the file is locked)

even when I'll use the GAC - I will have to stop the proram in order to chagne the dll.

so what does it save me ? compile is just - right click and build. thats all

I'm not seeing the benefit of mentioning : "you will need to compile only the broken class.."

What Am I missing ?

http://www.gontu.org/solid-single-responsibility-principle/ look for the word "build"

http://epic.tesio.it/doc/manual/solid_principles.html look for the word "recompiled"

http://www.dananhudson.com/?tag=solid look for the word "recompile"

like image 840
Royi Namir Avatar asked Dec 23 '12 08:12

Royi Namir


People also ask

Are SOLID principles still valid?

According to Orner, while the practice of software development has changed in the past 20 years, SOLID principles are still the basis of good design. The author explains how they also apply to functional programming and microservices architecture, with examples.

What does closed modification mean?

In object-oriented programming, the open–closed principle states "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification"; that is, such an entity can allow its behaviour to be extended without modifying its source code.

Which design pattern uses Open-Closed Principle?

In a nutshell, the developer must need to change only a specific part of the code (a class or a function) every time a requirement changes. Using a statically typed language like Java, C#, etc. the open/closed principle is generally achieved by using inheritance and polymorphism.

Which of the following is Open-Closed Principle?

Definition of the Open/Closed Principle Bertrand Meyer wrote about it in 1988 in his book Object-Oriented Software Construction. He explained the Open/Closed Principle as: “Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.”


2 Answers

Forget compile time, Forget application restart.

SOLID is about clean code and maintainability. It is not about anything at runtime, it's about the code getting more complicated over time and hard to maintain, and that is where the real cost is.

like image 93
TomTom Avatar answered Sep 17 '22 22:09

TomTom


There are situations where it is "politically" easier to deploy an update to an existing application if you can show that the changes are limited in scope: if only one DLL has to be updated, for example. (note that this does not mean that every class should be in its own DLL. But most likely, not all your classes are in the same DLL)

However, the other advantage is more conceptual: if I don't have to recompile a DLL, then I know for sure that I didn't break anything in it. The less code has to be touched, the less chance there is of me introducing a bug.

like image 39
jalf Avatar answered Sep 17 '22 22:09

jalf