JADE Environment Development Ideas

What's new in the upcoming JADE release?

IMPROVED DEVELOPER EFFICIENCY. ENHANCED SECURITY. SMOOTHER INTEGRATION

The JADE 2022 release meets tomorrow’s business demands.


Start your update to JADE's latest release

Autocomplete: Restrict classes for method return type and typecasting of return statement

Consider the following class structure:

ABCModel
 |- ABCEntity
  |- ABCPerson


ABCModelTA
 |- ABCEntityTA
  |- ABCPersonTA


The ABCModelTA class has a reference myModelObject of type ABCModel.

We implement a method to get the model object as follows:

ABCModelTA::getCurrentObject() : ABCModel;
begin
 return self.myModelObject;
end;


On subclasses, we reimplement the getCurrentObject method to return a more specific type at each level:

ABCEntityTA::getCurrentObject() : ABCEntity;
begin
 return inheritMethod().ABCEntity;
end;


ABCPersonTA::getCurrentObject() : ABCPerson
begin
 return inheritMethod().ABCPerson;
end;


This is quite a common approach in a number of JADE systems I have worked on as a way of avoiding the need for continual typecasting down to more specific types in methods which consume the getCurrentObject method for an instance of one of the subclasses of ABCModelTA.


Currently, autocomplete for the return type on the method signature and also for the typecast after the inheritMethod(). lists all possible classes which match what has been typed.

My suggestion is to use the information about the return types on superclass implementations of methods to restrict the classes in the autocomplete suggestions for the return type of this subclass reimplementation of the method.

Likewise, for the typecasting of the return inheritMethod(). statement it would be good to note the return type for this method and also limit the resulting autocomplete class suggestions for the typecast.


Note

This JEDI assumes that the overhead to work this out won't unnecessarily slow down the autocomplete suggestion list. If there's no efficient way to achieve this more targeted autocomplete suggestion list, please feel free to close this JEDI.

Cheers,
BeeJay.

  • BeeJay
  • Oct 8 2021
  • Future consideration
  • Attach files