SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Implementation Techniques Software Architecture Lecture 16
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Recall Pipe-and-Filter ,[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Framework #1: stdio ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Evaluating stdio ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Framework #2: java.io ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Evaluating java.io ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Recall the C2 Style ,[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Framework #1: Lightweight C2 Framework ,[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Evaluating Lightweight C2 Framework ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Framework #2: Flexible C2 Framework ,[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Framework #2: Flexible C2 Framework Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Evaluating Flexible C2 Framework ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementing Pipe and Filter Lunar Lander ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Pipe and Filter Lunar Lander ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Pipe and Filter Lunar Lander ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GetBurnRate Filter //Import the java.io framework import java.io.*; public class GetBurnRate{ public static void main(String[] args){ //Send welcome message System.out.println(&quot;#Welcome to Lunar Lander&quot;); try{ //Begin reading from System input BufferedReader inputReader =  new BufferedReader(new InputStreamReader(System.in)); //Set initial burn rate to 0  int burnRate = 0; do{ //Prompt user System.out.println(&quot;#Enter burn rate or <0 to quit:&quot;); . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GetBurnRate Filter //Import the java.io framework import java.io.*; public class GetBurnRate{ public static void main(String[] args){ //Send welcome message System.out.println(&quot;#Welcome to Lunar Lander&quot;); try{ //Begin reading from System input BufferedReader inputReader =  new BufferedReader(new InputStreamReader(System.in)); //Set initial burn rate to 0  int burnRate = 0; do{ //Prompt user System.out.println(&quot;#Enter burn rate or <0 to quit:&quot;); . . . . . . //Read user response try{ String burnRateString = inputReader.readLine(); burnRate = Integer.parseInt(burnRateString); //Send user-supplied burn rate to next filter  System.out.println(&quot;%&quot; + burnRate); } catch(NumberFormatException nfe){ System.out.println(&quot;#Invalid burn rate.&quot;); } }while(burnRate >= 0); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Pipe and Filter Lunar Lander ,[object Object],[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
CalcBurnRate Filter import java.io.*; public class CalcNewValues{ public static void main(String[] args){ //Initialize values final int GRAVITY = 2; int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; try{ BufferedReader inputReader = new  BufferedReader(new InputStreamReader(System.in)); //Print initial values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
CalcBurnRate Filter import java.io.*; public class CalcNewValues{ public static void main(String[] args){ //Initialize values final int GRAVITY = 2; int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; try{ BufferedReader inputReader = new  BufferedReader(new InputStreamReader(System.in)); //Print initial values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); . . . String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) &&  (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and  //should be passed down the pipeline System.out.println(inputLine); } else if(inputLine.startsWith(&quot;%&quot;)){ //This is an input burn rate try{ int burnRate = Integer.parseInt(inputLine.substring(1)); if(altitude <= 0){ System.out.println(&quot;#The game is over.&quot;); } else if(burnRate > fuel){ System.out.println(&quot;#Sorry, you don't&quot; +  &quot;have that much fuel.&quot;); } . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
CalcBurnRate Filter import java.io.*; public class CalcNewValues{ public static void main(String[] args){ //Initialize values final int GRAVITY = 2; int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; try{ BufferedReader inputReader = new  BufferedReader(new InputStreamReader(System.in)); //Print initial values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); . . . String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) &&  (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and  //should be passed down the pipeline System.out.println(inputLine); } else if(inputLine.startsWith(&quot;%&quot;)){ //This is an input burn rate try{ int burnRate = Integer.parseInt(inputLine.substring(1)); if(altitude <= 0){ System.out.println(&quot;#The game is over.&quot;); } else if(burnRate > fuel){ System.out.println(&quot;#Sorry, you don't&quot; +  &quot;have that much fuel.&quot;); } . . . else{ //Calculate new application state time = time + 1; altitude = altitude - velocity; velocity = ((velocity + GRAVITY) * 10 - burnRate * 2) / 10; fuel = fuel - burnRate; if(altitude <= 0){ altitude = 0; if(velocity <= 5){ System.out.println(&quot;#You have landed safely.&quot;); } else{ System.out.println(&quot;#You have crashed.&quot;); } } } //Print new values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); } catch(NumberFormatException nfe){ } . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
CalcBurnRate Filter import java.io.*; public class CalcNewValues{ public static void main(String[] args){ //Initialize values final int GRAVITY = 2; int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; try{ BufferedReader inputReader = new  BufferedReader(new InputStreamReader(System.in)); //Print initial values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); . . . String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) &&  (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and  //should be passed down the pipeline System.out.println(inputLine); } else if(inputLine.startsWith(&quot;%&quot;)){ //This is an input burn rate try{ int burnRate = Integer.parseInt(inputLine.substring(1)); if(altitude <= 0){ System.out.println(&quot;#The game is over.&quot;); } else if(burnRate > fuel){ System.out.println(&quot;#Sorry, you don't&quot; +  &quot;have that much fuel.&quot;); } . . . else{ //Calculate new application state time = time + 1; altitude = altitude - velocity; velocity = ((velocity + GRAVITY) * 10 - burnRate * 2) / 10; fuel = fuel - burnRate; if(altitude <= 0){ altitude = 0; if(velocity <= 5){ System.out.println(&quot;#You have landed safely.&quot;); } else{ System.out.println(&quot;#You have crashed.&quot;); } } } //Print new values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); } catch(NumberFormatException nfe){ } . . . } } }while((inputLine != null) && (altitude > 0)); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Pipe and Filter Lunar Lander ,[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
DisplayValues Filter import java.io.*; public class DisplayValues{ public static void main(String[] args){ try{ BufferedReader inputReader = new  BufferedReader(new InputStreamReader(System.in)); String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) &&  (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and  //should be passed down the pipeline with  //the pound-sign stripped off System.out.println(inputLine.substring(1)); } . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
DisplayValues Filter import java.io.*; public class DisplayValues{ public static void main(String[] args){ try{ BufferedReader inputReader = new  BufferedReader(new InputStreamReader(System.in)); String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) &&  (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and  //should be passed down the pipeline with  //the pound-sign stripped off System.out.println(inputLine.substring(1)); } . . . else if(inputLine.startsWith(&quot;%&quot;)){ //This is a value to display if(inputLine.length() > 1){ try{ char valueType = inputLine.charAt(1); int value = Integer.parseInt(inputLine.substring(2)); switch(valueType){ case 'a': System.out.println(&quot;Altitude: &quot; + value); break; case 'f': System.out.println(&quot;Fuel remaining: &quot; + value); break; case 'v': System.out.println(&quot;Current Velocity: “ + value); break; case 't': System.out.println(&quot;Time elapsed: &quot; + value); break; } } catch(NumberFormatException nfe){ } . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
DisplayValues Filter import java.io.*; public class DisplayValues{ public static void main(String[] args){ try{ BufferedReader inputReader = new  BufferedReader(new InputStreamReader(System.in)); String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) &&  (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and  //should be passed down the pipeline with  //the pound-sign stripped off System.out.println(inputLine.substring(1)); } . . . else if(inputLine.startsWith(&quot;%&quot;)){ //This is a value to display if(inputLine.length() > 1){ try{ char valueType = inputLine.charAt(1); int value = Integer.parseInt(inputLine.substring(2)); switch(valueType){ case 'a': System.out.println(&quot;Altitude: &quot; + value); break; case 'f': System.out.println(&quot;Fuel remaining: &quot; + value); break; case 'v': System.out.println(&quot;Current Velocity: “ + value); break; case 't': System.out.println(&quot;Time elapsed: &quot; + value); break; } } catch(NumberFormatException nfe){ } . . . } } } }while(inputLine != null); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Pipe and Filter Lunar Lander ,[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Pipe and Filter Lunar Lander Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Pipe and Filter Lunar Lander
Implementing Pipe and Filter Lunar Lander Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Pipe and Filter Lunar Lander
Takeaways ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementing Lunar Lander in C2 ,[object Object],[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Lunar Lander in C2 (cont’d) ,[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Clock Component import c2.framework.*; public class Clock extends ComponentThread{ public Clock(){ super.create(&quot;clock&quot;, FIFOPort.class); } public void start(){ super.start(); Thread clockThread = new Thread(){ public void run(){ //Repeat while the application runs while(true){ //Wait for five seconds try{ Thread.sleep(5000); } catch(InterruptedException ie){} //Send out a tick notification Notification n = new Notification(&quot;clockTick&quot;); send(n); } } }; Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Clock Component import c2.framework.*; public class Clock extends ComponentThread{ public Clock(){ super.create(&quot;clock&quot;, FIFOPort.class); } public void start(){ super.start(); Thread clockThread = new Thread(){ public void run(){ //Repeat while the application runs while(true){ //Wait for five seconds try{ Thread.sleep(5000); } catch(InterruptedException ie){} //Send out a tick notification Notification n = new Notification(&quot;clockTick&quot;); send(n); } } }; clockThread.start(); } protected void handle(Notification n){ //This component does not handle notifications } protected void handle(Request r){ //This component does not handle requests } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Lunar Lander in C2 ,[object Object],[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GameState Component import c2.framework.*; public class GameState extends ComponentThread{ public GameState(){ super.create(&quot;gameState&quot;, FIFOPort.class); } //Internal game state and initial values int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; int burnRate = 0; boolean landedSafely = false; Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GameState Component import c2.framework.*; public class GameState extends ComponentThread{ public GameState(){ super.create(&quot;gameState&quot;, FIFOPort.class); } //Internal game state and initial values int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; int burnRate = 0; boolean landedSafely = false; protected void handle(Request r){ if(r.name().equals(&quot;updateGameState&quot;)){ //Update the internal game state if(r.hasParameter(&quot;altitude&quot;)){ this.altitude = ((Integer)r.getParameter(&quot;altitude&quot;)).intValue(); } if(r.hasParameter(&quot;fuel&quot;)){ this.fuel = ((Integer)r.getParameter(&quot;fuel&quot;)).intValue(); } if(r.hasParameter(&quot;velocity&quot;)){ this.velocity = ((Integer)r.getParameter(&quot;velocity&quot;)).intValue(); } if(r.hasParameter(&quot;time&quot;)){ this.time = ((Integer)r.getParameter(&quot;time&quot;)).intValue(); } if(r.hasParameter(&quot;burnRate&quot;)){ this.burnRate = ((Integer)r.getParameter(&quot;burnRate&quot;)).intValue(); } if(r.hasParameter(&quot;landedSafely&quot;)){ this.landedSafely = ((Boolean)r.getParameter(&quot;landedSafely&quot;)) .booleanValue(); } //Send out the updated game state Notification n = createStateNotification(); send(n); } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GameState Component import c2.framework.*; public class GameState extends ComponentThread{ public GameState(){ super.create(&quot;gameState&quot;, FIFOPort.class); } //Internal game state and initial values int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; int burnRate = 0; boolean landedSafely = false; protected void handle(Request r){ if(r.name().equals(&quot;updateGameState&quot;)){ //Update the internal game state if(r.hasParameter(&quot;altitude&quot;)){ this.altitude = ((Integer)r.getParameter(&quot;altitude&quot;)).intValue(); } if(r.hasParameter(&quot;fuel&quot;)){ this.fuel = ((Integer)r.getParameter(&quot;fuel&quot;)).intValue(); } if(r.hasParameter(&quot;velocity&quot;)){ this.velocity = ((Integer)r.getParameter(&quot;velocity&quot;)).intValue(); } if(r.hasParameter(&quot;time&quot;)){ this.time = ((Integer)r.getParameter(&quot;time&quot;)).intValue(); } if(r.hasParameter(&quot;burnRate&quot;)){ this.burnRate = ((Integer)r.getParameter(&quot;burnRate&quot;)).intValue(); } if(r.hasParameter(&quot;landedSafely&quot;)){ this.landedSafely = ((Boolean)r.getParameter(&quot;landedSafely&quot;)) .booleanValue(); } //Send out the updated game state Notification n = createStateNotification(); send(n); } else if(r.name().equals(&quot;getGameState&quot;)){ //If a component requests the game state //without updating it, send out the state Notification n = createStateNotification(); send(n); } } protected Notification createStateNotification(){ //Create a new notification comprising the //current game state Notification n = new Notification(&quot;gameState&quot;); n.addParameter(&quot;altitude&quot;, altitude); n.addParameter(&quot;fuel&quot;, fuel); n.addParameter(&quot;velocity&quot;, velocity); n.addParameter(&quot;time&quot;, time); n.addParameter(&quot;burnRate&quot;, burnRate); n.addParameter(&quot;landedSafely&quot;, landedSafely); return n; } protected void handle(Notification n){ //This component does not handle notifications } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Lunar Lander in C2 ,[object Object],[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GameLogic Component import c2.framework.*; public class GameLogic extends ComponentThread{ public GameLogic(){ super.create(&quot;gameLogic&quot;, FIFOPort.class); } //Game constants final int GRAVITY = 2; //Internal state values for computation int altitude = 0; int fuel = 0; int velocity = 0; int time = 0; int burnRate = 0; public void start(){ super.start(); Request r = new Request(&quot;getGameState&quot;); send(r); } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GameLogic Component import c2.framework.*; public class GameLogic extends ComponentThread{ public GameLogic(){ super.create(&quot;gameLogic&quot;, FIFOPort.class); } //Game constants final int GRAVITY = 2; //Internal state values for computation int altitude = 0; int fuel = 0; int velocity = 0; int time = 0; int burnRate = 0; public void start(){ super.start(); Request r = new Request(&quot;getGameState&quot;); send(r); } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ if(n.hasParameter(&quot;altitude&quot;)){ this.altitude =  ((Integer)n.getParameter(&quot;altitude&quot;)).intValue(); } if(n.hasParameter(&quot;fuel&quot;)){ this.fuel =  ((Integer)n.getParameter(&quot;fuel&quot;)).intValue(); } if(n.hasParameter(&quot;velocity&quot;)){ this.velocity =  ((Integer)n.getParameter(&quot;velocity&quot;)).intValue(); } if(n.hasParameter(&quot;time&quot;)){ this.time =  ((Integer)n.getParameter(&quot;time&quot;)).intValue(); } if(n.hasParameter(&quot;burnRate&quot;)){ this.burnRate =  ((Integer)n.getParameter(&quot;burnRate&quot;)).intValue(); } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GameLogic Component import c2.framework.*; public class GameLogic extends ComponentThread{ public GameLogic(){ super.create(&quot;gameLogic&quot;, FIFOPort.class); } //Game constants final int GRAVITY = 2; //Internal state values for computation int altitude = 0; int fuel = 0; int velocity = 0; int time = 0; int burnRate = 0; public void start(){ super.start(); Request r = new Request(&quot;getGameState&quot;); send(r); } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ if(n.hasParameter(&quot;altitude&quot;)){ this.altitude =  ((Integer)n.getParameter(&quot;altitude&quot;)).intValue(); } if(n.hasParameter(&quot;fuel&quot;)){ this.fuel =  ((Integer)n.getParameter(&quot;fuel&quot;)).intValue(); } if(n.hasParameter(&quot;velocity&quot;)){ this.velocity =  ((Integer)n.getParameter(&quot;velocity&quot;)).intValue(); } if(n.hasParameter(&quot;time&quot;)){ this.time =  ((Integer)n.getParameter(&quot;time&quot;)).intValue(); } if(n.hasParameter(&quot;burnRate&quot;)){ this.burnRate =  ((Integer)n.getParameter(&quot;burnRate&quot;)).intValue(); } } else if(n.name().equals(&quot;clockTick&quot;)){ //Calculate new lander state values int actualBurnRate = burnRate; if(actualBurnRate > fuel){ //Ensure we don’t burn more fuel than we have actualBurnRate = fuel; } time = time + 1; altitude = altitude - velocity; velocity = ((velocity + GRAVITY) * 10 – actualBurnRate * 2) / 10; fuel = fuel - actualBurnRate; //Determine if we landed (safely) boolean landedSafely = false; if(altitude <= 0){ altitude = 0; if(velocity <= 5){ landedSafely = true; } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GameLogic Component import c2.framework.*; public class GameLogic extends ComponentThread{ public GameLogic(){ super.create(&quot;gameLogic&quot;, FIFOPort.class); } //Game constants final int GRAVITY = 2; //Internal state values for computation int altitude = 0; int fuel = 0; int velocity = 0; int time = 0; int burnRate = 0; public void start(){ super.start(); Request r = new Request(&quot;getGameState&quot;); send(r); } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ if(n.hasParameter(&quot;altitude&quot;)){ this.altitude =  ((Integer)n.getParameter(&quot;altitude&quot;)).intValue(); } if(n.hasParameter(&quot;fuel&quot;)){ this.fuel =  ((Integer)n.getParameter(&quot;fuel&quot;)).intValue(); } if(n.hasParameter(&quot;velocity&quot;)){ this.velocity =  ((Integer)n.getParameter(&quot;velocity&quot;)).intValue(); } if(n.hasParameter(&quot;time&quot;)){ this.time =  ((Integer)n.getParameter(&quot;time&quot;)).intValue(); } if(n.hasParameter(&quot;burnRate&quot;)){ this.burnRate =  ((Integer)n.getParameter(&quot;burnRate&quot;)).intValue(); } } else if(n.name().equals(&quot;clockTick&quot;)){ //Calculate new lander state values int actualBurnRate = burnRate; if(actualBurnRate > fuel){ //Ensure we don’t burn more fuel than we have actualBurnRate = fuel; } time = time + 1; altitude = altitude - velocity; velocity = ((velocity + GRAVITY) * 10 – actualBurnRate * 2) / 10; fuel = fuel - actualBurnRate; //Determine if we landed (safely) boolean landedSafely = false; if(altitude <= 0){ altitude = 0; if(velocity <= 5){ landedSafely = true; } } Request r = new Request(&quot;updateGameState&quot;); r.addParameter(&quot;time&quot;, time); r.addParameter(&quot;altitude&quot;, altitude); r.addParameter(&quot;velocity&quot;, velocity); r.addParameter(&quot;fuel&quot;, fuel); r.addParameter(&quot;landedSafely&quot;, landedSafely); send(r); } } protected void handle(Request r){ //This component does not handle requests } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Lunar Lander in C2 ,[object Object],[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GUI Component import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import c2.framework.*; public class GUI extends ComponentThread{ public GUI(){ super.create(&quot;gui&quot;, FIFOPort.class); } public void start(){ super.start(); Thread t = new Thread(){ public void run(){ processInput(); } }; t.start(); } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GUI Component import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import c2.framework.*; public class GUI extends ComponentThread{ public GUI(){ super.create(&quot;gui&quot;, FIFOPort.class); } public void start(){ super.start(); Thread t = new Thread(){ public void run(){ processInput(); } }; t.start(); } public void processInput(){ System.out.println(&quot;Welcome to Lunar Lander&quot;); try{ BufferedReader inputReader = new BufferedReader( new InputStreamReader(System.in)); int burnRate = 0; do{ System.out.println(&quot;Enter burn rate or <0 to quit:&quot;); try{ String burnRateString = inputReader.readLine(); burnRate = Integer.parseInt(burnRateString); Request r = new Request(&quot;updateGameState&quot;); r.addParameter(&quot;burnRate&quot;, burnRate); send(r); } catch(NumberFormatException nfe){ System.out.println(&quot;Invalid burn rate.&quot;); } }while(burnRate >= 0); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GUI Component import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import c2.framework.*; public class GUI extends ComponentThread{ public GUI(){ super.create(&quot;gui&quot;, FIFOPort.class); } public void start(){ super.start(); Thread t = new Thread(){ public void run(){ processInput(); } }; t.start(); } public void processInput(){ System.out.println(&quot;Welcome to Lunar Lander&quot;); try{ BufferedReader inputReader = new BufferedReader( new InputStreamReader(System.in)); int burnRate = 0; do{ System.out.println(&quot;Enter burn rate or <0 to quit:&quot;); try{ String burnRateString = inputReader.readLine(); burnRate = Integer.parseInt(burnRateString); Request r = new Request(&quot;updateGameState&quot;); r.addParameter(&quot;burnRate&quot;, burnRate); send(r); } catch(NumberFormatException nfe){ System.out.println(&quot;Invalid burn rate.&quot;); } }while(burnRate >= 0); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ System.out.println(); System.out.println(&quot;New game state:&quot;); if(n.hasParameter(&quot;altitude&quot;)){ System.out.println(&quot;  Altitude: &quot; + n.getParameter(&quot;altitude&quot;)); } if(n.hasParameter(&quot;fuel&quot;)){ System.out.println(&quot;  Fuel: &quot; + n.getParameter(&quot;fuel&quot;)); } if(n.hasParameter(&quot;velocity&quot;)){ System.out.println(&quot;  Velocity: &quot; + n.getParameter(&quot;velocity&quot;)); } if(n.hasParameter(&quot;time&quot;)){ System.out.println(&quot;  Time: &quot; + n.getParameter(&quot;time&quot;)); } if(n.hasParameter(&quot;burnRate&quot;)){ System.out.println(&quot;  Burn rate: &quot; + n.getParameter(&quot;burnRate&quot;)); } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
GUI Component import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import c2.framework.*; public class GUI extends ComponentThread{ public GUI(){ super.create(&quot;gui&quot;, FIFOPort.class); } public void start(){ super.start(); Thread t = new Thread(){ public void run(){ processInput(); } }; t.start(); } public void processInput(){ System.out.println(&quot;Welcome to Lunar Lander&quot;); try{ BufferedReader inputReader = new BufferedReader( new InputStreamReader(System.in)); int burnRate = 0; do{ System.out.println(&quot;Enter burn rate or <0 to quit:&quot;); try{ String burnRateString = inputReader.readLine(); burnRate = Integer.parseInt(burnRateString); Request r = new Request(&quot;updateGameState&quot;); r.addParameter(&quot;burnRate&quot;, burnRate); send(r); } catch(NumberFormatException nfe){ System.out.println(&quot;Invalid burn rate.&quot;); } }while(burnRate >= 0); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ System.out.println(); System.out.println(&quot;New game state:&quot;); if(n.hasParameter(&quot;altitude&quot;)){ System.out.println(&quot;  Altitude: &quot; + n.getParameter(&quot;altitude&quot;)); } if(n.hasParameter(&quot;fuel&quot;)){ System.out.println(&quot;  Fuel: &quot; + n.getParameter(&quot;fuel&quot;)); } if(n.hasParameter(&quot;velocity&quot;)){ System.out.println(&quot;  Velocity: &quot; + n.getParameter(&quot;velocity&quot;)); } if(n.hasParameter(&quot;time&quot;)){ System.out.println(&quot;  Time: &quot; + n.getParameter(&quot;time&quot;)); } if(n.hasParameter(&quot;burnRate&quot;)){ System.out.println(&quot;  Burn rate: &quot; + n.getParameter(&quot;burnRate&quot;)); } if(n.hasParameter(&quot;altitude&quot;)){ int altitude =  ((Integer)n.getParameter(&quot;altitude&quot;)).intValue(); if(altitude <= 0){ boolean landedSafely =  ((Boolean)n.getParameter(&quot;landedSafely&quot;)) .booleanValue(); if(landedSafely){ System.out.println(&quot;You have landed safely.&quot;); } else{ System.out.println(&quot;You have crashed.&quot;); } System.exit(0); } } } } protected void handle(Request r){ //This component does not handle requests } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Implementing Lunar Lander in C2 ,[object Object],[object Object],Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Main Program import c2.framework.*; public class LunarLander{ public static void main(String[] args){ //Create the Lunar Lander architecture Architecture lunarLander = new  SimpleArchitecture(&quot;LunarLander&quot;); //Create the components Component clock = new Clock(); Component gameState = new GameState(); Component gameLogic = new GameLogic(); Component gui = new GUI(); //Create the connectors Connector bus = new ConnectorThread(&quot;bus&quot;); //Add the components and connectors to the architecture lunarLander.addComponent(clock); lunarLander.addComponent(gameState); lunarLander.addComponent(gameLogic); lunarLander.addComponent(gui); lunarLander.addConnector(bus); Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Main Program import c2.framework.*; public class LunarLander{ public static void main(String[] args){ //Create the Lunar Lander architecture Architecture lunarLander = new  SimpleArchitecture(&quot;LunarLander&quot;); //Create the components Component clock = new Clock(); Component gameState = new GameState(); Component gameLogic = new GameLogic(); Component gui = new GUI(); //Create the connectors Connector bus = new ConnectorThread(&quot;bus&quot;); //Add the components and connectors to the architecture lunarLander.addComponent(clock); lunarLander.addComponent(gameState); lunarLander.addComponent(gameLogic); lunarLander.addComponent(gui); lunarLander.addConnector(bus); //Create the welds (links) between components and //connectors lunarLander.weld(clock, bus); lunarLander.weld(gameState, bus); lunarLander.weld(bus, gameLogic); lunarLander.weld(bus, gui); //Start the application lunarLander.start(); } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy;  (C)  2008 John Wiley & Sons, Inc. Reprinted with permission.
Takeaways ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

ترم ثاني تحضير 2 ثانوى
ترم ثاني تحضير 2 ثانوىترم ثاني تحضير 2 ثانوى
ترم ثاني تحضير 2 ثانوىOmar Computer Teacher
 
أمن الويب
أمن الويب أمن الويب
أمن الويب Nouha Hamami
 
Software Project Management
Software Project ManagementSoftware Project Management
Software Project Managementasim78
 
Eservices project planning
Eservices project planningEservices project planning
Eservices project planningChetan Manchanda
 
Software proposal
Software proposalSoftware proposal
Software proposalAvijit Dhar
 
Use of hypertext, hypermedia and multimedia
Use of hypertext, hypermedia and multimediaUse of hypertext, hypermedia and multimedia
Use of hypertext, hypermedia and multimediaGeomara Cabrera
 
التقرير العلمي الجودة في التعلم الالكتروني
التقرير العلمي الجودة في التعلم الالكترونيالتقرير العلمي الجودة في التعلم الالكتروني
التقرير العلمي الجودة في التعلم الالكترونيصالح المالكي
 
التعرف على اهداف التنمية المستدامة واجندة الامم المتحدة 2030 وحشد الدعم (المن...
التعرف على اهداف التنمية المستدامة واجندة الامم المتحدة 2030 وحشد الدعم (المن...التعرف على اهداف التنمية المستدامة واجندة الامم المتحدة 2030 وحشد الدعم (المن...
التعرف على اهداف التنمية المستدامة واجندة الامم المتحدة 2030 وحشد الدعم (المن...Lebanese Library Association
 
Software Project Management
Software Project ManagementSoftware Project Management
Software Project ManagementNoorHameed6
 
Digital Media Team Structure and Hierarchy
Digital Media Team Structure and Hierarchy Digital Media Team Structure and Hierarchy
Digital Media Team Structure and Hierarchy Mujeeb Riaz
 
أنظمة إدارة المحتوى
أنظمة إدارة المحتوىأنظمة إدارة المحتوى
أنظمة إدارة المحتوىEhab Saad Ahmad
 
Earnestine the Enterprise Architect February 2023.pdf
Earnestine the Enterprise Architect February 2023.pdfEarnestine the Enterprise Architect February 2023.pdf
Earnestine the Enterprise Architect February 2023.pdfIntersection Group
 
Project human resource management
Project human resource managementProject human resource management
Project human resource managementJahangeer Shams
 
Software Engineering (Introduction to Software Engineering)
Software Engineering (Introduction to Software Engineering)Software Engineering (Introduction to Software Engineering)
Software Engineering (Introduction to Software Engineering)ShudipPal
 
Project Human Resource Management.pptx
Project Human Resource Management.pptxProject Human Resource Management.pptx
Project Human Resource Management.pptxIkram192675
 
Basic Software Effort Estimation
Basic Software Effort EstimationBasic Software Effort Estimation
Basic Software Effort Estimationumair khan
 

Was ist angesagt? (20)

ترم ثاني تحضير 2 ثانوى
ترم ثاني تحضير 2 ثانوىترم ثاني تحضير 2 ثانوى
ترم ثاني تحضير 2 ثانوى
 
أمن الويب
أمن الويب أمن الويب
أمن الويب
 
Software Project Management
Software Project ManagementSoftware Project Management
Software Project Management
 
Eservices project planning
Eservices project planningEservices project planning
Eservices project planning
 
Software proposal
Software proposalSoftware proposal
Software proposal
 
Network security # Lecture 1
Network security # Lecture 1Network security # Lecture 1
Network security # Lecture 1
 
Use of hypertext, hypermedia and multimedia
Use of hypertext, hypermedia and multimediaUse of hypertext, hypermedia and multimedia
Use of hypertext, hypermedia and multimedia
 
التقرير العلمي الجودة في التعلم الالكتروني
التقرير العلمي الجودة في التعلم الالكترونيالتقرير العلمي الجودة في التعلم الالكتروني
التقرير العلمي الجودة في التعلم الالكتروني
 
RMMM Plan
RMMM PlanRMMM Plan
RMMM Plan
 
التعرف على اهداف التنمية المستدامة واجندة الامم المتحدة 2030 وحشد الدعم (المن...
التعرف على اهداف التنمية المستدامة واجندة الامم المتحدة 2030 وحشد الدعم (المن...التعرف على اهداف التنمية المستدامة واجندة الامم المتحدة 2030 وحشد الدعم (المن...
التعرف على اهداف التنمية المستدامة واجندة الامم المتحدة 2030 وحشد الدعم (المن...
 
Software Project Management
Software Project ManagementSoftware Project Management
Software Project Management
 
Reqdet
ReqdetReqdet
Reqdet
 
Digital Media Team Structure and Hierarchy
Digital Media Team Structure and Hierarchy Digital Media Team Structure and Hierarchy
Digital Media Team Structure and Hierarchy
 
تحليل النظم
تحليل النظمتحليل النظم
تحليل النظم
 
أنظمة إدارة المحتوى
أنظمة إدارة المحتوىأنظمة إدارة المحتوى
أنظمة إدارة المحتوى
 
Earnestine the Enterprise Architect February 2023.pdf
Earnestine the Enterprise Architect February 2023.pdfEarnestine the Enterprise Architect February 2023.pdf
Earnestine the Enterprise Architect February 2023.pdf
 
Project human resource management
Project human resource managementProject human resource management
Project human resource management
 
Software Engineering (Introduction to Software Engineering)
Software Engineering (Introduction to Software Engineering)Software Engineering (Introduction to Software Engineering)
Software Engineering (Introduction to Software Engineering)
 
Project Human Resource Management.pptx
Project Human Resource Management.pptxProject Human Resource Management.pptx
Project Human Resource Management.pptx
 
Basic Software Effort Estimation
Basic Software Effort EstimationBasic Software Effort Estimation
Basic Software Effort Estimation
 

Andere mochten auch

17 applied architectures
17 applied architectures17 applied architectures
17 applied architecturesMajong DevJfu
 
S D D Program Development Tools
S D D  Program  Development  ToolsS D D  Program  Development  Tools
S D D Program Development Toolsgavhays
 
15 implementing architectures
15 implementing architectures15 implementing architectures
15 implementing architecturesMajong DevJfu
 
Architecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionArchitecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionNguyen Tung
 
The software Implementation Process
The software Implementation ProcessThe software Implementation Process
The software Implementation Processrthompson604
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great InfographicsSlideShare
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShareKapost
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareEmpowered Presentations
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation OptimizationOneupweb
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingContent Marketing Institute
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksSlideShare
 

Andere mochten auch (13)

17 applied architectures
17 applied architectures17 applied architectures
17 applied architectures
 
S D D Program Development Tools
S D D  Program  Development  ToolsS D D  Program  Development  Tools
S D D Program Development Tools
 
15 implementing architectures
15 implementing architectures15 implementing architectures
15 implementing architectures
 
Software Development Techniques
Software Development TechniquesSoftware Development Techniques
Software Development Techniques
 
Architecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionArchitecture Patterns - Open Discussion
Architecture Patterns - Open Discussion
 
The software Implementation Process
The software Implementation ProcessThe software Implementation Process
The software Implementation Process
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great Infographics
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShare
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
 
You Suck At PowerPoint!
You Suck At PowerPoint!You Suck At PowerPoint!
You Suck At PowerPoint!
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
 

Ähnlich wie 16 implementation techniques

01 intro to programming in .net
01   intro to programming in .net01   intro to programming in .net
01 intro to programming in .netFelisha Hosein
 
18 applied architectures_part_2
18 applied architectures_part_218 applied architectures_part_2
18 applied architectures_part_2Majong DevJfu
 
Cs 1023 lec 6 architecture (week 1)
Cs 1023 lec 6 architecture (week 1)Cs 1023 lec 6 architecture (week 1)
Cs 1023 lec 6 architecture (week 1)stanbridge
 
Gervais Peter Resume Oct :2015
Gervais Peter Resume Oct :2015Gervais Peter Resume Oct :2015
Gervais Peter Resume Oct :2015Peter Gervais
 
C# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy todayC# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy todayAfonso Macedo
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdfvino108206
 
report_barc
report_barcreport_barc
report_barcsiontani
 
The Concurrency Challenge : Notes
The Concurrency Challenge : NotesThe Concurrency Challenge : Notes
The Concurrency Challenge : NotesSubhajit Sahu
 
Software engineering
Software engineeringSoftware engineering
Software engineeringFahe Em
 
Software engineering
Software engineeringSoftware engineering
Software engineeringFahe Em
 
22 deployment and_mobility
22 deployment and_mobility22 deployment and_mobility
22 deployment and_mobilityMajong DevJfu
 
Aspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETAspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETWaqas Tariq
 
OMG CORBA Component Model tutorial
OMG CORBA Component Model tutorialOMG CORBA Component Model tutorial
OMG CORBA Component Model tutorialJohnny Willemsen
 

Ähnlich wie 16 implementation techniques (20)

01 intro to programming in .net
01   intro to programming in .net01   intro to programming in .net
01 intro to programming in .net
 
18 applied architectures_part_2
18 applied architectures_part_218 applied architectures_part_2
18 applied architectures_part_2
 
Cs 1023 lec 6 architecture (week 1)
Cs 1023 lec 6 architecture (week 1)Cs 1023 lec 6 architecture (week 1)
Cs 1023 lec 6 architecture (week 1)
 
Gervais Peter Resume Oct :2015
Gervais Peter Resume Oct :2015Gervais Peter Resume Oct :2015
Gervais Peter Resume Oct :2015
 
C# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy todayC# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy today
 
Unit 2 Java
Unit 2 JavaUnit 2 Java
Unit 2 Java
 
Dot net
Dot netDot net
Dot net
 
Resume
ResumeResume
Resume
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
report_barc
report_barcreport_barc
report_barc
 
The Concurrency Challenge : Notes
The Concurrency Challenge : NotesThe Concurrency Challenge : Notes
The Concurrency Challenge : Notes
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
22 deployment and_mobility
22 deployment and_mobility22 deployment and_mobility
22 deployment and_mobility
 
Revealing C# 5
Revealing C# 5Revealing C# 5
Revealing C# 5
 
Srgoc dotnet_new
Srgoc dotnet_newSrgoc dotnet_new
Srgoc dotnet_new
 
Dot Net PPt.pptx
Dot Net PPt.pptxDot Net PPt.pptx
Dot Net PPt.pptx
 
3DD 1e 31 Luglio Apertura
3DD 1e 31 Luglio Apertura3DD 1e 31 Luglio Apertura
3DD 1e 31 Luglio Apertura
 
Aspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETAspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NET
 
OMG CORBA Component Model tutorial
OMG CORBA Component Model tutorialOMG CORBA Component Model tutorial
OMG CORBA Component Model tutorial
 

Mehr von Majong DevJfu

9 - Architetture Software - SOA Cloud
9 - Architetture Software - SOA Cloud9 - Architetture Software - SOA Cloud
9 - Architetture Software - SOA CloudMajong DevJfu
 
8 - Architetture Software - Architecture centric processes
8 - Architetture Software - Architecture centric processes8 - Architetture Software - Architecture centric processes
8 - Architetture Software - Architecture centric processesMajong DevJfu
 
7 - Architetture Software - Software product line
7 - Architetture Software - Software product line7 - Architetture Software - Software product line
7 - Architetture Software - Software product lineMajong DevJfu
 
6 - Architetture Software - Model transformation
6 - Architetture Software - Model transformation6 - Architetture Software - Model transformation
6 - Architetture Software - Model transformationMajong DevJfu
 
5 - Architetture Software - Metamodelling and the Model Driven Architecture
5 - Architetture Software - Metamodelling and the Model Driven Architecture5 - Architetture Software - Metamodelling and the Model Driven Architecture
5 - Architetture Software - Metamodelling and the Model Driven ArchitectureMajong DevJfu
 
4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture PortfolioMajong DevJfu
 
3 - Architetture Software - Architectural styles
3 - Architetture Software - Architectural styles3 - Architetture Software - Architectural styles
3 - Architetture Software - Architectural stylesMajong DevJfu
 
2 - Architetture Software - Software architecture
2 - Architetture Software - Software architecture2 - Architetture Software - Software architecture
2 - Architetture Software - Software architectureMajong DevJfu
 
1 - Architetture Software - Software as a product
1 - Architetture Software - Software as a product1 - Architetture Software - Software as a product
1 - Architetture Software - Software as a productMajong DevJfu
 
10 - Architetture Software - More architectural styles
10 - Architetture Software - More architectural styles10 - Architetture Software - More architectural styles
10 - Architetture Software - More architectural stylesMajong DevJfu
 

Mehr von Majong DevJfu (20)

9 - Architetture Software - SOA Cloud
9 - Architetture Software - SOA Cloud9 - Architetture Software - SOA Cloud
9 - Architetture Software - SOA Cloud
 
8 - Architetture Software - Architecture centric processes
8 - Architetture Software - Architecture centric processes8 - Architetture Software - Architecture centric processes
8 - Architetture Software - Architecture centric processes
 
7 - Architetture Software - Software product line
7 - Architetture Software - Software product line7 - Architetture Software - Software product line
7 - Architetture Software - Software product line
 
6 - Architetture Software - Model transformation
6 - Architetture Software - Model transformation6 - Architetture Software - Model transformation
6 - Architetture Software - Model transformation
 
5 - Architetture Software - Metamodelling and the Model Driven Architecture
5 - Architetture Software - Metamodelling and the Model Driven Architecture5 - Architetture Software - Metamodelling and the Model Driven Architecture
5 - Architetture Software - Metamodelling and the Model Driven Architecture
 
4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio
 
3 - Architetture Software - Architectural styles
3 - Architetture Software - Architectural styles3 - Architetture Software - Architectural styles
3 - Architetture Software - Architectural styles
 
2 - Architetture Software - Software architecture
2 - Architetture Software - Software architecture2 - Architetture Software - Software architecture
2 - Architetture Software - Software architecture
 
1 - Architetture Software - Software as a product
1 - Architetture Software - Software as a product1 - Architetture Software - Software as a product
1 - Architetture Software - Software as a product
 
10 - Architetture Software - More architectural styles
10 - Architetture Software - More architectural styles10 - Architetture Software - More architectural styles
10 - Architetture Software - More architectural styles
 
Uml3
Uml3Uml3
Uml3
 
Uml2
Uml2Uml2
Uml2
 
6
66
6
 
5
55
5
 
4 (uml basic)
4 (uml basic)4 (uml basic)
4 (uml basic)
 
3
33
3
 
2
22
2
 
1
11
1
 
Tmd template-sand
Tmd template-sandTmd template-sand
Tmd template-sand
 
26 standards
26 standards26 standards
26 standards
 

Kürzlich hochgeladen

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Kürzlich hochgeladen (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

16 implementation techniques

  • 1. Implementation Techniques Software Architecture Lecture 16
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. Framework #2: Flexible C2 Framework Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. GetBurnRate Filter //Import the java.io framework import java.io.*; public class GetBurnRate{ public static void main(String[] args){ //Send welcome message System.out.println(&quot;#Welcome to Lunar Lander&quot;); try{ //Begin reading from System input BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); //Set initial burn rate to 0 int burnRate = 0; do{ //Prompt user System.out.println(&quot;#Enter burn rate or <0 to quit:&quot;); . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 20. GetBurnRate Filter //Import the java.io framework import java.io.*; public class GetBurnRate{ public static void main(String[] args){ //Send welcome message System.out.println(&quot;#Welcome to Lunar Lander&quot;); try{ //Begin reading from System input BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); //Set initial burn rate to 0 int burnRate = 0; do{ //Prompt user System.out.println(&quot;#Enter burn rate or <0 to quit:&quot;); . . . . . . //Read user response try{ String burnRateString = inputReader.readLine(); burnRate = Integer.parseInt(burnRateString); //Send user-supplied burn rate to next filter System.out.println(&quot;%&quot; + burnRate); } catch(NumberFormatException nfe){ System.out.println(&quot;#Invalid burn rate.&quot;); } }while(burnRate >= 0); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 21.
  • 22. CalcBurnRate Filter import java.io.*; public class CalcNewValues{ public static void main(String[] args){ //Initialize values final int GRAVITY = 2; int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; try{ BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); //Print initial values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 23. CalcBurnRate Filter import java.io.*; public class CalcNewValues{ public static void main(String[] args){ //Initialize values final int GRAVITY = 2; int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; try{ BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); //Print initial values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); . . . String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) && (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and //should be passed down the pipeline System.out.println(inputLine); } else if(inputLine.startsWith(&quot;%&quot;)){ //This is an input burn rate try{ int burnRate = Integer.parseInt(inputLine.substring(1)); if(altitude <= 0){ System.out.println(&quot;#The game is over.&quot;); } else if(burnRate > fuel){ System.out.println(&quot;#Sorry, you don't&quot; + &quot;have that much fuel.&quot;); } . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 24. CalcBurnRate Filter import java.io.*; public class CalcNewValues{ public static void main(String[] args){ //Initialize values final int GRAVITY = 2; int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; try{ BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); //Print initial values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); . . . String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) && (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and //should be passed down the pipeline System.out.println(inputLine); } else if(inputLine.startsWith(&quot;%&quot;)){ //This is an input burn rate try{ int burnRate = Integer.parseInt(inputLine.substring(1)); if(altitude <= 0){ System.out.println(&quot;#The game is over.&quot;); } else if(burnRate > fuel){ System.out.println(&quot;#Sorry, you don't&quot; + &quot;have that much fuel.&quot;); } . . . else{ //Calculate new application state time = time + 1; altitude = altitude - velocity; velocity = ((velocity + GRAVITY) * 10 - burnRate * 2) / 10; fuel = fuel - burnRate; if(altitude <= 0){ altitude = 0; if(velocity <= 5){ System.out.println(&quot;#You have landed safely.&quot;); } else{ System.out.println(&quot;#You have crashed.&quot;); } } } //Print new values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); } catch(NumberFormatException nfe){ } . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 25. CalcBurnRate Filter import java.io.*; public class CalcNewValues{ public static void main(String[] args){ //Initialize values final int GRAVITY = 2; int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; try{ BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); //Print initial values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); . . . String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) && (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and //should be passed down the pipeline System.out.println(inputLine); } else if(inputLine.startsWith(&quot;%&quot;)){ //This is an input burn rate try{ int burnRate = Integer.parseInt(inputLine.substring(1)); if(altitude <= 0){ System.out.println(&quot;#The game is over.&quot;); } else if(burnRate > fuel){ System.out.println(&quot;#Sorry, you don't&quot; + &quot;have that much fuel.&quot;); } . . . else{ //Calculate new application state time = time + 1; altitude = altitude - velocity; velocity = ((velocity + GRAVITY) * 10 - burnRate * 2) / 10; fuel = fuel - burnRate; if(altitude <= 0){ altitude = 0; if(velocity <= 5){ System.out.println(&quot;#You have landed safely.&quot;); } else{ System.out.println(&quot;#You have crashed.&quot;); } } } //Print new values System.out.println(&quot;%a&quot; + altitude); System.out.println(&quot;%f&quot; + fuel); System.out.println(&quot;%v&quot; + velocity); System.out.println(&quot;%t&quot; + time); } catch(NumberFormatException nfe){ } . . . } } }while((inputLine != null) && (altitude > 0)); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 26.
  • 27. DisplayValues Filter import java.io.*; public class DisplayValues{ public static void main(String[] args){ try{ BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) && (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and //should be passed down the pipeline with //the pound-sign stripped off System.out.println(inputLine.substring(1)); } . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 28. DisplayValues Filter import java.io.*; public class DisplayValues{ public static void main(String[] args){ try{ BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) && (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and //should be passed down the pipeline with //the pound-sign stripped off System.out.println(inputLine.substring(1)); } . . . else if(inputLine.startsWith(&quot;%&quot;)){ //This is a value to display if(inputLine.length() > 1){ try{ char valueType = inputLine.charAt(1); int value = Integer.parseInt(inputLine.substring(2)); switch(valueType){ case 'a': System.out.println(&quot;Altitude: &quot; + value); break; case 'f': System.out.println(&quot;Fuel remaining: &quot; + value); break; case 'v': System.out.println(&quot;Current Velocity: “ + value); break; case 't': System.out.println(&quot;Time elapsed: &quot; + value); break; } } catch(NumberFormatException nfe){ } . . . Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 29. DisplayValues Filter import java.io.*; public class DisplayValues{ public static void main(String[] args){ try{ BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); String inputLine = null; do{ inputLine = inputReader.readLine(); if((inputLine != null) && (inputLine.length() > 0)){ if(inputLine.startsWith(&quot;#&quot;)){ //This is a status line of text, and //should be passed down the pipeline with //the pound-sign stripped off System.out.println(inputLine.substring(1)); } . . . else if(inputLine.startsWith(&quot;%&quot;)){ //This is a value to display if(inputLine.length() > 1){ try{ char valueType = inputLine.charAt(1); int value = Integer.parseInt(inputLine.substring(2)); switch(valueType){ case 'a': System.out.println(&quot;Altitude: &quot; + value); break; case 'f': System.out.println(&quot;Fuel remaining: &quot; + value); break; case 'v': System.out.println(&quot;Current Velocity: “ + value); break; case 't': System.out.println(&quot;Time elapsed: &quot; + value); break; } } catch(NumberFormatException nfe){ } . . . } } } }while(inputLine != null); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 30.
  • 31. Implementing Pipe and Filter Lunar Lander Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 32. Implementing Pipe and Filter Lunar Lander
  • 33. Implementing Pipe and Filter Lunar Lander Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 34. Implementing Pipe and Filter Lunar Lander
  • 35.
  • 36.
  • 37.
  • 38. Clock Component import c2.framework.*; public class Clock extends ComponentThread{ public Clock(){ super.create(&quot;clock&quot;, FIFOPort.class); } public void start(){ super.start(); Thread clockThread = new Thread(){ public void run(){ //Repeat while the application runs while(true){ //Wait for five seconds try{ Thread.sleep(5000); } catch(InterruptedException ie){} //Send out a tick notification Notification n = new Notification(&quot;clockTick&quot;); send(n); } } }; Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 39. Clock Component import c2.framework.*; public class Clock extends ComponentThread{ public Clock(){ super.create(&quot;clock&quot;, FIFOPort.class); } public void start(){ super.start(); Thread clockThread = new Thread(){ public void run(){ //Repeat while the application runs while(true){ //Wait for five seconds try{ Thread.sleep(5000); } catch(InterruptedException ie){} //Send out a tick notification Notification n = new Notification(&quot;clockTick&quot;); send(n); } } }; clockThread.start(); } protected void handle(Notification n){ //This component does not handle notifications } protected void handle(Request r){ //This component does not handle requests } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 40.
  • 41. GameState Component import c2.framework.*; public class GameState extends ComponentThread{ public GameState(){ super.create(&quot;gameState&quot;, FIFOPort.class); } //Internal game state and initial values int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; int burnRate = 0; boolean landedSafely = false; Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 42. GameState Component import c2.framework.*; public class GameState extends ComponentThread{ public GameState(){ super.create(&quot;gameState&quot;, FIFOPort.class); } //Internal game state and initial values int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; int burnRate = 0; boolean landedSafely = false; protected void handle(Request r){ if(r.name().equals(&quot;updateGameState&quot;)){ //Update the internal game state if(r.hasParameter(&quot;altitude&quot;)){ this.altitude = ((Integer)r.getParameter(&quot;altitude&quot;)).intValue(); } if(r.hasParameter(&quot;fuel&quot;)){ this.fuel = ((Integer)r.getParameter(&quot;fuel&quot;)).intValue(); } if(r.hasParameter(&quot;velocity&quot;)){ this.velocity = ((Integer)r.getParameter(&quot;velocity&quot;)).intValue(); } if(r.hasParameter(&quot;time&quot;)){ this.time = ((Integer)r.getParameter(&quot;time&quot;)).intValue(); } if(r.hasParameter(&quot;burnRate&quot;)){ this.burnRate = ((Integer)r.getParameter(&quot;burnRate&quot;)).intValue(); } if(r.hasParameter(&quot;landedSafely&quot;)){ this.landedSafely = ((Boolean)r.getParameter(&quot;landedSafely&quot;)) .booleanValue(); } //Send out the updated game state Notification n = createStateNotification(); send(n); } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 43. GameState Component import c2.framework.*; public class GameState extends ComponentThread{ public GameState(){ super.create(&quot;gameState&quot;, FIFOPort.class); } //Internal game state and initial values int altitude = 1000; int fuel = 500; int velocity = 70; int time = 0; int burnRate = 0; boolean landedSafely = false; protected void handle(Request r){ if(r.name().equals(&quot;updateGameState&quot;)){ //Update the internal game state if(r.hasParameter(&quot;altitude&quot;)){ this.altitude = ((Integer)r.getParameter(&quot;altitude&quot;)).intValue(); } if(r.hasParameter(&quot;fuel&quot;)){ this.fuel = ((Integer)r.getParameter(&quot;fuel&quot;)).intValue(); } if(r.hasParameter(&quot;velocity&quot;)){ this.velocity = ((Integer)r.getParameter(&quot;velocity&quot;)).intValue(); } if(r.hasParameter(&quot;time&quot;)){ this.time = ((Integer)r.getParameter(&quot;time&quot;)).intValue(); } if(r.hasParameter(&quot;burnRate&quot;)){ this.burnRate = ((Integer)r.getParameter(&quot;burnRate&quot;)).intValue(); } if(r.hasParameter(&quot;landedSafely&quot;)){ this.landedSafely = ((Boolean)r.getParameter(&quot;landedSafely&quot;)) .booleanValue(); } //Send out the updated game state Notification n = createStateNotification(); send(n); } else if(r.name().equals(&quot;getGameState&quot;)){ //If a component requests the game state //without updating it, send out the state Notification n = createStateNotification(); send(n); } } protected Notification createStateNotification(){ //Create a new notification comprising the //current game state Notification n = new Notification(&quot;gameState&quot;); n.addParameter(&quot;altitude&quot;, altitude); n.addParameter(&quot;fuel&quot;, fuel); n.addParameter(&quot;velocity&quot;, velocity); n.addParameter(&quot;time&quot;, time); n.addParameter(&quot;burnRate&quot;, burnRate); n.addParameter(&quot;landedSafely&quot;, landedSafely); return n; } protected void handle(Notification n){ //This component does not handle notifications } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 44.
  • 45. GameLogic Component import c2.framework.*; public class GameLogic extends ComponentThread{ public GameLogic(){ super.create(&quot;gameLogic&quot;, FIFOPort.class); } //Game constants final int GRAVITY = 2; //Internal state values for computation int altitude = 0; int fuel = 0; int velocity = 0; int time = 0; int burnRate = 0; public void start(){ super.start(); Request r = new Request(&quot;getGameState&quot;); send(r); } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 46. GameLogic Component import c2.framework.*; public class GameLogic extends ComponentThread{ public GameLogic(){ super.create(&quot;gameLogic&quot;, FIFOPort.class); } //Game constants final int GRAVITY = 2; //Internal state values for computation int altitude = 0; int fuel = 0; int velocity = 0; int time = 0; int burnRate = 0; public void start(){ super.start(); Request r = new Request(&quot;getGameState&quot;); send(r); } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ if(n.hasParameter(&quot;altitude&quot;)){ this.altitude = ((Integer)n.getParameter(&quot;altitude&quot;)).intValue(); } if(n.hasParameter(&quot;fuel&quot;)){ this.fuel = ((Integer)n.getParameter(&quot;fuel&quot;)).intValue(); } if(n.hasParameter(&quot;velocity&quot;)){ this.velocity = ((Integer)n.getParameter(&quot;velocity&quot;)).intValue(); } if(n.hasParameter(&quot;time&quot;)){ this.time = ((Integer)n.getParameter(&quot;time&quot;)).intValue(); } if(n.hasParameter(&quot;burnRate&quot;)){ this.burnRate = ((Integer)n.getParameter(&quot;burnRate&quot;)).intValue(); } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 47. GameLogic Component import c2.framework.*; public class GameLogic extends ComponentThread{ public GameLogic(){ super.create(&quot;gameLogic&quot;, FIFOPort.class); } //Game constants final int GRAVITY = 2; //Internal state values for computation int altitude = 0; int fuel = 0; int velocity = 0; int time = 0; int burnRate = 0; public void start(){ super.start(); Request r = new Request(&quot;getGameState&quot;); send(r); } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ if(n.hasParameter(&quot;altitude&quot;)){ this.altitude = ((Integer)n.getParameter(&quot;altitude&quot;)).intValue(); } if(n.hasParameter(&quot;fuel&quot;)){ this.fuel = ((Integer)n.getParameter(&quot;fuel&quot;)).intValue(); } if(n.hasParameter(&quot;velocity&quot;)){ this.velocity = ((Integer)n.getParameter(&quot;velocity&quot;)).intValue(); } if(n.hasParameter(&quot;time&quot;)){ this.time = ((Integer)n.getParameter(&quot;time&quot;)).intValue(); } if(n.hasParameter(&quot;burnRate&quot;)){ this.burnRate = ((Integer)n.getParameter(&quot;burnRate&quot;)).intValue(); } } else if(n.name().equals(&quot;clockTick&quot;)){ //Calculate new lander state values int actualBurnRate = burnRate; if(actualBurnRate > fuel){ //Ensure we don’t burn more fuel than we have actualBurnRate = fuel; } time = time + 1; altitude = altitude - velocity; velocity = ((velocity + GRAVITY) * 10 – actualBurnRate * 2) / 10; fuel = fuel - actualBurnRate; //Determine if we landed (safely) boolean landedSafely = false; if(altitude <= 0){ altitude = 0; if(velocity <= 5){ landedSafely = true; } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 48. GameLogic Component import c2.framework.*; public class GameLogic extends ComponentThread{ public GameLogic(){ super.create(&quot;gameLogic&quot;, FIFOPort.class); } //Game constants final int GRAVITY = 2; //Internal state values for computation int altitude = 0; int fuel = 0; int velocity = 0; int time = 0; int burnRate = 0; public void start(){ super.start(); Request r = new Request(&quot;getGameState&quot;); send(r); } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ if(n.hasParameter(&quot;altitude&quot;)){ this.altitude = ((Integer)n.getParameter(&quot;altitude&quot;)).intValue(); } if(n.hasParameter(&quot;fuel&quot;)){ this.fuel = ((Integer)n.getParameter(&quot;fuel&quot;)).intValue(); } if(n.hasParameter(&quot;velocity&quot;)){ this.velocity = ((Integer)n.getParameter(&quot;velocity&quot;)).intValue(); } if(n.hasParameter(&quot;time&quot;)){ this.time = ((Integer)n.getParameter(&quot;time&quot;)).intValue(); } if(n.hasParameter(&quot;burnRate&quot;)){ this.burnRate = ((Integer)n.getParameter(&quot;burnRate&quot;)).intValue(); } } else if(n.name().equals(&quot;clockTick&quot;)){ //Calculate new lander state values int actualBurnRate = burnRate; if(actualBurnRate > fuel){ //Ensure we don’t burn more fuel than we have actualBurnRate = fuel; } time = time + 1; altitude = altitude - velocity; velocity = ((velocity + GRAVITY) * 10 – actualBurnRate * 2) / 10; fuel = fuel - actualBurnRate; //Determine if we landed (safely) boolean landedSafely = false; if(altitude <= 0){ altitude = 0; if(velocity <= 5){ landedSafely = true; } } Request r = new Request(&quot;updateGameState&quot;); r.addParameter(&quot;time&quot;, time); r.addParameter(&quot;altitude&quot;, altitude); r.addParameter(&quot;velocity&quot;, velocity); r.addParameter(&quot;fuel&quot;, fuel); r.addParameter(&quot;landedSafely&quot;, landedSafely); send(r); } } protected void handle(Request r){ //This component does not handle requests } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 49.
  • 50. GUI Component import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import c2.framework.*; public class GUI extends ComponentThread{ public GUI(){ super.create(&quot;gui&quot;, FIFOPort.class); } public void start(){ super.start(); Thread t = new Thread(){ public void run(){ processInput(); } }; t.start(); } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 51. GUI Component import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import c2.framework.*; public class GUI extends ComponentThread{ public GUI(){ super.create(&quot;gui&quot;, FIFOPort.class); } public void start(){ super.start(); Thread t = new Thread(){ public void run(){ processInput(); } }; t.start(); } public void processInput(){ System.out.println(&quot;Welcome to Lunar Lander&quot;); try{ BufferedReader inputReader = new BufferedReader( new InputStreamReader(System.in)); int burnRate = 0; do{ System.out.println(&quot;Enter burn rate or <0 to quit:&quot;); try{ String burnRateString = inputReader.readLine(); burnRate = Integer.parseInt(burnRateString); Request r = new Request(&quot;updateGameState&quot;); r.addParameter(&quot;burnRate&quot;, burnRate); send(r); } catch(NumberFormatException nfe){ System.out.println(&quot;Invalid burn rate.&quot;); } }while(burnRate >= 0); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 52. GUI Component import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import c2.framework.*; public class GUI extends ComponentThread{ public GUI(){ super.create(&quot;gui&quot;, FIFOPort.class); } public void start(){ super.start(); Thread t = new Thread(){ public void run(){ processInput(); } }; t.start(); } public void processInput(){ System.out.println(&quot;Welcome to Lunar Lander&quot;); try{ BufferedReader inputReader = new BufferedReader( new InputStreamReader(System.in)); int burnRate = 0; do{ System.out.println(&quot;Enter burn rate or <0 to quit:&quot;); try{ String burnRateString = inputReader.readLine(); burnRate = Integer.parseInt(burnRateString); Request r = new Request(&quot;updateGameState&quot;); r.addParameter(&quot;burnRate&quot;, burnRate); send(r); } catch(NumberFormatException nfe){ System.out.println(&quot;Invalid burn rate.&quot;); } }while(burnRate >= 0); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ System.out.println(); System.out.println(&quot;New game state:&quot;); if(n.hasParameter(&quot;altitude&quot;)){ System.out.println(&quot; Altitude: &quot; + n.getParameter(&quot;altitude&quot;)); } if(n.hasParameter(&quot;fuel&quot;)){ System.out.println(&quot; Fuel: &quot; + n.getParameter(&quot;fuel&quot;)); } if(n.hasParameter(&quot;velocity&quot;)){ System.out.println(&quot; Velocity: &quot; + n.getParameter(&quot;velocity&quot;)); } if(n.hasParameter(&quot;time&quot;)){ System.out.println(&quot; Time: &quot; + n.getParameter(&quot;time&quot;)); } if(n.hasParameter(&quot;burnRate&quot;)){ System.out.println(&quot; Burn rate: &quot; + n.getParameter(&quot;burnRate&quot;)); } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 53. GUI Component import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import c2.framework.*; public class GUI extends ComponentThread{ public GUI(){ super.create(&quot;gui&quot;, FIFOPort.class); } public void start(){ super.start(); Thread t = new Thread(){ public void run(){ processInput(); } }; t.start(); } public void processInput(){ System.out.println(&quot;Welcome to Lunar Lander&quot;); try{ BufferedReader inputReader = new BufferedReader( new InputStreamReader(System.in)); int burnRate = 0; do{ System.out.println(&quot;Enter burn rate or <0 to quit:&quot;); try{ String burnRateString = inputReader.readLine(); burnRate = Integer.parseInt(burnRateString); Request r = new Request(&quot;updateGameState&quot;); r.addParameter(&quot;burnRate&quot;, burnRate); send(r); } catch(NumberFormatException nfe){ System.out.println(&quot;Invalid burn rate.&quot;); } }while(burnRate >= 0); inputReader.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } protected void handle(Notification n){ if(n.name().equals(&quot;gameState&quot;)){ System.out.println(); System.out.println(&quot;New game state:&quot;); if(n.hasParameter(&quot;altitude&quot;)){ System.out.println(&quot; Altitude: &quot; + n.getParameter(&quot;altitude&quot;)); } if(n.hasParameter(&quot;fuel&quot;)){ System.out.println(&quot; Fuel: &quot; + n.getParameter(&quot;fuel&quot;)); } if(n.hasParameter(&quot;velocity&quot;)){ System.out.println(&quot; Velocity: &quot; + n.getParameter(&quot;velocity&quot;)); } if(n.hasParameter(&quot;time&quot;)){ System.out.println(&quot; Time: &quot; + n.getParameter(&quot;time&quot;)); } if(n.hasParameter(&quot;burnRate&quot;)){ System.out.println(&quot; Burn rate: &quot; + n.getParameter(&quot;burnRate&quot;)); } if(n.hasParameter(&quot;altitude&quot;)){ int altitude = ((Integer)n.getParameter(&quot;altitude&quot;)).intValue(); if(altitude <= 0){ boolean landedSafely = ((Boolean)n.getParameter(&quot;landedSafely&quot;)) .booleanValue(); if(landedSafely){ System.out.println(&quot;You have landed safely.&quot;); } else{ System.out.println(&quot;You have crashed.&quot;); } System.exit(0); } } } } protected void handle(Request r){ //This component does not handle requests } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 54.
  • 55. Main Program import c2.framework.*; public class LunarLander{ public static void main(String[] args){ //Create the Lunar Lander architecture Architecture lunarLander = new SimpleArchitecture(&quot;LunarLander&quot;); //Create the components Component clock = new Clock(); Component gameState = new GameState(); Component gameLogic = new GameLogic(); Component gui = new GUI(); //Create the connectors Connector bus = new ConnectorThread(&quot;bus&quot;); //Add the components and connectors to the architecture lunarLander.addComponent(clock); lunarLander.addComponent(gameState); lunarLander.addComponent(gameLogic); lunarLander.addComponent(gui); lunarLander.addConnector(bus); Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 56. Main Program import c2.framework.*; public class LunarLander{ public static void main(String[] args){ //Create the Lunar Lander architecture Architecture lunarLander = new SimpleArchitecture(&quot;LunarLander&quot;); //Create the components Component clock = new Clock(); Component gameState = new GameState(); Component gameLogic = new GameLogic(); Component gui = new GUI(); //Create the connectors Connector bus = new ConnectorThread(&quot;bus&quot;); //Add the components and connectors to the architecture lunarLander.addComponent(clock); lunarLander.addComponent(gameState); lunarLander.addComponent(gameLogic); lunarLander.addComponent(gui); lunarLander.addConnector(bus); //Create the welds (links) between components and //connectors lunarLander.weld(clock, bus); lunarLander.weld(gameState, bus); lunarLander.weld(bus, gameLogic); lunarLander.weld(bus, gui); //Start the application lunarLander.start(); } } Software Architecture: Foundations, Theory, and Practice ; Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy; (C) 2008 John Wiley & Sons, Inc. Reprinted with permission.
  • 57.