Managing Software Development
Project 1: More Products through Feature Combination
Spring 2008
Karl Lieberherr  
Out: Jan. 27, 2008

Due date: Feb. 4, 2008 

Preparation:
Learn how to program with AspectJ and DemeterJ.
There will be a lab session on two Thursdays: 1/31 5-7 pm and 2/6 5-7 pm in WVH 212. 
Immediately before the lab there is an installation session
at 4.30 pm in WVH 212 to get help from Feng to install the software
for your account or computer.

Topics:
using DemeterJ
using AspectJ
using Eclipse
  - drawing UML class diagrams (Omondo plug-in)
  - compiling and modifying Java programs
  - using AspectJ plugin
  - using DemeterJ
  - using DemeterF
using the wiki

If you cannot come at this time, make sure you get the notes from a friend.

Motivation for learning AspectJ:
http://www.ccs.neu.edu/home/lieber/courses/csg110/sp08/AspectJ-used/

We use an incremental software development process.
For each of the features that you implement, 
dig for the requirements, do requirements analysis, write test cases,
do design and implementation. 

In this project you learn an important new skill:
Adding new behavior to a program without editing the program.
Evolution by addition, rather than modification is another
good slogan summarizing the approach.
Aspect-Oriented Programming facilitates evolution by addition, rather than modification.

In this project you also learn to adapt to new technologies in the 
Aspect-Oriented Programming space:
AspectJ, DemeterJ and DemeterF.
DemeterJ we use for Java data binding, AspectJ and DemeterJ we use to add features.
DemeterF we use to follow the Law of Demeter and avoid
lots of boiler plate code and to prepare our
programs to run fast on multi-core machines.

In project 3 we start with a development diary:
http://www.ccs.neu.edu/home/lieber/courses/csg110/sp08/development-diary.html
Please include your diary for each part of the project as well as
the documents you reference in the diary.
For non programming parts, adapt the diary accordingly (no design, test cases etc.)

As software development process we use:
http://en.wikipedia.org/wiki/IBM_Rational_Unified_Process


PART 0: Managing Feature Addition using Advice
==============================================

Consider the program in directory var-count-advice.
It contains a base program that counts the number of variables
in a cnf. 
Implement the weight-count feature 
for this program which counts the weighted variables.
The weight of a variable is the weight of the enclosing clause. 

You need to add this feature to the base program without
modifying the base program. The base program has been
prepared to facilitate this addition.
You only need to modify file demf/VarWeightCounter.java
to add the feature.

Use the shell script 
var-count-advice/compile-features
to create two members of the product line:
the base and the weight-count feature.


PART 1: Managing Feature Addition using Inter-Type Declaration
==============================================================

The problem is similar to PART 0: we want to add a feature
to a base program without having to edit the base program.
We can modify programs either by modifying them dynamically
during the execution of the program or by adding new methods
to the program. Here we add a new method.

The plan was to use an AspectJ inter-type declaration,
but it did not work. See:
var-count-inter-type/aspectj+reflection

Instead we use DemeterJ to express the inter-type declaration.
You need to write the file: demf/VarWeightCounter.beh

Please ignore the Shannon Decomposition code that
was added to this part. It will be used in the next part.

Use the shell script 
var-count-inter-type/compile-features
to create two members of the product line:
the base and the weight-count feature.
Note that this script is different than in PART 1.

What to turn in:
The file VarWeightCounter.beh.


PART 2: Add a reduction feature
===============================

In PART 1 we use Shannon decomposition to simplify
a formula when a variable is assigned.

The Shannon expansion develops the idea that 
Boolean functions can be reduced by means of the identity:

    F = x \cdot F_x + x' \cdot F_x',

where F is any function and 
F_x and F_x' are positive and negative 
Shannon cofactors of F, respectively.

In other words, the Shannon cofactors are reduced or simplified
versions of the original formula.

The Shannon cofactors are computed by the CNFReducer class.

Your task is to generalize the reduction as follows:
So far a clause was satisfied when at least one literal was satisfied.
Now a clause is satisfied when at least two literals are satisfied.
We call such a clause a constraint.
You may assume that a constraint involves at most 3 literals.

Here is an analysis of the transition space for a constraint:
(i,j,k are literals)

atleast2(i,j,k)
  i=t: atleast1(j,k)
    j=t: sat
    j=f: atleast1(k)
      k=t: sat
      k=f: unsat
  i=f: atleast2(j,k)
    j=t: atleast1(k) see above
    j=f: unsat

You need to update the class dictionary to represent the constraints


What to turn in:
Your modified reducer. Use it to determine the quality of an assignment.

Tool PART = PART 3

PURPOSE: See DemeterJ in action. Study an application of the concepts covered so far in the context of a Java application. Gives you an impression how structure-shy programming works.

Tasks to be done: Read and work through the complete Laboratory Guide using DemeterJ and hand in all files modified.

The Laboratory Guide introduces you to DemeterJ (formerly called Demeter/Java) but much of what you learn will help you to write Java Programs with DemeterF and a tiny bit of DemeterJ. So when you go through the Laboratory Guide, focus on class dictionaries and how you would express the adaptive programs you encounter directly using DemeterF without using the adaptive programming language of DemeterJ.

Name substitution throughout Laboratory Guide and other documents:
Demeter/Java -> DemeterJ
demjava -> demeterj

READING:

Read chapters 11, 12 of the AP book. http://www.ccs.neu.edu/research/demeter/biblio/dem-book.html

The class dictionary for DemeterJ which defines the DemeterJ notation. It is reachable from the DemeterJ and AP-Studio resources page: http://www.ccs.neu.edu/research/demeter/DemeterJava/

Plus additional reading as described below.


Browse through the DemeterJ User's Guide. also available from the DemeterJ Resources page http://www.ccs.neu.edu/research/demeter/DemeterJava/. Focus on class dictionaries and only a little bit on the adaptive programming language of DemeterJ.

Browsing the User's Guide will help you to better understand the Laboratory Guide.

The purpose of this laboratory exercise is to see adaptive programming in operation in the Java world. Turn in all the files you modified.

From a happy user of the Demeter/C++ lab guide. The DemeterJ Laboratory Guide is a translation of the Demeter/C++ Lab Guide.

Hi Crista:
 
I just finished working through the Demeter Lab Guide and already feel
a lot more comfortable with Demeter. The Lab Guide is concise, clear
and written with a great deal of empathy for the user. Congratulations
for doing such an excellent job with the Lab Guide!
 
...

What to turn in: For the tools part: Modified files.

Please send mail to

csg110-grader@ccs.neu.edu

if you find something not clear in this Project Description.