JaroslavTulach: /* Ghost Alternatives */ - 2010-11-08 08:19:13

Ghost Alternatives

←Older revision Revision as of 08:19, 8 November 2010
Line 88: Line 88:
With a little bit of help from some
With a little bit of help from some
[[NetBeans_Runtime_Container|Modular Runtime Container]] one can
[[NetBeans_Runtime_Container|Modular Runtime Container]] one can
-
even load two versions of some class with two different classloaders.
+
even load two versions of some class with two different [[ClassLoader]]s.
The decision to load the old or new class is done during linkage time,
The decision to load the old or new class is done during linkage time,
based on dependencies.
based on dependencies.

192.9.112.196 at 12:38, 16 July 2010 - 2010-07-16 12:38:17

←Older revision Revision as of 12:38, 16 July 2010
Line 1: Line 1:
As has been explained in [[ClarityOfAccessModifiers]] page, sometimes
As has been explained in [[ClarityOfAccessModifiers]] page, sometimes
even relatively fine looking [[API]] can have a hidden catch. Just
even relatively fine looking [[API]] can have a hidden catch. Just
-
like following '''Arithmetic''' class:
+
like following '''Arithmetica''' class:
<source lang="java" snippet="design.composition.arith1.0"/>
<source lang="java" snippet="design.composition.arith1.0"/>

88.80.164.230 at 16:15, 15 July 2010 - 2010-07-15 16:15:23

←Older revision Revision as of 16:15, 15 July 2010
Line 1: Line 1:
As has been explained in [[ClarityOfAccessModifiers]] page, sometimes
As has been explained in [[ClarityOfAccessModifiers]] page, sometimes
even relatively fine looking [[API]] can have a hidden catch. Just
even relatively fine looking [[API]] can have a hidden catch. Just
-
like following '''Arithmetica''' class:
+
like following '''Arithmetic''' class:
<source lang="java" snippet="design.composition.arith1.0"/>
<source lang="java" snippet="design.composition.arith1.0"/>
Line 17: Line 17:
Is all our [[API]]
Is all our [[API]]
development in stuck? Do we need to keep the old, slow 1.0 version of '''sumRange'''
development in stuck? Do we need to keep the old, slow 1.0 version of '''sumRange'''
-
method? Do we have to sacrify [[BackwardCompatibility]]? No and no. We just need
+
method? Do we have to sacrifice [[BackwardCompatibility]]? No and no. We just need
to learn how to provide [[AlternativeBehaviour]]s.
to learn how to provide [[AlternativeBehaviour]]s.

JaroslavTulach: AlternativeBehaviour moved to AlternativeBehavior: Typo in name - 2010-01-25 04:04:07

AlternativeBehaviour moved to AlternativeBehavior: Typo in name

←Older revision Revision as of 04:04, 25 January 2010

JaroslavTulach at 08:54, 23 March 2009 - 2009-03-23 08:54:50

←Older revision Revision as of 08:54, 23 March 2009
Line 132: Line 132:
by [[C]] linker. More about that in [[How to Write Shared Libraries]].
by [[C]] linker. More about that in [[How to Write Shared Libraries]].
-
 
+
[[Category:APIDesignPatterns]]
-
<comments/>
+
[[Category:APIDesignPatterns:Evolution]]

JaroslavTulach: /* Runtime-time Alternatives */ - 2009-02-17 20:23:28

Runtime-time Alternatives

←Older revision Revision as of 20:23, 17 February 2009
Line 118: Line 118:
<source lang="java" snippet="design.composition.arith.runtime"/>
<source lang="java" snippet="design.composition.arith.runtime"/>
-
By doing this inspection the code the requires '''Arithmetica''' behaviour in
+
By doing this inspection the '''Arithmetica''' class can find out what actual version and thus behaviour the code calling into the [[API]] really requires. If the dependency is on anything older than version 2.0 the code will see the old behaviour. Callers compiled against the newer, improved
-
version older than 2.0 will get it, while those aware of the new, improved
+
'''sumRange''' implementation will benefit from the performance boost. Moreover
'''sumRange''' implementation will benefit from the performance boost. Moreover
there is just one version of the '''Arithmetica''' class in the whole system,
there is just one version of the '''Arithmetica''' class in the whole system,
so there are no problems with multiple ''ghost'' types.
so there are no problems with multiple ''ghost'' types.
 +
 +
:''The above example assumes that there is 1:1 mapping between a module''
 +
:''and a classloader and as such it is easy to iterate the stack and find''
 +
:''the dependency information from it. This is the simplest case, good for''
 +
:''demonstration purposes. Everything else would just complicate the principle.''
This style of providing [[AlternativeBehaviour]]s is not really common in [[Java]]
This style of providing [[AlternativeBehaviour]]s is not really common in [[Java]]

JaroslavTulach at 16:47, 16 February 2009 - 2009-02-16 16:47:58

←Older revision Revision as of 16:47, 16 February 2009
Line 127: Line 127:
these days, but it is worth to mention that this is exactly the system used
these days, but it is worth to mention that this is exactly the system used
by [[C]] linker. More about that in [[How to Write Shared Libraries]].
by [[C]] linker. More about that in [[How to Write Shared Libraries]].
 +
 +
 +
<comments/>

JaroslavTulach: /* Runtime-time Alternatives */ - 2009-02-16 16:36:45

Runtime-time Alternatives

←Older revision Revision as of 16:36, 16 February 2009
Line 113: Line 113:
moreover it solves the problem of mutual incompatible types is based on runtime
moreover it solves the problem of mutual incompatible types is based on runtime
inspection. The basic presumption is that the code carries runtime information
inspection. The basic presumption is that the code carries runtime information
-
about its necessary dependencies which can be queried during runtime. Then one
+
about its necessary [[dependencies]] which can be queried during runtime. Then one
can rewrite the '''Arithmetica''' class in following way:
can rewrite the '''Arithmetica''' class in following way:

JaroslavTulach: /* Runtime-time Alternatives */ - 2009-02-16 16:35:46

Runtime-time Alternatives

←Older revision Revision as of 16:35, 16 February 2009
Line 110: Line 110:
=== Runtime-time Alternatives ===
=== Runtime-time Alternatives ===
-
Solution that offers as simple upgrade path as the ''ghost alternatives'' and
+
Solution that offers as simple [[upgradability|upgrade path]] as the ''ghost alternatives'' and
moreover it solves the problem of mutual incompatible types is based on runtime
moreover it solves the problem of mutual incompatible types is based on runtime
inspection. The basic presumption is that the code carries runtime information
inspection. The basic presumption is that the code carries runtime information

JaroslavTulach: /* Side by Side Alternatives */ - 2009-02-16 16:30:08

Side by Side Alternatives

←Older revision Revision as of 16:30, 16 February 2009
Line 82: Line 82:
old and new version. Sometimes this is easy (like exchanging numbers between
old and new version. Sometimes this is easy (like exchanging numbers between
'''Math''' and '''StrictMath'''), however often it is not easy at all and
'''Math''' and '''StrictMath'''), however often it is not easy at all and
-
one needs to either give up on the task on invest in writing bridge.
+
one needs to either give up on the task on invest in writing a [[bridge]].
=== Ghost Alternatives ===
=== Ghost Alternatives ===