0

I'm developing a java application that has 20 plugins, each plugin's have some similar GUI menu item's and menu event's but they store data in different table's in a database. Currently I'm creating separate GUI, event and model classes for each plugin by copying and pasting in diffrent class files.

Is it wise to develop separate GUI, event and model classes for each plugin's and duplicate similar methods to other plugin's?

I need your advice on how to create a generic GUI, event and model interface for all the plugin's without making my application uneasy to maintain.

Thank you.

Arne Deutsch
14.8k5 gold badges56 silver badges72 bronze badges
asked Mar 22, 2011 at 20:47
1
  • I think to get a meaningfull answer you have to provide some more detail. An (simplified) example plugin with highlighting of the code that duplicates in each (or many) plugins might help. Commented Mar 22, 2011 at 20:51

1 Answer 1

1

We have a plug-in system in our product, and ran into the same issue. Many of the plug-ins share a lot of code. We ultimately decided on the following:

  1. Define clean Interfaces (PluginABC implements MyProductInterface). These interfaces don't require a specific implementation but...
  2. We provided a AbstractPlugin that Plugins can extend. This AbstractPlugin provides a ton of standard functionality that is useful for most plug-ins.

Example:

public interface MyProductInterface {
 public void doIt();
}
public class MyPlugin implements MyProductInterface extends AbtractPlugin {
 public doIt() {
 // ...
 usefulMethodForMostPlugins();
 /// ...
 }
}
public abstract class AbstractPlugin {
 public usefulMethodForMostPlugins() ...
}
answered Mar 22, 2011 at 21:03
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.