[[PageOutline(1-2)]] = Relationships for Squeak = A framework that implements relationships as first class members of the language and extends the browser to support them. You define relationships between classes and the framework automagically creates responding methods for you to use. This is not only faster than implementing these methods yourself, it's also a lot easier to read and edit. Additionally, the generated methods maintain the relationship in a consistent state to prevent common bugs. The browser extension helps in creating new relationships by providing good templates. Usually, you only select the first class, the relationship-type and write the name of the other class. Compare this to Ruby On Rails where you have to open the first class, type the relationship-type and write the name of the other class - and then do the same thing again in the other class (for bidirectional relationships)! The framework was inspired by relational databases and ORM mappers. = How to Install = {{{ #!div class="wiki_infotable" style="float:right;" ||'''Environment'''|| || || [[Image(media/icons/custom:squeak_16.png, title="Recommended Squeak Version", nolink, right)]] || 4.2 || || [[Image(media/icons/silk:application_home.png, title="Recommended Squeak VM Version", nolink, right)]] || 4.1 || || [[Image(media/icons/silk:cog.png, title="Recommended Cog VM Version", nolink, right)]] || ''supported?'' || ||'''Sources'''|| || || [[Image(media/icons/silk:script_gear.png, title="Metacello Configuration", nolink, right)]] || [http://www.hpi.uni-potsdam.de/hirschfeld/squeaksource/MetacelloRepository/ ConfigurationOfRelationships] || || [[Image(media/icons/silk:database.png, title="Repository", nolink, right)]] || [http://www.hpi.uni-potsdam.de/hirschfeld/squeaksource/meta10relationships Relationships] || || [[Image(media/icons/silk:package.png, title="Needed Packages from the Repository", nolink, right)]] || ''Relationships'' || ||'''Misc'''|| || || [[Image(media/icons/silk:world.png, title="Website", nolink, right)]] || [http://www.hpi.uni-potsdam.de/hirschfeld/squeaksource/meta10relationships.html Relationships@SqueakSource] || }}} When checking out from Monticello, an additional instance variable is added to Class, causing a lenghty recompile. You probably want to do this on a new image. To open the browser that supports relationships, you need to do: ''!RelationshipBrowser open'' {{{ #!div style="clear:both;" }}} = How to Use = When editing relationships, use the relationship browser: ''!RelationshipBrowser open'' I'll use a simple example to illustrate the use of this framework: We have a class ''Artist'' and a class ''Artwork''. Artists can create many artworks, but an artwork can only have a single artist. We therefore have a one to many relationship between artist and artwork. === Create a relationship === In the relationship browser, select the ''Artist'' class and click on the relationship symbol: --> [[Image(auswahl.png)]] In the category menu, select ''!OneToMany''. As you can see, there is a template for a ''!OneToManyRelationship'' in the edit pane. Simply add the ''Artwork'' class as the right class and save. The new relationship has been created. If you go back to the instance view, you can see that ''Artist'' does now have the methods ''addArtwork:'', ''artworks'' and ''removeArtwork''. ''Artwork'' has the method ''artist''. === Edit a relationship === Assume we have found out that sometimes, multiple artists collaborate to create an artwork. Go back to the relationship view (use -->) and select the existing relationship. The edit pane is filled with the previous values. To create a many to many relationship, replace ''!OneToManyRelationship'' with ''!ManyToManyRelationship''. Hit save and look at the newly generated methods. Assume all artworks in this relationships are paintings. We don't want to create a new subclass for this, but change the name used in the methods. Select the existing relationship and add a name for the right class: ''rightClassName: 'painting' '' and save. The methods will be renamed. [[Image(nachaenderung.png)]] = Known limitations = The relationships are not added to monticello when saved (however, the generated methods and instance variables are - your code still works). Generated methods are editable. Don't do it! Generated instance variables are editable and accessible. Don't do it, use the accessors instead! = How to Extend = ''!RelationshipDescription'' is an abstract class which encapsulates a lot of the shared logic. The inheriting classes implement the generation / removal of the instance variables and methods needed for its specific type. ''!RelationshipBrowser'' implements the changes for relationships on top of the standard browser from Squeak. It mostly overrides existing methods and uses the relationships like one would from the workspace. = Acknowledgments = [[Image(media/icons/silk:user.png, nolink)]] To date the following contributors: * Christoph Neijenhuis