Skip to Content Java Solaris Communities Partners My Sun Sun Store United States Worldwide

»  Spotlight Articles
»  Projects
»  Publications
»  People
»  Awards
»  Events
»  Downloads
»  Internships
»  Contrarian Minds
»  About Sun Labs

Dynamic inheritance

  • Assigning to a parent slot changes the inherited behavior of an object.

  • Usually used to switch between states where behavior is significantly different.

  • Use with caution!

Dynamic inheritance

Because parent slots are potentially assignable, we have a new concept in Self not present in class-based languages such as Smalltalk, C++ and Eiffel: dynamic inheritance.

Using dynamic inheritance, an object can change one or more of its parents during execution.

Typically, this is used when an object can be in one of a small number of discrete states, each having significantly different behavior from the others. An example is the object unix, which represents the Unix system call interface. It has a dynamic parent, currentOsVariant, which can be set to an object containing behavior specific to a particular variant of Unix; this is done every time the system is started.

Dynamic inheritance should be used with caution: it is easy to construct programs which are very hard to understand!

[ Previous ] [ Index ] [ Next ]
Would you recommend this Sun site to a friend or colleague?
Contact About Sun News Employment Privacy Terms of Use Trademarks Copyright 1994-2008 Sun Microsystems, Inc.