Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43465

Re: Functional vs. Object oriented API

References <mailman.429.1365635789.3114.python-list@python.org> <51678b94$0$29977$c3e8da3$5496439d@news.astraweb.com> <roy-E3B2B9.10194712042013@news.panix.com>
Subject Re: Functional vs. Object oriented API
From David M Chess <chess@us.ibm.com>
Date 2013-04-12 11:37 -0400
Newsgroups comp.lang.python
Message-ID <mailman.527.1365781666.3114.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

> Roy Smith <roy@panix.com> 

> As part of our initial interview screen, we give applicants some small 
> coding problems to do.  One of the things we see a lot is what you could 

> call "Java code smell".  This is our clue that the person is really a 
> Java hacker at heart who just dabbles in Python but isn't really fluent. 
 
> ...
> It's not just LongVerboseFunctionNamesInCamelCase().  Nor is it code 
> that looks like somebody bought the Gang of Four patterns book and is 
> trying to get their money's worth out of the investment.  The real dead 
> giveaway is when they write classes which contain a single static method 

> and nothing else.

I may have some lingering Java smell myself, although I've been working 
mostly in Python lately, but my reaction here is that's really I don't 
know "BASIC smell" or something; a class that contains a single static 
method and nothing else isn't wonderful Java design style either.

> That being said, I've noticed in my own coding, it's far more often that 

> I start out writing some functions and later regret not having initially 

> made it a class, than the other way around.  That's as true in my C++ 
> code as it is in my Python.

Definitely.

> Once you start having state (i.e. data) and behavior (i.e. functions) in 

> the same thought, then you need a class.  If you find yourself passing 
> the same bunch of variables around to multiple functions, that's a hint 
> that maybe there's a class struggling to be written.

And I think equally to the point, even if you have only data, or only 
functions, right now, if the thing in question has that thing-like feel to 
it :) you will probably find yourself with both before you're done, so you 
might as well make it a class now...

DC

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Functional vs. Object oriented API Max Bucknell <mpwb500@york.ac.uk> - 2013-04-11 00:16 +0100
  Re: Functional vs. Object oriented API Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-12 04:20 +0000
    Re: Functional vs. Object oriented API Roy Smith <roy@panix.com> - 2013-04-12 10:19 -0400
      Re: Functional vs. Object oriented API Mitya Sirenef <msirenef@lightbird.net> - 2013-04-12 10:29 -0400
      Re: Functional vs. Object oriented API David M Chess <chess@us.ibm.com> - 2013-04-12 11:37 -0400
        Re: Functional vs. Object oriented API 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-12 22:25 -0700
        Re: Functional vs. Object oriented API 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-12 22:25 -0700
  Re: Functional vs. Object oriented API Rui Maciel <rui.maciel@gmail.com> - 2013-04-13 09:51 +0100

csiph-web