Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nebula - An Example of Dependency Tracking Friday 22nd March 2002.

Similar presentations


Presentation on theme: "Nebula - An Example of Dependency Tracking Friday 22nd March 2002."— Presentation transcript:

1 Nebula - An Example of Dependency Tracking Friday 22nd March 2002

2 Introduction This talk will introduce Michael Perry's Dependency Tracker and his example 'Nebula' This talk will introduce Michael Perry's Dependency Tracker and his example 'Nebula' It will then present a version of Nebula developed using automated dependency maintenance with the JaM2 API It will then present a version of Nebula developed using automated dependency maintenance with the JaM2 API

3 Nebula Published in 3 parts (17 Aug, 01 Sep, 19 Oct 2001) in JavaWorld Published in 3 parts (17 Aug, 01 Sep, 19 Oct 2001) in JavaWorld Written by Michael L Perry Written by Michael L Perry Nebula is a TCP/IP network modelling tool developed in Java Nebula is a TCP/IP network modelling tool developed in Java The aim of the article was to show an alternative to the Observer design pattern when developing user interfaces The aim of the article was to show an alternative to the Observer design pattern when developing user interfaces

4 Using MLP's dependency tracker Decide which of our object attributes are 'Dynamic' data Decide which of our object attributes are 'Dynamic' data This is the data that wish to track changes to This is the data that wish to track changes to Data should already be accessed via methods, add 'Sentry' notifications to these methods Data should already be accessed via methods, add 'Sentry' notifications to these methods

5 Dynamic Data and Sentries public class Value { public int getValue() public int getValue() { dynValue.onGet(); dynValue.onGet(); return value; return value; } public void setValue(int newvalue) public void setValue(int newvalue) { dynValue.onSet(); dynValue.onSet(); value = newvalue; value = newvalue; } int value = 0; //Dynamic Data int value = 0; //Dynamic Data Dynamic dynValue = new Dynamic(); //The Sentry Dynamic dynValue = new Dynamic(); //The Sentry}

6 Tracking Changes We have to specify how to recalculate our data elements if one of our tracked attributes changes We have to specify how to recalculate our data elements if one of our tracked attributes changes We define a 'Dependent' and an update method that will perform this calculation We define a 'Dependent' and an update method that will perform this calculation When we use data that this Dependent affects we ask the Dependent to make sure all our attributes are up to date When we use data that this Dependent affects we ask the Dependent to make sure all our attributes are up to date

7 static Value value1 = new Value(); static Value value1 = new Value(); static Value value2 = new Value(); static Value value2 = new Value(); public static void main(String[] args) public static void main(String[] args) { //Register a recalculation method (i.e. A dependency definition) //Register a recalculation method (i.e. A dependency definition) //This is equivalent to "value1.value is 2 * value2.value;" //This is equivalent to "value1.value is 2 * value2.value;" Dependent depValue = new Dependent( Dependent depValue = new Dependent( new IUpdate() new IUpdate() { public void onUpdate() public void onUpdate() { value2.setValue(2 * value1.getValue()); value2.setValue(2 * value1.getValue()); } }); }); value1.setValue(10); value1.setValue(10); System.out.println("Current Value 1 :" + value1.getValue()); System.out.println("Current Value 1 :" + value1.getValue()); System.out.println("Current Value 2 :" + value2.getValue()); System.out.println("Current Value 2 :" + value2.getValue()); depValue.onGet(); //We want to make sure that Value 2 is up to date depValue.onGet(); //We want to make sure that Value 2 is up to date System.out.println("Current Value 1 :" + value1.getValue()); System.out.println("Current Value 1 :" + value1.getValue()); System.out.println("Current Value 2 :" + value2.getValue()); System.out.println("Current Value 2 :" + value2.getValue()); }

8 Dependency Tracker within Nebula This dependency tracker is used within Nebula to: This dependency tracker is used within Nebula to: Keep the graphical representation of the Information Model up to date Keep the graphical representation of the Information Model up to date So LocatedNetwork contains dynamic data consisting of a HashMap from Devices to LocatedDevices So LocatedNetwork contains dynamic data consisting of a HashMap from Devices to LocatedDevices When the UI draws the LocatedNetwork the update method makes sure the HashMap is up to date When the UI draws the LocatedNetwork the update method makes sure the HashMap is up to date

9 JaM2 The aim was to construct a simplified version of the Nebula tool using JaM2 to maintain dependencies automatically rather than just tracking them The aim was to construct a simplified version of the Nebula tool using JaM2 to maintain dependencies automatically rather than just tracking them This meant that the network had to be modelled as a definitive script and notation for manipulating networks defined This meant that the network had to be modelled as a definitive script and notation for manipulating networks defined

10 Building the JaM2 Model Data Types (Device, Computer, Hub, Cable) Data Types (Device, Computer, Hub, Cable) Operators (join, drawDevice, drawCable) Operators (join, drawDevice, drawCable) A sample network A sample network Modifying the network Modifying the network Redefinitions triggered by user actions Redefinitions triggered by user actions Altering the script Altering the script

11 JaM2 Version Notes JaM2 version is script based, every dependency is declared in the script JaM2 version is script based, every dependency is declared in the script Updates are automatic and are done as needed Updates are automatic and are done as needed Chains of dependency can be established Chains of dependency can be established Updates are 'pushed' Updates are 'pushed'

12 Original Version Notes Tracker version discovers dependencies automatically, update methods have to be specified Tracker version discovers dependencies automatically, update methods have to be specified Dependency chains must be explicit (update methods must make sure their dependents are up to date before they perform their calculation) Dependency chains must be explicit (update methods must make sure their dependents are up to date before they perform their calculation) Updates are 'pulled' Updates are 'pulled'

13 Summary Nebula - Network Design Tool Nebula - Network Design Tool Reimplemented using JaM2 Reimplemented using JaM2 Definitive Script instead of Object Model Definitive Script instead of Object Model


Download ppt "Nebula - An Example of Dependency Tracking Friday 22nd March 2002."

Similar presentations


Ads by Google