2626import java .util .List ;
2727
2828/**
29- *
30- * Layers is an architectural style where software responsibilities are divided among the different layers of the
31- * application.
32- * <p>
33- * This example demonstrates a traditional 3- layer architecture consisting of data access layer , business layer and
34- * presentation layer.
35- * <p>
36- * The data access layer is formed of Spring Data repositories <code>CakeDao </code>, <code>CakeToppingDao </code> and
37- * <code>CakeLayerDao</code>. The repositories can be used for CRUD operations on cakes, cake toppings and cake layers
38- * respectively.
39- * <p>
40- * The business layer is built on top of the data access layer. <code>CakeBakingService</code> offers methods to
41- * retrieve available cake toppings and cake layers and baked cakes. Also the service is used to create new cakes out of
42- * cake toppings and cake layers.
43- * <p>
44- * The presentation layer is built on the business layer and in this example it simply lists the cakes that have been
45- * baked.
46- * <p>
47- * We have applied so called strict layering which means that the layers can only access the classes directly beneath
48- * them. This leads the solution to create an additional set of DTOs ( <code>CakeInfo</code>,
49- * <code>CakeToppingInfo</code>, <code>CakeLayerInfo</code>) to translate data between layers. In other words,
50- * <code>CakeBakingService </code> cannot return entities ( <code>Cake </code>, <code>CakeTopping </code>,
51- * <code>CakeLayer</code>) directly since these reside on data access layer but instead translates these into business
52- * layer DTOs (<code>CakeInfo</code>, <code>CakeToppingInfo</code>, <code>CakeLayerInfo</code>) and returns them
53- * instead. This way the presentation layer does not have any knowledge of other layers than the business layer and thus
54- * is not affected by changes to them.
29+ * Layers is an architectural style where software responsibilities are divided among the
30+ * different layers of the application.
31+ *
32+ * <p>This example demonstrates a traditional 3-layer architecture consisting of data access
33+ * layer, business layer and presentation layer.
34+ *
35+ * <p>The data access layer is formed of Spring Data repositories <code>CakeDao</code>,
36+ * <code>CakeToppingDao </code> and <code>CakeLayerDao </code>. The repositories can be used
37+ * for CRUD operations on cakes, cake toppings and cake layers respectively.
38+ *
39+ * <p>The business layer is built on top of the data access layer. <code>CakeBakingService</code>
40+ * offers methods to retrieve available cake toppings and cake layers and baked cakes. Also the
41+ * service is used to create new cakes out of cake toppings and cake layers.
42+ *
43+ * <p>The presentation layer is built on the business layer and in this example it simply lists
44+ * the cakes that have been baked.
45+ *
46+ * <p>We have applied so called strict layering which means that the layers can only access the
47+ * classes directly beneath them. This leads the solution to create an additional set of DTOs
48+ * ( <code>CakeInfo</code>, <code>CakeToppingInfo</code>, <code>CakeLayerInfo</code>) to translate
49+ * data between layers. In other words, <code>CakeBakingService</code> cannot return entities
50+ * ( <code>Cake </code>, <code>CakeTopping </code>, <code>CakeLayer </code>) directly since these
51+ * reside on data access layer but instead translates these into business layer DTOs
52+ * (<code>CakeInfo</code>, <code>CakeToppingInfo</code>, <code>CakeLayerInfo</code>) and returns
53+ * them instead. This way the presentation layer does not have any knowledge of other layers than
54+ * the business layer and thus is not affected by changes to them.
5555 *
5656 * @see Cake
5757 * @see CakeTopping
@@ -70,7 +70,7 @@ public class App {
7070 private static CakeBakingService cakeBakingService = new CakeBakingServiceImpl ();
7171
7272 /**
73- * Application entry point
73+ * Application entry point.
7474 *
7575 * @param args Command line parameters
7676 */
@@ -85,7 +85,7 @@ public static void main(String[] args) {
8585 }
8686
8787 /**
88- * Initializes the example data
88+ * Initializes the example data.
8989 */
9090 private static void initializeData (CakeBakingService cakeBakingService ) {
9191 cakeBakingService .saveNewLayer (new CakeLayerInfo ("chocolate" , 1200 ));
@@ -108,10 +108,10 @@ private static void initializeData(CakeBakingService cakeBakingService) {
108108 } catch (CakeBakingException e ) {
109109 e .printStackTrace ();
110110 }
111- CakeInfo cake2 =
112- new CakeInfo ( new CakeToppingInfo ( "cherry " , 0 ), List . of (
113- new CakeLayerInfo ("vanilla" , 0 ), new CakeLayerInfo ( " lemon" , 0 ), new CakeLayerInfo (
114- "strawberry" , 0 )));
111+ CakeInfo cake2 = new CakeInfo ( new CakeToppingInfo ( "cherry" , 0 ), List . of (
112+ new CakeLayerInfo ( "vanilla " , 0 ),
113+ new CakeLayerInfo ("lemon" , 0 ),
114+ new CakeLayerInfo ( "strawberry" , 0 )));
115115 try {
116116 cakeBakingService .bakeNewCake (cake2 );
117117 } catch (CakeBakingException e ) {
0 commit comments