Reputation: 713
What is the proper way to make java reusable components that is capable of used in various applications. I mean for example I'm doing a application that has its own user interface and database and etc. If I want to make this app reusable for many other applications as a component of other applications. For example one feature of my first app may needed by other app. So how to make it possible for other apps to use this feature of my app without changing my original code. What are the proper ways to achieve this re usability.
Upvotes: 0
Views: 469
Reputation: 182
This is a rather broad question. As such, I am offering broad suggestions:
Hope that helps.
Upvotes: 1
Reputation: 1737
Sun Microsystems, the creators of the Java language, have at last recognized this need, and have released the Java Beans Component Architecture. Java Beans are, quite simply, reusable controls written in Java, for Java application development.
Beans are "capsules" of code, each designed for a specific purpose. The advantage of Java Beans over standard programming controls is that Beans are independent. They are not specific to operating systems or development environments. A Bean created in one development environment can be easily copied and modified by another. This allows Java Beans greater flexibility in enterprise computing, as components are easily shared between developers.
Upvotes: 0
Reputation: 2100
You need code in such a way that your components are loosely coupled. Then the re-usability is very much high. Take a look at this and this.
Upvotes: 0
Reputation: 533530
Write something simple which does what it does very well. Document it and unit test it and make it open source.
Upvotes: 3
Reputation: 597114
Have the the reusable components in another project (e.g. "common") and package them as .jar. Then include that jar in the projects where it's needed.
Extracting a separate project might be tricky though. You should observer the following:
You have a couple of options for the mechanics of packaging:
Upvotes: 2