An attempt to make parts of any class in Squeak/Smalltalk usable just like a trait. This way, programmers don't have to decide upfront to either implement functionality with a class or a trait and may even just reuse parts of classes.
This project was started in the course Module Systems at HPI's Software Architecture Group.
- Setup a Squeak image
- CogVM
- Squeak 4.3
- CompiledMethod>>#hash
- SwaUtil from SWA Utilities
- AST-Core from [Refactoring Engine] (http://www.squeaksource.com/rb)
- Install FileTree, see dalehenrich/filetree
- Clone TraitClasses repository,
git clone [email protected]:lauritzthamsen/TraitClasses.git
- Load TraitClasses packages
- In your Squeak image, open a Monticello Browser and add a new FileTree repository. Point it to the packages-subdirectory of the cloned repository you just created. Load the latest versions into the Monticello browser.
Note: Alternatively, the project with its dependencies can be loaded through its Baseline, see tests/travisCI.st
.
Superclass subclass: #SubclassName
"TraitClasses: include other (parts of) other classes"
includes: { #OtherClass selectors: {#methodA . #MethodB} .
#AnotherClass
selectors: {#importantMethod}
protocols: {#enumeration}
variables: {#someVariable. #existingVariable useExisting. (#newVariable -> #usedVariable) useExisting}.
}
instanceVariableNames: 'existingVariable usedVariable'
classVariableNames: ''
poolDictionaries: ''
category: 'Some-Category'
Our repository also contains a TraitClasses-Browser package that provides an alternative system browser. While all browsers show class definitions with all their inclusions, this alternative browser provides buttons to hide and show included methods as well as inherited methods. After loading that package, you might want to register that browser as default system browser.