fREWdiculous!
1 Sep
Sadly reading is going slower than expected due to being so busy with various things in life. Oh well, just a single pattern today.
How do you represent instantiation?
In addition to a vanilla constructor, add methods for common cases to instantiate typical objects. For strange cases allow the use of accessors.
Using Perl (with Moose) an example might be:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
So now both of the following work:
1 2 | my $p = Point->new(5, 6); my $v = Point->r_theta(10, 1.4); |
One Response for "Smalltalk Best Practice Patterns: Constructor Method"
[...] 2011-09-01 by fREW Schmidt Related Posts:Smalltalk Best Practice Patterns, Chapters 1 and 2Smalltalk Best Practice Patterns – Chapter 3Git aliases for your lifeStop accidentally committing all with gitUsing DBI Effectively: bind_columns() [...]
Leave a reply