[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: Adding own methods to existing classes
|
I guess that templates (similar to C++ templates) that Sun is going to
introduce in 1.5 JDK as a generic types (
http://jcp.org/en/jsr/detail?id=014), can provide you this service.
"Runar Jordahl" <runarzjordahl@xxxxxxxxxxx> wrote in message
news:avgo8d$8d6$1@xxxxxxxxxxxxxxxx
> Being new to Java I do not really know whether my questions is more about
> Java than about Eclipse... In IBM VisualAge for Smalltalk (also developed
by
> OTI) classes can be "extended". Please note that in this tool, extending a
> class does not mean inheriting from it, but adding a set of methods to the
> actual class. In VisualAge Smalltalk, an "extension" is controlled as a
> separate unit by the source control system and it can be loaded, unloaded,
> and versioned independently of the class extended. Prerequisites for the
> extension are also controlled separately from the actual class definition.
>
> Using VisualAge Smalltalk extensions is very useful. Let's say you want to
> add support for flashing (to alert the user) to a set of widget classes.
> Performing the flash action might need different behaviour for each widget
> type. Using extensions, you add the method "flash" in extensions for all
the
> widget classes. A container widget might do nothing, except invoke "flash"
> on all its children, while more basic type of widgets will change their
> colour. (For a more complete solution, more than one method might need to
be
> added.)
>
> Using VisualAge Smalltalk extensions is an alternative that in many cases
> can be used instead of these techniques:
>
> - Inherit from the class and add the desired behaviour in subclass.
> Problems: A small change does not always justify creation of a new class.
> Users referring original class do not get new behaviour.
>
> - Create a new, modified version of the existing class.
> Problem: If a new version of the original class is published, changes
needs
> to be integrated once more.
>
> - Wrap instances of the class (Adaptor pattern)
> Problems: Need to wrap all behaviour. Users referring original class do
not
> get new behaviour.
>
> - External control. Don't bother changing the class, but add behaviour
> somewhere else.
> Problem: Breaks good OO practice by not storing behaviour where if belongs
> (at the class it operates on).
>
>
> Does Java or Eclipse support making VisualAge Smalltalk-type extensions?
Can
> I add own methods to existing classes, without modifying the actual class?
>
> Runar Jordahl
>
>
>
> runarzjordahl@xxxxxxxxxxx (Remove the "z")
>
>