Re: Refactoring into ravioli code
- From: chris_a_brooks@xxxxxxxxxxxxx
- Date: Tue, 15 Jan 2008 05:54:37 -0800 (PST)
On 15 Jan, 13:22, "Daniel T." <danie...@xxxxxxxxxxxxx> wrote:
Java. Must admit I hate all the new generics stuff...
What language is that? C#?
SmallTalk (Squeak):Well of course
matchNamesThatStartWith: matchMe
^self allStrings select: [:each| each startsWith: matchMe].
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
!bind( &String::endsWith, _1, matchMe ) );remove_copy_if( allStrings.begin(), allStrings.end(), matches,
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
.
- Follow-Ups:
- Re: Refactoring into ravioli code
- From: Daniel T.
- Re: Refactoring into ravioli code
- From: Daniel T.
- Re: Refactoring into ravioli code
- References:
- Refactoring into ravioli code
- From: chris_a_brooks
- Re: Refactoring into ravioli code
- From: Daniel T.
- Refactoring into ravioli code
- Prev by Date: Re: Asserts for Embedded Systems
- Next by Date: Re: Business objects, subset of collection
- Previous by thread: Re: Refactoring into ravioli code
- Next by thread: Re: Refactoring into ravioli code
- Index(es):