[Chicago] Factoring fun with functions in Python
g at rre.tt
Fri Nov 16 16:25:10 CET 2012
On Thu, Nov 15, 2012 at 9:00 PM, Martin Maney <maney at two14.net> wrote:
> On Thu, Nov 15, 2012 at 07:41:57AM -0800, Dan Krol wrote:
>> Sure, I'm not against writing one or two line functions or one or two
>> function modules when it represents appropriate coupling. I was just
>> focusing on the fact that *every* function in the example was like
>> this, and perhaps I took that aspect of the example to be a key point
>> when I shouldn't have.
> Yeah, sorry, it was early and I was short on time before I had to get
> going. I was really more agreeing with your remarks, but replying to a
> bunch of other replies that, if I understood them, seemed to be
> unreservedly approving of this IMO poor example of program refinement.
> I too have had a very hard time seeing it as anything more than
> pointless text shuffling. Replace db.cursor() by get_cursor(db)?
> That's just playing with the text; perhaps it was a mistake to give up
> punch cards after all. :-/ If the former is so obviously correct when
> it's inside the latter, what makes it less obvious inlined, without the
> cargo-cult trappings?
FP cargo cult? I wish.
Let's be clear, the whole point of the exercise is to play with text.
Whether it's pointless shuffling depends on what you're trying to
The premise is that *functions* are used to represent logic.
"db.cursor()" is a method invocation on an object, not a function. If
you concede that "getting a cursor" is an important logical operation
in the program, according to the rules of the text-playing-game, it
must be represented by a function.
If you want to be proper annoyed, read the big brother to the OP :)
More information about the Chicago