{"id":78,"date":"2020-05-18T09:23:41","date_gmt":"2020-05-18T09:23:41","guid":{"rendered":"https:\/\/turtleflyblog.com\/?p=78"},"modified":"2022-02-28T10:13:27","modified_gmt":"2022-02-28T10:13:27","slug":"solid-isp","status":"publish","type":"post","link":"https:\/\/turtleflyblog.com\/en\/2020\/05\/18\/solid-isp\/","title":{"rendered":"SOLID principle \u2013 ISP"},"content":{"rendered":"\n
This article introduces one of solid principles which is ISP (Interface Segregation Principle).<\/p>\n\n\n\n
It is better to build a small-sized interface than a heavy interface as a small-size interface is easier to refactor and decouple.<\/p>\n\n\n\n
Too many is better than too few<\/em><\/p>\n\n\n\n For example, you have IAnimal<\/strong> interface which has three methods(eat, move and sleep)<\/p>\n\n\n\n The above IAnimal interface works on most animals such as bear, elephant and tiger, etc. However, if you want plant class to implement IAnimal<\/strong> interface, you will notice that most behaviors of IAnimal interface does not work on plant.<\/p>\n\n\n\n However, if we can break IAnimal interface into three small interfaces (eat, sleep, move). Plant can\u2019t move and sleep, but it can eat as it can consume energy and release oxygen. Hence, eat behavior can work on Plant interface<\/p>\n\n\n\n The above example proves that a small interface is more useful than a large interface.<\/p>\n","protected":false},"excerpt":{"rendered":" This article introduces one of solid principles which is ISP (Interface Segregation Principle). It is better to build a small-sized interface than a heavy interface as a small-size interface is easier to refactor and decouple. Too many is better than too few For example, you have IAnimal interface which has three methods(eat, move and sleep) […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[31],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-software-engineering"],"yoast_head":"\n<\/figure>\n\n\n\n
<\/figure>\n\n\n\n