Because of this design, a staple job would know about all the methods of the print job, even though there was no use for them. This resulted in a ‘fat’ class with multitudes of methods specific to a variety of different clients. Whenever a print job or a stapling job needed to be performed, a call was made to the Job class. The design problem was that a single Job class was used by almost all of the tasks. Bad design of a C++ program can lead to significant compilation time. The redeployment cycle took so much time because at that time there were no C# or Java, these languages compile very fast. #Interface segregation software#As the software grew, making modifications became more and more difficult so that even the smallest change would take a redeployment cycle of an hour, which made development nearly impossible. The software for this system was created from the ground up. Xerox had created a new printer system that could perform a variety of tasks such as stapling and faxing. He applied the ISP first time while consulting for Xerox. I’m pretty sure that ISP was first used long ago before Robert Martin, but the first public formulation belongs to Robert C. Here is an interesting historical note about the ISP. This obviously implies that if you have a public interface named IRequireFood, it would be silly to have methods like LaunchAircraft or KillCharacter exposed by that interface. This funny monster wants to eat and that’s why it says that if IRequireFood, then it means that I want to Eat some food, not light candelabra or layout cutlery. And of course, this is also a chance to get some fun. It’s always useful to look at a picture which illustrates the problem. Just in case, I’ll remind you that “cohesive” means that all the API members are logically related to each other. “The Interface Segregation Principle states that Clients should not be forced to depend on methods they do not use.”Ī simple conclusion that we can draw from this definition is that you should prefer small, cohesive interfaces to “fat” interfaces. So, simply put, an interface is what clients see and use.Ī great simple definition of the Interface Segregation Principle was given in the book you have already heard of, “Agile Principles, Patterns, and Practices in C#”. The set of public members of a class represents the interface of that class. What I mean is that classes which don’t implement any interfaces have their own interfaces comprised of publicly visible members. Such a construction defines an API, a shape which has to be implemented by inheritors of that interface.Īt the same time, it’s not necessary to implement an interface to expose an interface. Of course, “interface” is a reserved keyword in C# which allows to declare a non-implementable type consisting of member signatures. Interface Segregation Principle Definitionīefore giving a definition, I want to say a couple of words about what we mean here by the word “interface”. If you want an easier way of learning SOLID principles in depth, then I would recommend you taking my SOLID tutorial just for 10.99$. In this part of the SOLID series, we’re going to revisit the ISP or Interface Segregation Principle.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |