8fde3a1a8fea35459040633fd0fd284d.ppt
- Количество слайдов: 13
Nebula - An Example of Dependency Tracking Friday 22 nd March 2002
Introduction n n 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 Ja. M 2 API
Nebula n n Published in 3 parts (17 Aug, 01 Sep, 19 Oct 2001) in Java. World Written by Michael L Perry 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
Using MLP's dependency tracker n n n Decide which of our object attributes are 'Dynamic' data This is the data that wish to track changes to Data should already be accessed via methods, add 'Sentry' notifications to these methods
Dynamic Data and Sentries public class Value { public int get. Value() { dyn. Value. on. Get(); return value; } public void set. Value(int newvalue) { dyn. Value. on. Set(); value = newvalue; } int value = 0; //Dynamic Data Dynamic dyn. Value = new Dynamic(); //The Sentry }
Tracking Changes n n n 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 When we use data that this Dependent affects we ask the Dependent to make sure all our attributes are up to date
static Value value 1 = new Value(); static Value value 2 = new Value(); public static void main(String[] args) { //Register a recalculation method (i. e. A dependency definition) //This is equivalent to "value 1. value is 2 * value 2. value; " Dependent dep. Value = new Dependent( new IUpdate() { public void on. Update() { value 2. set. Value(2 * value 1. get. Value()); } }); value 1. set. Value(10); System. out. println("Current Value 1 : " + value 1. get. Value()); System. out. println("Current Value 2 : " + value 2. get. Value()); dep. Value. on. Get(); //We want to make sure that Value 2 is up to date System. out. println("Current Value 1 : " + value 1. get. Value()); System. out. println("Current Value 2 : " + value 2. get. Value()); }
Dependency Tracker within Nebula n This dependency tracker is used within Nebula to: Keep the graphical representation of the Information Model up to date n So Located. Network contains dynamic data consisting of a Hash. Map from Devices to Located. Devices n When the UI draws the Located. Network the update method makes sure the Hash. Map is up to date n
Ja. M 2 n n The aim was to construct a simplified version of the Nebula tool using Ja. M 2 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
Building the Ja. M 2 Model n n Data Types (Device, Computer, Hub, Cable) Operators (join, draw. Device, draw. Cable) A sample network Modifying the network Redefinitions triggered by user actions n Altering the script n
Ja. M 2 Version Notes n n Ja. M 2 version is script based, every dependency is declared in the script Updates are automatic and are done as needed Chains of dependency can be established Updates are 'pushed'
Original Version Notes n n n 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) Updates are 'pulled'
Summary n n n Nebula - Network Design Tool Reimplemented using Ja. M 2 Definitive Script instead of Object Model
8fde3a1a8fea35459040633fd0fd284d.ppt