Add all 23 GoF design pattern implementations (2026-06-13)
This commit is contained in:
24
03-behavioral/template-method/Main.java
Normal file
24
03-behavioral/template-method/Main.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package template;
|
||||
|
||||
/**
|
||||
* Template Method Design Pattern — Runnable Demo
|
||||
* Run: javac template/*.java -d out/template && java -cp out/template template.Main
|
||||
* Article: https://ankurm.com/template-method-design-pattern-java/
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=== Template Method Design Pattern Demo ===");
|
||||
|
||||
DataMigration csvJob = new CsvMigration("customers_export.csv");
|
||||
csvJob.migrate();
|
||||
|
||||
DataMigration apiJob = new ApiMigration("https://api.partner.com/v2/orders");
|
||||
apiJob.migrate();
|
||||
|
||||
System.out.println("-- Both jobs used the same migrate() skeleton --");
|
||||
System.out.println("-- Each provided its own connect/read/transform implementation --");
|
||||
System.out.println("-- ApiMigration overrode the sendNotification() hook: no email --");
|
||||
|
||||
System.out.println("\n=== Demo complete ===");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user