google-code-export / umple

Automatically exported from code.google.com/p/umple
1 stars 0 forks source link

Dead or useless code elimination #623

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
There are several contexts in which Umple generates code that is of no use.

The simplest example is a plain attribute

class X {
  a;
}

That generates

public boolean setA(String aA)
{
  boolean wasSet = false;
  a = aA;
  wasSet = true;
  return wasSet;
}

Where the first and third line are not needed, and the 'return wasSet;' can be 
'return true'.

This change has to be done super-carefully, however, since the wasSet variable 
might be needed if there are before and after code injections, so it should 
only be removed once we are absolutely certain it is not needed.

The main benefit of making this change is so that educational users of Umple 
see ideal code, and not code that is a bit awkward. This would also slightly 
improve efficiency.

Original issue reported on code.google.com by TimothyCLethbridge on 5 Sep 2014 at 2:30