CSE 668 Applied Component-based Software Engineeing
Software Development Assignments
(25%) Lab1 Waterworks - Valves and Tanks
Summary: Write a small class library (.dll) for valves with different behaviors and tanks or resevoirs with difference behaviors. Develop unit tests for all of your classes.
Objectives: Basic C# Visual Studio usage, developing type libraries, doing things the wrong way so we can correct them later, unit testing, code documentation.
Due: The last minute in January 2009. 1-31-2009 at 11:59pm (note that the CSE labs close early on Saturdays).
Specifications:
- (10 pts) Write a class hierarchy for water valves, including an abstract base class which supports an Open/Close virtual method call, and a property to get the current Flux or (signed) Capacity of the valve. The flux should be in floating point and can be negative.
- (7 pts) Write a concrete class for a simple valve that has a fixed maximum flux when open and zero flux when closed.
- (7 pts) Write a concrete class that has a variable flux (percent open).
- (7 pts) Write a concrete class that has a back-flow safety feature preventing the flow (flux) from being negative.
- (10 pts) Write a class hierarchy for water tanks, including an abstract base class which supports a collection of inlet valves, a collection of outlet valves, and properties for the current pressure, current volume, current temperature and the percentage full.
- (7 pts) Write a concrete class for a simple tank with a fixed maximum volume.
- (7 pts) Write a concrete class for a high pressure tank.
- (7 pts) Write a concrete class for a open resevoir (infinite volume).
- (10 pts) Develop unit tests for the entire valve hierarchy.
- (10 pts) Develop unit tests for the entire tank hierarchy.
- (7 pts) Write a UML Class diagram for the valve hierarchy.
- (7 pts) Write a UML Class diagram for the tank hierarchy.
- (7 pts) Write in-code documentation for the valve hierarchy.
- (7 pts) Write in-code documentation for the tank hierarchy.
(35%) Lab2 Waterworks - Programming to Interfaces and Design Patterns
Summary: Refactor your Lab1 into two type libraries, one containing only interfaces for your valve base and your tank base. A second class library contains all of your concrete classes. Add a third project that will be a crude simulator. We will use a Windows Console Application for this.
Objectives: Programming to events. Implementing the Composite, Builder, Singleton and Factory method design patterns. Reading in XML files. Working with .NET events.
Part I Due: February 17, 2009 at 11:59pm (note that the CSE labs close before midnight).
Specifications Part I (40 points):
- (5 pts) Create an IValve and an ITank interface for your valves and tanks. Place these in a separate class library. Have you existing VavleBase and TankBase implement these interfaces as appropriate. Use Add Reference in Visual Studio to add the interface type library to your valve/tank library. Test your existing Unit testing framework to make sure everything still works.
- (8 pts) Add a new concrete valve that uses the Composite Design Pattern. A composite valve is a connected set of tanks and valves, with one and only one valve not connected as an inlet valve of a tank in the composite and one and only one valve not connected to an outlet valve of a tank in the composite. Also, each valve has to have at least one connection to a tank. For simplicity, assume we have a validly constructed composite valve (see below), that the internal valves are fixed in their state then and handle the Open/Close and other behaviors appropriately for the composite. Hmmm. I wonder what it means to Open a composite valve? No knowledge of any concrete tanks or valves should be part of this class.
- (10 pts) Create a composite valve builder class using the Builder Design Pattern. On retrieving the finished composite valve, ensure that it is valid. If not, throw an exception. See also the System.Text.StringBuilder class. Hmmm. Now which project should this go into? This class should use the valve and tank interfaces only except for the concrete composite valve.
- (5 pts) Develop new unit tests for the your new concrete classes.
- (2 pts) Write a UML Class diagram for the composite valve.
- (3 pts) Write a UML Class diagram for the valve builder class.
- (7 pts) Create a little driver program to create and test your new classes. Comment this driver program profusely.
Part II Due: February 25, 2009 at 11:59pm (note that the CSE labs close before midnight).
Specifications Part II (60 points):
- (10 points) Create a Asset Manager that keeps track of all valves and tanks in the system. An asset should be 1) easy to reference; 2) persistent in the system; 3) possibly shared across many sub-components. I typically associate an instance with a string (e.g, Name). This allows me to query an asset using its name. You can either a) build this association outside of your valve and tank interfaces, b) add a Name get property to your interfaces or c) add a new interface, IAsset that all of your concrete classes can also implement. I usually do c.
- (10 points) Create two Factory Methods. One that creates IValve instances, and another that creates ITank instances. Both of these should take as input a XML element indicating the type of valve or tank to create and any necessary parameters. You can use the tag value to indicate the type or use an attribute. Separate the tasks of adding assets (tanks and valves) from the task of connecting them into a system. Allow for new prototype valve types to be specified and registered using the XML (see below). Now, hide all of your constructors for your concrete valves and tanks to be internal. The only way to create a tank or valve should now be through your factories.
- (7 points) Use the Prototype Design Pattern to register composite valves with the Factory. Create at least 3 interesting composite valves and register them.
- (5 points) Create Object UML diagrams of the system after the XML files have been processed.
- (10 points) Write a crude simulator using a timer to update the volumes of the tanks at each tick. For now, just change the volume based on the entire flux of the tank.
- (10 points) Add events to your system
/ classes / interfaces (and just how do we add an event to an interface!).
- Desired volume reached
- Valve opening.
- Valve opened.
- Valve closing.
- Valve closed.
- Pressure critically high
- Pressure critically low
- (8 points) Add a logger to your system to write out the events to a file using XML. This should be implemented using the Singleton Design Pattern. Use the logger to subscribe to all of the events of all assets.
(40%) Lab3 Waterworks - Plug-in Architectures and .NET Remoting
Summary: Refactor your Lab2 such that your factories dynamically detects new valves or tanks to create at run-time. Allow the creation and hosting of tanks or valves on different processes or even different machines.
Objectives: Working with .NET Remoting, include singleton objects and persistent instance objects.
Due: March 14, 2009 at 11:59pm (note that the CSE labs close before midnight).
Specifications:
- (50%) Rework your factory, such that it can take an Assembly and create instances of any valves or tanks in the assembly. Read in (load) a seperate assembly with all of your concrete tanks and valves in the simulator and then pass this to the factory. Your XML input should now still work at this point.
- We can not seem to resolve the Vista security issues, so below is no longer part of the assignment:
- (50%) Create an additional console application that contains your logger class and prints out the events to the Console window rather than XML. From your simulator, call Process.Start to start this application immediately such that any references to the logger are fine. Use a config file (App.config) in each of the projects (simulator and logger) to create a .NET Remoting link between the two such that the Logger is a Singleton Server Activated Object. You can hardcode the localhost address (use localhost, not numbers) and the port number in the config file.
- Here is a simple Demo program of the factory method using plug-ins. Note that your concrete constructors can be internal.