SlideShare une entreprise Scribd logo
1  sur  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]

Contenu connexe

Tendances

Ericsson 5G plug-ins
Ericsson 5G plug-insEricsson 5G plug-ins
Ericsson 5G plug-insEricsson
 
Beginners: Open RAN, White Box RAN & vRAN
Beginners: Open RAN, White Box RAN & vRANBeginners: Open RAN, White Box RAN & vRAN
Beginners: Open RAN, White Box RAN & vRAN3G4G
 
Diameter Capabilities Exchange
Diameter Capabilities ExchangeDiameter Capabilities Exchange
Diameter Capabilities ExchangeArpit Prajapati
 
Mobile Networks Overview (2G / 3G / 4G-LTE)
Mobile Networks Overview (2G / 3G / 4G-LTE)Mobile Networks Overview (2G / 3G / 4G-LTE)
Mobile Networks Overview (2G / 3G / 4G-LTE)Hamidreza Bolhasani
 
LTE (Long Term Evolution) Introduction
LTE (Long Term Evolution) IntroductionLTE (Long Term Evolution) Introduction
LTE (Long Term Evolution) IntroductionGuisun Han
 
Software Defined Networking(SDN) and practical implementation_trupti
Software Defined Networking(SDN) and practical implementation_truptiSoftware Defined Networking(SDN) and practical implementation_trupti
Software Defined Networking(SDN) and practical implementation_truptitrups7778
 
Unblocking Stollen Mobile Phones using SS7-MaP vulnerabilities
Unblocking Stollen Mobile Phones using SS7-MaP vulnerabilities Unblocking Stollen Mobile Phones using SS7-MaP vulnerabilities
Unblocking Stollen Mobile Phones using SS7-MaP vulnerabilities Siddharth Rao
 
LTE - Long Term Evolution
LTE - Long Term EvolutionLTE - Long Term Evolution
LTE - Long Term EvolutionArief Gunawan
 
Mobile signaling threats and vulnerabilities - real cases and statistics from...
Mobile signaling threats and vulnerabilities - real cases and statistics from...Mobile signaling threats and vulnerabilities - real cases and statistics from...
Mobile signaling threats and vulnerabilities - real cases and statistics from...DefCamp
 
ePRTC in data centers - GNSS-backup-as-a-service (GBaaS)
ePRTC in data centers - GNSS-backup-as-a-service (GBaaS)ePRTC in data centers - GNSS-backup-as-a-service (GBaaS)
ePRTC in data centers - GNSS-backup-as-a-service (GBaaS)ADVA
 
Securing the Onion: 5G Cloud Native Infrastructure
Securing the Onion: 5G Cloud Native InfrastructureSecuring the Onion: 5G Cloud Native Infrastructure
Securing the Onion: 5G Cloud Native InfrastructureMyNOG
 
Advanced: Private Networks & 5G Non-Public Networks
Advanced: Private Networks & 5G Non-Public NetworksAdvanced: Private Networks & 5G Non-Public Networks
Advanced: Private Networks & 5G Non-Public Networks3G4G
 
Handover &amp;mobility in 4g5g
Handover &amp;mobility in 4g5gHandover &amp;mobility in 4g5g
Handover &amp;mobility in 4g5gabolfazlzakeri
 
Part 6: Standalone and Non-Standalone 5G - 5G for Absolute Beginners
Part 6: Standalone and Non-Standalone 5G - 5G for Absolute BeginnersPart 6: Standalone and Non-Standalone 5G - 5G for Absolute Beginners
Part 6: Standalone and Non-Standalone 5G - 5G for Absolute Beginners3G4G
 
Unit VIII wireless sensor networks
Unit VIII wireless sensor networksUnit VIII wireless sensor networks
Unit VIII wireless sensor networkssangusajjan
 
SPINS: Security Protocols for Sensor Networks
SPINS: Security Protocols for Sensor NetworksSPINS: Security Protocols for Sensor Networks
SPINS: Security Protocols for Sensor NetworksAbhijeet Awade
 
Signaling security essentials. Ready, steady, 5G!
 Signaling security essentials. Ready, steady, 5G! Signaling security essentials. Ready, steady, 5G!
Signaling security essentials. Ready, steady, 5G!PositiveTechnologies
 
5G and Open Reference Platforms
5G and Open Reference Platforms5G and Open Reference Platforms
5G and Open Reference PlatformsMichelle Holley
 

