Re: How to separate interface from implementation when using JARs?
- From: Patrick May <pjm@xxxxxxx>
- Date: Mon, 17 Sep 2007 13:24:22 -0400
Marc <MJT.Keijsers@xxxxxxxxx> writes:
In an engineering world where I used to be working with C++ I am
now shiftnig to Java. In C++ I would publishe my interfaces in
header files. In Java I can use the interface concept. However
this is not sufficient for me. I want to be able to full separate
the implementation from the interface of e.g. a class method.
Example:
public interface MyMath {
int MyAdd(int a, int n);
}
class Calculate implements MyMath {
int MyAdd(int a, int n) {
return a - b;
}
I would use this class as an import in my client code:
#import Calculate
class client {
void DoIt() {
Calculate c = new Calculate();
int sum = c.MyAdd(9,7);
}
Once I discover the implementation error in the Calculate and want
to fix that I do not want to change the client code to require
recompilation/distribution. In C++ I would not have to change the
header file,only a cpp file. I would compile and link the math
library to a dll and redistribute only that DLL. In basic JAVA, when
I recompile my client code will recompile leading to a new
(changed?) client JAR which I should also redistibute. This is
undesired for me.
If I understand your issue correctly, you can achieve something
similar by creating separate jar files for interfaces and
implementations. With that approach, you could release only the
implementation jar when fixing a bug.
If you have a distributed system, you could dynamically download
updates by distributing jars only to class servers. One Java
technology that supports this is Jini (http://www.jini.org).
Regards,
Patrick
------------------------------------------------------------------------
S P Engineering, Inc. | Large scale, mission-critical, distributed OO
| systems design and implementation.
pjm@xxxxxxx | (C++, Java, Common Lisp, Jini, middleware, SOA)
.
- References:
- How to separate interface from implementation when using JARs?
- From: MJT . Keijsers
- Re: How to separate interface from implementation when using JARs?
- From: Marc
- How to separate interface from implementation when using JARs?
- Prev by Date: Re: struts ebooks
- Next by Date: Re: Design choices and patterns for passing contextual runtime information.
- Previous by thread: Re: How to separate interface from implementation when using JARs?
- Next by thread: Re: How to separate interface from implementation when using JARs?
- Index(es):
Relevant Pages
|