31 lines
1004 B
Java
31 lines
1004 B
Java
package facade;
|
|
|
|
/**
|
|
* Facade Design Pattern — Runnable Demo
|
|
*
|
|
* Demonstrates reducing a complex video conversion subsystem
|
|
* to a single method call via a Facade.
|
|
*
|
|
* Run: javac facade/*.java && java facade.Main
|
|
* Article: https://ankurm.com/facade-design-pattern-java/
|
|
*/
|
|
public class Main {
|
|
|
|
public static void main(String[] args) {
|
|
System.out.println("=== Facade Design Pattern Demo ===\n");
|
|
|
|
VideoConversionFacade converter = new VideoConversionFacade();
|
|
|
|
System.out.println("-- Client: just one method call --");
|
|
String result1 = converter.convertVideo("holiday.ogg", "mp4");
|
|
System.out.println("Output: " + result1);
|
|
|
|
System.out.println();
|
|
String result2 = converter.convertVideo("presentation.mp4", "ogg");
|
|
System.out.println("Output: " + result2);
|
|
|
|
System.out.println("\nClient code: 1 line. Subsystem: 6 classes. Facade hides the complexity.");
|
|
System.out.println("\n=== Demo complete ===");
|
|
}
|
|
}
|