Re: Refactoring into ravioli code



On 15 Jan, 13:22, "Daniel T." <danie...@xxxxxxxxxxxxx> wrote:

What language is that? C#?
Java. Must admit I hate all the new generics stuff...

SmallTalk (Squeak):
matchNamesThatStartWith: matchMe

   ^self allStrings select: [:each| each startsWith: matchMe].
Well of course

But you have created the code __here__, in the top level
matchNamesThatStartWith method. You have not created more classes (and
hence ravioli - my original point) to solve this issue. You've just
used the fact Smalltalk provides this kind of language construct to
help you.

The C++ example I didn't understand I'm afraid (having only played
with the language 15 years ago) No disrespect intended but were you
suggesting that

remove_copy_if( allStrings.begin(), allStrings.end(), matches,
!bind( &String::endsWith, _1, matchMe ) );

was self documenting?

.You end up with the ability to select members of a container with one line..
I'm sure you'd agree the ability to put the all the code on one line
does not necessarily make for a readable line of code.

It's all about writing code that can be __read__ (assuming familarity
with the syntax) not which has to be __translated__. Your c++ must be
translated to be understood. The Smalltalk example was fine obviously.

Thanks for the comments.

Chris
.