ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Alberto Fernandez" <j_a_fernan...@yahoo.com>
Subject Appropriate coding methodology
Date Tue, 27 Nov 2001 14:13:19 GMT
Hi guys,

While going through the code and taking a look at what Erik was saying about the behavior
of <ant> I noticed that in several parts of that code we use the following pattern:

    Property p = (Property) project.createTask("property");
    p.setName(...);
    p.setValue(...);

or something like:

    Ant callee  = (Ant) project.createTask("ant");
    callee.setOwningTarget(target);
    callee.setTaskName(getTaskName());
    callee.setLocation(location);

This code assumes that the names above will always be linked to the particular implementations
as provided by the default .properties files. On other parts of the code this usage of createTask()
has been considered to be bad
and instead the encouragment has been for usages of the form:

    Ant callee = new Ant(project);
    callee.setsetOwningTarget(target);
    callee.setTaskName(getTaskName());
    callee.setLocation(location);

or:

    Property p = new Property(project);
    ...

which is inmune to task name manipulation. You get an object of the class you asked for.

The current code, seem to be using one way or the other depending on how the person writing
the code felt at that moment in time. Can we continue doing it that way. Shall we define when
should one be used instead of another?

Another example of this is whether one should subclass a Task (use the actual class) or delegate
to another
task created using Project.createTask(). Once again we see this two patterns used in different
parts.

What do people think is the right codding standard for a more maintainable code.

Jose Alberto



Mime
View raw message