Sunday, May 1, 2016

Interface Segregation Principle

This is another principle developed by Robert Martin who I have had the great pleasure to see speak several times at conferences.  He is a very lively speaker and you return to coding wanting to do your best work after you see him speak.  As for a skilled software craftsman, he is at the top of his game. 

ISP says that no client should be forced to depend on methods it doesn't use.  Martin came up with this when he was consulting with Xerox.  He found they had a job class that was used for every single task in the system.   A stapling job shouldn't have to know anything about a print job and all the methods for printing.

OK people I work for Xerox and there nothing called  Staple Job.  Stapling is an attribute on a job.  Print jobs can have an attribute that says staple me.  But so can Copy jobs.  So I'm not sure where he saw this but maybe it was a looong time ago. 

In practice when working with Microsoft Windows for example, there are what I call "Big A!& Classes".  They are huge with a bazillion attributes and methods.  Often I don't care about 9/10ths of them. I search through the documentation for what I need.  This is one of many interfaces I have used and dare say I have created that violate this principle. 

However, when I create an interface, I literally fight people to the bone to keep it simple.  More functionality is desired and interfaces get new methods and before you know it, you have a massive class with more methods and data then any sane person can keep straight.  I have to argue quite a bit to keep it simple - deadlines are tight and people don't want to do the extra work for this principle. 

On the flip side, I think this principle could be considered "too pure" for many software engineers.  And engineers I talk to about this principle find it too difficult to practice in a real word setting.  They understand it intellectually but don't see the benefits.   Testing is one huge benefit.  If you have a massive class for a job you would have to implement the print functions even for a staple job (which doesn't exist, just saying…).  Even if it was a no-op, you'd have to test it.


Testing takes up over half of our development activities.  So if you can save on that, ISP is worth it! 

23 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Magicjack Support- 1-800-653-4096
    www.completepcsolution.net/magicjack-support.html
    Magicjack Installation
    magicjack customer support
    support for magicjack
    contact for magicjack

    ReplyDelete
  3. Thanks for provide the best interface segregation principle. Free PC Optimizer
    Can Crusher

    ReplyDelete
  4. Magicjack Support 1-800-653-4096,
    Customer Support For Magicjack

    COMPLETEPCSOLUTION is one of the best way to resolve
    all problems like magicjack technical support,
    magicjack customer suppport and installation,
    magicjack contact number

    ReplyDelete
  5. There is so much in this article that I would never thought of on my own. Your content gives readers things to think about in an interesting way. Thank you for your clear information.
    architects in rawalpindi

    ReplyDelete
  6. Magicjack Support 1-800-653-4096,
    Customer Support For Magicjack
    COMPLETEPCSOLUTION is one of the best way to resolve
    all problems like magicjack technical support,
    magicjack customer suppport and installation,
    magicjack contact number.

    ReplyDelete
  7. Nicely written. Thanks for google that found page like this. Maybe youe heard something about AxadSystem and you can share it?

    ReplyDelete
  8. Nice information on software. However if you want to experience the best software go to the Best Freelancing Portal in India

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Thank you for sharing interior designing blog I am satisfied with your site and your posts they very nice and very useful to us I got such a good information on this topic it’s very interesting one.to know more about

    Architects in Chennai
    Architectural Firms in Chennai

    ReplyDelete
  11. very attractive for designing the luxuries house thanks for sharing this on your blog. Thanks for this post.

    Office Interiors in Chennai

    Best Interior Designers in Chennai

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. cinema box app android is an app that allows you to watch movies for free without any terms and conditions. all you have to download the appp froom the site and install it.

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. NETSOL Technologies Inc is a worldwide provider of global IT
    and enterprise application solutions which include credit and finance portfolio management systems,
    SAP consulting, custom development, systems integration and technical services.Asset Finance Software
    https://www.netsoltech.com/

    ReplyDelete
  16. NETSOL Technologies Inc is a worldwide provider of global IT
    and enterprise application solutions which include credit and finance portfolio management systems,
    SAP consulting, custom development, systems integration and technical services. Asset Finance Software
    Asset Finance Software

    ReplyDelete
  17. Exkash.com is reliable and most trusted instant exchange bitcoin to bank account transfer cryptocurrency withdraw btc to bank cash dollars conversion live.
    Bitcoin to Bank Account

    ReplyDelete
  18. Crystal water is Georgia pools builders company with budget friendly customs solutions based in atlanta swimming
    pool contractors near me creative design.

    ReplyDelete