Do you know well-tested and open source Composite examples in Smalltalk?
I would like to review example implementations of the Composite pattern in Smalltalk. Any dialect is fine, I am interested particularly in source code including unit test cases. This post describes what I am looking for, common testing snippets which can be re-used in my applications.
An well-designed implementation is useful too because I want to learn how composite tests are structured.
The Design patterns are defined as the best practices that a programmer must follow to amplify code reusability in a framework. The design pattern explains how to plan the test automation test ware to be useful and easy to maintain.
Composite pattern is used where we need to treat a group of objects in similar way as a single object. Composite pattern composes objects in term of a tree structure to represent part as well as whole hierarchy.
Composite pattern is a partitioning design pattern and describes a group of objects that is treated the same way as a single instance of the same type of object. The intent of a composite is to “compose” objects into tree structures to represent part-whole hierarchies.
The Composite Design Pattern is meant to "compose objects into a tree structure to represent part-whole hierarchies. Composite Pattern lets clients treat individual objects and compositions of objects uniformly".
The composite pattern is extremely common in Smalltalk, I suspect almost any reasonably sized application has one or more uses of this design pattern. Some of the packages I know that contain a lot of tests include:
Refactoring engine: The refactoring engine contains dozens of composites, most prominent the model of the AST. It comes with a good collection of tests and is available in almost all Smalltalk dialects.
Seaside: This web application framework models request handlers, widgets, html tags, configurations, ... as composite objects. Again, it comes with a good collection of tests and is available on many Smalltalk platforms.
Pier: This content management system has various composites to model nested pages and their content. There are hundreds of tests that validate the construction, destruction and behaviour of these composite structures. The tests are structured across the hierarchy of the classes and many tests are reused on different kind of nodes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With