Tendances (20)

Ericsson 5G plug-ins
Ericsson 5G plug-insEricsson 5G plug-ins
Ericsson 5G plug-ins
 
Beginners: Open RAN, White Box RAN & vRAN
Beginners: Open RAN, White Box RAN & vRANBeginners: Open RAN, White Box RAN & vRAN
Beginners: Open RAN, White Box RAN & vRAN
 
Diameter Capabilities Exchange
Diameter Capabilities ExchangeDiameter Capabilities Exchange
Diameter Capabilities Exchange
 
Mobile Networks Overview (2G / 3G / 4G-LTE)
Mobile Networks Overview (2G / 3G / 4G-LTE)Mobile Networks Overview (2G / 3G / 4G-LTE)
Mobile Networks Overview (2G / 3G / 4G-LTE)
 
LTE (Long Term Evolution) Introduction
LTE (Long Term Evolution) IntroductionLTE (Long Term Evolution) Introduction
LTE (Long Term Evolution) Introduction
 
Software Defined Networking(SDN) and practical implementation_trupti
Software Defined Networking(SDN) and practical implementation_truptiSoftware Defined Networking(SDN) and practical implementation_trupti
Software Defined Networking(SDN) and practical implementation_trupti
 
Unblocking Stollen Mobile Phones using SS7-MaP vulnerabilities
Unblocking Stollen Mobile Phones using SS7-MaP vulnerabilities Unblocking Stollen Mobile Phones using SS7-MaP vulnerabilities
Unblocking Stollen Mobile Phones using SS7-MaP vulnerabilities
 
LTE - Long Term Evolution
LTE - Long Term EvolutionLTE - Long Term Evolution
LTE - Long Term Evolution
 
Mobile signaling threats and vulnerabilities - real cases and statistics from...
Mobile signaling threats and vulnerabilities - real cases and statistics from...Mobile signaling threats and vulnerabilities - real cases and statistics from...
Mobile signaling threats and vulnerabilities - real cases and statistics from...
 
ePRTC in data centers - GNSS-backup-as-a-service (GBaaS)
ePRTC in data centers - GNSS-backup-as-a-service (GBaaS)ePRTC in data centers - GNSS-backup-as-a-service (GBaaS)
ePRTC in data centers - GNSS-backup-as-a-service (GBaaS)
 
Securing the Onion: 5G Cloud Native Infrastructure
Securing the Onion: 5G Cloud Native InfrastructureSecuring the Onion: 5G Cloud Native Infrastructure
Securing the Onion: 5G Cloud Native Infrastructure
 
Advanced: Private Networks & 5G Non-Public Networks
Advanced: Private Networks & 5G Non-Public NetworksAdvanced: Private Networks & 5G Non-Public Networks
Advanced: Private Networks & 5G Non-Public Networks
 
Handover &amp;mobility in 4g5g
Handover &amp;mobility in 4g5gHandover &amp;mobility in 4g5g
Handover &amp;mobility in 4g5g
 
Part 6: Standalone and Non-Standalone 5G - 5G for Absolute Beginners
Part 6: Standalone and Non-Standalone 5G - 5G for Absolute BeginnersPart 6: Standalone and Non-Standalone 5G - 5G for Absolute Beginners
Part 6: Standalone and Non-Standalone 5G - 5G for Absolute Beginners
 
Unit VIII wireless sensor networks
Unit VIII wireless sensor networksUnit VIII wireless sensor networks
Unit VIII wireless sensor networks
 
Mpls L3_vpn
Mpls L3_vpnMpls L3_vpn
Mpls L3_vpn
 
SPINS: Security Protocols for Sensor Networks
SPINS: Security Protocols for Sensor NetworksSPINS: Security Protocols for Sensor Networks
SPINS: Security Protocols for Sensor Networks
 
Doc6 mpls vpn-ppt
Doc6 mpls vpn-pptDoc6 mpls vpn-ppt
Doc6 mpls vpn-ppt
 
Signaling security essentials. Ready, steady, 5G!
 Signaling security essentials. Ready, steady, 5G! Signaling security essentials. Ready, steady, 5G!
Signaling security essentials. Ready, steady, 5G!
 
5G and Open Reference Platforms
5G and Open Reference Platforms5G and Open Reference Platforms
5G and Open Reference Platforms
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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
 

Dernier

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 

Dernier (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
+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...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

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.