On Jun 22, 2006, at 4:31 AM, John Haxby wrote:

DM Smith wrote:
Generally open source projects have a policy to change as little of the file
as possible, only changing what is necessary.
Hmmm. Necessary by what criterion? Necessary to make, say, Lucene exploit the new interator constructs to avoid run-time type- checking? Necessary to make the code more readable? Necessary to prevent use with Java 1.4? :-)

I'm not sure I've ever seen a policy expressed in that way -- patches generally should be clear, concise and do what they're intended to do, but that doesn't necessarily mean minimising the size of the patch and it doesn't necessarily mean keeping the source compatible with some old compiler or environment.

I wasn't trying to be argumentative (with this statement). I probably stated it badly.

I simply meant that the change that is being made should be done in such a way that one applying the patch can readily see what is being changed. The most common case of unnecessary change is that of whitespace. Changing indentation, changing the placement of curly braces, reordering methods and variables and so forth are all unnecessary.

There are structural changes to the code that can be done that do not change the behavior of the code. Some developers feel strongly about one construct over another. For example take the following example:
public int f(int x)
{
        if (x > 0)
                return x * 2;
        else
                return x * -2;
}

Some think its dumb that there is an else clause as above.
public int f(int x)
{
        if (x > 0)
                return x * 2;
        return x * -2;
}

Others feel strongly that there should only be one exit in a method:
public int f(int x)
{
        int ret = 0;
        if (x > 0)
                ret = x * -2;
        else
                ret = x * -2;
        return ret;
}

Some like brevity:
public int f(int x) { return x*(x>0?2:-2;}

Such a change is most likely unnecessary.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to