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

Prototypes

  • Conventional OO languages make objects by instantiating from classes. Cons:

    • Need to make new class to make a new kind of object
    • To change an object's behavior or structure, need to change the class.
    • Browse classes, not objects.

  • In SELF, new objects are made by copying existing ones. Safe to change a copy.

Prototypes

Self is a prototype-based language. What does this mean?

Conventional object-oriented languages use classes to define the structure and behavior of objects. When a new object is required, a class must be instantiated . Modifying an object's structure or behavior means the class has to be modified.

There are disadvantages to this approach:

  • Before making a new kind of object, we need to make a new class. Whenever we want to change the object's structure or behavior, we have to change the class. Some systems do not even permit existing objects to have their class changed; the object has to be reconstructed after the class has changed. When we change the class, we have to be sure that there are no other instances which require the old behavior; otherwise we need to make a new subclass. This slows down development and hinders experimentation.

  • When we want to make a new kind of object, we don't usually look for an existing object that is similar to what we want, but we look for a class that defines objects similar to our intent. Then we have to imagine an instance, or, if we are lucky, we can instantiate the class and examine the object. But it's still somewhat indirect.

    The Self language doesn't have any classes. When we want a new object, we find an existing one and copy it. We can then change the copy, safe in the knowledge that we have not affected anything else.

[ 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.