Abdelrazak Younes wrote:
Jean-Marc Lasgouttes wrote:
Abdelrazak Younes <[EMAIL PROTECTED]> writes:
That's not my goal, it will just be a nice side effect. You don't get
the big picture I think. It's not just about this single method but
about implementing things where they belong. When searching for a
string it is more natural to ask the object that knows about _its_
content (in this case the Paragraph class) than to retrieve each and
every character of the object (thus reconstructing the contents) and
then search for it.
This is OK when the method has potentially more than one user and
looks like something that is not built for the benefit of one caller.
The moment it touches private contents it should become a member.
For example, while find() _might_ be generically useful, changeCase is
definitely not in this situation. And please do not tell me that we
have a performance problem with it.
In this case, this is more about encapsulation, not speed. 'Text' should
have no business in modifying the characters. 'Paragraph' owns the
content so it should be the one that modifies it. Besides, the code is
stupid:
Forgot to add that it is stupid _now_ and thus can be simplified. But it
could not be easily simplified when being external to Paragraph.
Abdel.