Sun and Oracle Community Voices How to Buy Log In United States [Change] English

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

Mixing state and behavior

  • Data and method slots can be freely mixed.

  • Can use the freedom to experiment in safety: make a copy of an object, put a copy of a method in it, experiment with the method, the move it back to the traits when done.

Benefits of mixed state and behavior

In Self, we can put method and data slots in whichever object we choose - it is up to us to exercise good taste and careful design to get the effect we want.

We can also use this flexibility to explore new designs in a safe way. For example, suppose we want to try a new deposit: method, but we are unsure of ourselves and don't want to break any existing bank accounts until we are certain that our new method works.

We can make a new bank account by copying an existing one, and put a local copy of deposit: inside it. We can then experiment with deposit: sure in the knowledge that no other object will be affected. When we are convinced our new method is working, we can move it back to the traits, so all accounts use it.

[ Previous ] [ Index ] [ Next ]