- This topic has 3 replies, 2 voices, and was last updated 16 years, 4 months ago by Loyal Water.
-
AuthorPosts
-
Jukka PalomäkiMemberHello.
Would it prove too difficult to add an alternate style of code generation besides the current extension model to M4M? The current model is based on extension, which isn’t IMO really extension, but composition, as shown below.
public class MyComponent extends JPanel { private JComponent jComponent1; private JComponent jComponent2; public MyComponent() { initComponents(); } private void initComponents() { // Initialize the layout/components and add to this } }
An alternative to this could be the ‘builder’ or ‘wrapper’ (or whatever =) pattern as shown below.
public class MyComponent { private JPanel jPanel; private JComponent jComponent1; private JComponent jComponent2; public MyComponent() { initComponents(); } private void initComponents() { // Initialize the panel and other components, add layout and components to panel } public JPanel getInstance() { return jPanel; } // ... }
This would have the added benefit of not only omitting the inheritance misuse, but also add the possibility for the wrapper class to extend another class if need be as well as providing an extra level of abstraction on top of the actual component. This would allow for example us to place internationalization/reinitialization code outside of the component.
It is easy enough to transform currently generated code to this, but then consequent changes to the design invalidate it.
Just a thought.
Loyal WaterMemberI’ll make a note of this feature request and move this to the feature request forum. Thank you for your feedback.
Jukka PalomäkiMemberThanks for your reply Nipun.
Now what is your gut feeling, any chance this sort of feature would get incorporated into a future release in a reasonable time-frame?
BR,
Jukka
Loyal WaterMemberJukka,
Since we have this thread open on the feature request forum, the other users can vote in favor of this request. I feel the management will monitor the request, and incase the demand for this request shoots up, they might consider it a little sooner than otherwise. -
AuthorPosts