Closed Coupled : Decouple « Spring « Java






Closed Coupled

       
File: Main.java

import java.io.PrintStream;

public class Main {
  public static void main(String[] a) {
    MessageData source = new MessageData("Hello, world");
    MessageReporter destination = new MessageReporter();
    destination.write(System.out, source.getMessage());
  }
}

final class MessageData {
  private final String message;

  public MessageData(String message) {
    this.message = message;
  }

  public String getMessage() {
    return message;
  }
}

class MessageReporter {

  public void write(PrintStream out, String message) {
    out.println(message);
  }

}




           
       








Spring-ClosedCoupled.zip( 2,562 k)

Related examples in the same category

1.Decouple With Interface
2.Spring Style Decouple
3.Spring Prototype