News for hackers. Stuff that matters.
Re:How to name things in programming by ajuc on Monday May 25, 2015 @04:56AM (#9599185)
I am suspicious of names containing "and".

I agree about clarity over everything else, but then why even make a function if all it does is calling 2 functions in sequence, and you can't name it on higher level of abstraction?

In this case wouldn't

    [x+1 for x in input_list.reversed()]
be even clearer?

True, functions allow you to change code in one place and affect many places (so they prevent "forgot to update one place" errors), but when function is named from its implementation instead of its purpose - it doesn't make much sense to change implementation anyway. The absolute worst thing is

    def reverseListAndAddOneToEachElement(input_list):
        #requirements changed
        return [x+2 for x in input_list.reversed()]
So either I repeat myself by copy-pasting code, or I repeat myself by saying the same thing in implementation and in the name. It's the hardest problem in naming for me.
Re:How to name things in programming by jacquesm on Monday May 25, 2015 @06:48AM (#9599461)
Function composition is by far the better solution, it is future proof and requires less memorization.
Re:How to name things in programming by eru on Monday May 25, 2015 @10:49AM (#9600231)
It's syntax is just somewhat ugly in Python. (Compared to, say, Haskell.)
Re:How to name things in programming by Kiro on Monday May 25, 2015 @05:59AM (#9599330)
> but then why even make a function if all it does is calling 2 functions in sequence

How else would you execute the functions? What initiates them?

Re:How to name things in programming by ajuc on Monday May 25, 2015 @07:00AM (#9599491)
The "and you can't name it on higher level of abstraction" part is important.