Skip to content

Instantly share code, notes, and snippets.

@malalanayake
Created April 12, 2016 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malalanayake/07cf4ea643f98901735be06477505757 to your computer and use it in GitHub Desktop.
Save malalanayake/07cf4ea643f98901735be06477505757 to your computer and use it in GitHub Desktop.
Interface Segregation Principal - Good sample code
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();
}
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]");
}
}
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]");
}
}
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