Thinking in Patterns with Java V0.9: chapter 3: Simplifying Idioms: TIPatterns.htm#_Toc41169691
1, Sections name of today's learning;
Messenger. 22
Collecting Parameter. 24
2, What is it talk about in these sections and my comments and feeling for the content:
Bruce's book always give me good reading experiment.
He puts the Messenger and Collecting parameter at Simplifying Idioms
chapter, I think the reason is that these two patterns can be used in the basis implementation of a process which performing a specific task.
1), Messenger.
If we need translate many related parameters into a method, we can package
these parameters into an object, then we can translate this object into that method instead.
I think I can use this Messenger pattern in our LearnDiary Open Source
Project like this: Because we use Struts framework, it need tranlate some
attributes from a Struts Action into a Jsp page, my method before is set these
attributes into request scope seperately, then get these attributes in Jsp
page seperately; Now, if some of these attributes is related, we can package some of these attributes into an attribute object, then translate this packaged attribute object into Jsp page. But, I think this need balance, we can't package all the attributes into only an attribute object without any proper reason.
2), Collecting Parameter.
Frankly speaking, I have never used Collecting Parameter patterns before, I
haven't ever thought that a parameter can be used like this: pass a parameter
into a method, let this method do some change on this parameter, then pass
this changed parameter into another method, and let this another method do
some change on this changed parameter again, and so on. That's really an
intresting use of a parameter. Just like flow line production:). But,
remember, the parameter is always only one same object, only the content of
this object changed.
Let me think a while, how can I use this pattern into our LearnDiary
project? aha, a little example coming, in our project, there is an Email
object, it consists of email address and title, content, and so on. Email
address can be gotten from user object, and email's title and content can be
gotten from an article object. So, create method at user and article object
for adding some field into email object. Then, translate email object into
user and article object's corresponding method to do some change in turn.
3, My questions about the english language;
1), Strange words:
trivial, pass around, magnitude, dummy, pollen, accumulating
I have made a mistake. There aren't Messenger and Collecting Parameter patterns in GoF's 23 Design Patterns.
The author puts these two items here only for: "Before getting into more complex techniques, it?s helpful to look at some basic ways to keep code simple and straightforward.".