The JADE 2022 release meets tomorrow’s business demands.
Could you please make it available to copy classes?
Case: Manual creation of a new class and copying of all methods is tedious with classes of many methods. This is useful when there are many, many methods.
A menu item under classes with a popup form to show the name of the class to be copied, the source class hierarchy location (selectable tree hierarchy control), the destination class hierarchy location (selectable tree hierarchy control), a textbox control prompting the user to enter in the new class name. The usual OK & Cancel buttons.
This form will popup when the user uses the copy drag and drop functionality. The source and destination information will auto populate with the drag drop information.
Note: this popup form can be used for class moving too (but with the new class name controls either hidden or disabled). Perhaps the name of the popup form should be called "Move / Copy Class".
The new class will be created from the source class with the exception of the class name will be that of the text entered in the popup form's "New Class Name" textbox control. All the methods will be copied and complied. There will be methods in error, but that is OK as the developer can go through each method in error and fix them up manually.
Primitive attributes can be safely copied.
Uni directional references can be safely copied.
Properties of type Object (& subclasses of) can be safely copied.
The only issue is bi directional references. These can be omitted during the copy process and the only limitation of this feature. The developer can then manually correct where required.
Hi Kevin, We have reviewed your JEDI and have not approved it as we believe that copying complete classes could result in bad coding practices. I will close this JEDI, but if you wish to submit another, more along the lines suggested by Kevin Saul we would review that. Thanks John R.
As a work-around, you can use a script to extract/modify/reload an existing class.
While there may be historical reasons in existing systems, repeatedly copying whole classes with many, many methods is probably a code smell (should be using inheritance or composition), so I don't think it'd be all that beneficial for the IDE to support copying whole classes directly.
What I'd prefer to see are IDE improvements that help with copying class features in a more selective manner. We can already drag methods to copy/move them from one class to another, but going further, it'd be good if we could:
Multi-select features to be copied/moved.
Copy/move properties to another class (including inverse relationships if compatible subject to a prompt).
Copy interface mappings to another class, including the associated method implementations & any properties they use (if they don't already exist).
This'd help with refactoring to break up monolithic classes, as well as support use cases where we need to create new functionality following an existing pattern. For scenarios where we do have to follow a common pattern, our utopia would be a framework for creating custom wizards that can generate a group of classes based on the inputs we provide (possibly something we could achieve via IDE extensions in future).