Introduction
Few questions that have always drawn attention of the Software Engineering community
1. Is there any simpler way to explain the functionality of software to a layman? -Simpler then UML diagrams?
2. Can we start with a single representation and use it to generate the program as well as generate the test cases and documentation? – Can the representation x applied to a function f i.e. f(x) produce the desired program, generate the documents, and test cases?
3. Can we produce an optimized version by working on the original representation of software? Can O (n^2) explicit complexity of the representation x be reduced to O (n)?
4. My mom doesn’t know programming; can she still be able to write software? Can she just say -”I need a calculator to multiply two integers” and the calculator is before her screen?
Everyone in the IT industry would be happy to have all these in place. The main reason would be a huge reduction in the software development cost. And yes, recent research in Software Engineering is just focusing on them. Some major research in this area is going on product-line architecture in Department of Computer Science in UT Austin. They are working on feature-refinement techniques and almost covering all of the challenges 1-4 .
What is a feature?
A feature is a unit of functionality provided by a program. e.g. let’s take an example of calculator. The normal features of the calculator are addition, subtraction, multiplication and division of integers. Features can be added and removed and replaced just like different software to and from an OS. Product line architecture mainly deals with developing software by incrementally adding features to a product. The paradigm of software development using features as building block is called feature oriented programming.
FOP implementation
AHEAD or Algebraic Hierarchical Equations for Application Design is one of the pioneering work in FOP by the product line architecture group. It represents a program or a set of programs using a nested set of equations. It uses constants (a feature), a function (a feature refinement) and a few operators to write the equations. The equations are ideal for code generators and can be interpreted by different generators to produce codes, as well as documentations and test cases etc (2). They are simple enough to explain. Since they are based on algebraic equations, they are susceptible to optimization (3)
The main operator is called composition and it’s represented by a solid dot (•). Lets take an example of the use of this operator – let f is a program with features bf ,af ,cf and h with features bh ah and dh.
Then the composition of f and h is given by
f•h = { bf ,af ,cf }•{ bh, ah , dh}
= { bf• bh , af• ah , cf , dh }
Note that the constants with same name but different subscription are recursively composed to produce the final product f•h. The operator • is polymorphic so you are free to implement the operator as you like and produce your own implementation. E.g. it can be javac to produce the java codes from the equations, may be javadoc to produce the html pages.
I would include the other operators in my next post.
AHEAD Tool Set
ATS is the software kit that can be used to develop software in a feature oriented way.
You can download the latest version of AHEAD tool set from this link. AHEAD is developed in Java, so you will need JAVA. It is also preferable to download ANT as well. ATS comes with a composer. I have used it for refinement of Jak features. Jak features are written in a Java like languages that conforms to Jakarta Tool Set. Typically you pass the Algebraic equation to composer and the composer produces the desired product for you. Let’s try out your first programming in AHEAD using the FOP concepts.
Hello World in AHEAD
Aim : To generate a program that writes “Hello World” in three languages English, Hindi and Assamese.
Features –
- Base : that writes “Hello World” – English
- Hindi : That writes “Namaste India” – Hindi
- Assamese : That Writes “Namaskar Axom” – Assamese
Toolset version:
Runs in Linux
ahead-v2007.08.28
Steps:
1. Create the following hierarchy of directory in your $HOME
2. Copy the following files to the appropriate directories
a. HelloWorld/Base/hello.jak
public class hello
{
String str = “Hello World”;
public void print()
{
System.out.println(str);
}
}
b. HelloWorld/Hindi/hello.jak
refines class hello
{
public void print()
{
str += “\n Namaste India.” ;
Super().print();
}
}
Note that we are using Super().print() to refer to the definition of the print() of the super class in the hierarchy. In this case Base->Hindi->Assamese
c.HelloWorld/Assamese/hello.jak
refines class hello
{
public void print()
{
str +=”\n Namaskar Axom”;
Super().print();
}
}
3. Create a file called composer.properties to set the following property –
unit.file.jak: JamPackFileUnit
It says when composing Jak files use the tool “jampack”. jampack is shipped with ATS.
4. Now in our case we want a composition comp = Base • Hindi • Assamese so that we can print something like
Hello World
Namaskar Axom
Namaste India.
So we run the composer inside HelloWorld as follows
$ composer –target=comp Base Hindi Assamese
5 . The composer creates a directory called comp in the same level.
The resulting composition will be the same “hello.jak” with the following modification –
layer comp;
public class hello
{
String str = “Hello World”;
public final void print$$Base()
{
System.out.println(str);
}
public final void print$$Hindi()
{
str += “\n Namaste India.” ;
print$$Base();
}
public void print()
{
str +=”\n Namaskar Axom”;
print$$Hindi();
}
}
You can see the tool is very intelligent to replace every Super().print() is replaced by a function with name as print$$[base class] . So finally when we call hello.print it should print the desired result .
6. The java code for the corresponding jak code is generated by jak2java tool comes with ATS.
So
$ jak2java hello.jak
will result in hello.java with
package comp;
public class hello
{
String str = “Hello World”;
public final void print$$Base()
{
System.out.println(str);
}
public final void print$$Hindi()
{
str += “\n Namaste India.” ;
print$$Base();
}
public void print()
{
str +=”\n Namaskar Axom”;
print$$Hindi();
}
}
7. Just write a test program to test it . I am using the following test program to do so .
import i3.*;
class test
{
public static void main(String args[])
{
hello c = new hello();
c.print();
}
}
~
And you should see something like
Hello World
Namaskar Axom
Namaste India.
On the screen.
A FEW MORE POINTS
If you want to install AHEAD from the source code – you must used the latest versions of Jdk and Ant , javaCC.
I am using the following version
Be sure to set the env variable JAVA_HOME, ANT_HOME, AHEAD_HOME, PATH and LD_LIBRARY_PATH. I am still having some issues with compiling “reform” so I am using the executables instead.
In any case feel free to drop me your thoughts, queries. I would happy to discuss.
In my next post I would try to describe one more approach of FOP that I have used recently.
Just a point to ponder – “Compositor is polymorphic. What kind of polymorphism it supports? Dynamic or Static?”

Comments