Created
April 12, 2016 18:42
-
-
Save malalanayake/07cf4ea643f98901735be06477505757 to your computer and use it in GitHub Desktop.
Interface Segregation Principal - Good sample code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample.design.Interface.segregation.good; | |
/** | |
* | |
* Distibution under GNU GENERAL PUBLIC LICENSE Version 2, June 1991 | |
* | |
* @author dmalalan | |
* @created Apr 12, 2016 1:23:31 PM | |
* | |
* @blog https://malalanayake.wordpress.com/ | |
*/ | |
public interface Feedable { | |
public void eat(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample.design.Interface.segregation.good; | |
/** | |
* | |
* Distibution under GNU GENERAL PUBLIC LICENSE Version 2, June 1991 | |
* | |
* @author dmalalan | |
* @created Apr 12, 2016 1:25:34 PM | |
* | |
* @blog https://malalanayake.wordpress.com/ | |
*/ | |
public class HumanNew implements Workable, Feedable { | |
public void startWork() { | |
System.out.println("[START:Working Human]"); | |
} | |
public void stopWork() { | |
System.out.println("[STOP:Working Human]"); | |
} | |
public void eat() { | |
System.out.println("[EAT:Lunch Human]"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample.design.Interface.segregation.good; | |
/** | |
* | |
* Distibution under GNU GENERAL PUBLIC LICENSE Version 2, June 1991 | |
* | |
* @author dmalalan | |
* @created Apr 12, 2016 1:27:46 PM | |
* | |
* @blog https://malalanayake.wordpress.com/ | |
*/ | |
public class RobotNew implements Workable { | |
public void startWork() { | |
System.out.println("[START:Working Robot]"); | |
} | |
public void stopWork() { | |
System.out.println("[STOP:Working Robot]"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample.design.Interface.segregation.good; | |
/** | |
* | |
* Distibution under GNU GENERAL PUBLIC LICENSE Version 2, June 1991 | |
* | |
* @author dmalalan | |
* @created Apr 12, 2016 1:23:31 PM | |
* | |
* @blog https://malalanayake.wordpress.com/ | |
*/ | |
public interface Workable { | |
public void startWork(); | |
public void stopWork(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment