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


Groups > comp.lang.python > #101498

Re: When I need classes?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Travis Griggs <travisgriggs@gmail.com>
Newsgroups comp.lang.python
Subject Re: When I need classes?
Date Mon, 11 Jan 2016 15:45:35 -0800
Lines 32
Message-ID <mailman.27.1452555945.13488.python-list@python.org> (permalink)
References <c0bb7499-c359-4010-aac2-270d1b82a47d@googlegroups.com> <56927b37$0$1586$c3e8da3$5496439d@news.astraweb.com> <CAERt=-xWsUoy6bHdtE0W+VrLgGA3OE2=-GzwFfMWBxqi=s02bA@mail.gmail.com>
Mime-Version 1.0 (Mac OS X Mail 9.2 \(3112\))
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de qvwVnB8OAX6pmdzp77Jb0QaCUicSC88wkyUueMIrh63A==
Return-Path <travisgriggs@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'classes,': 0.05; 'think,': 0.05; '(of': 0.07; 'classes.': 0.07; 'behavior,': 0.09; 'script,': 0.09; 'jan': 0.11; '(object': 0.16; 'bind': 0.16; 'feasible': 0.16; 'messages)': 0.16; 'numbered': 0.16; 'obviously,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'why,': 0.16; 'wrote:': 0.16; 'figures': 0.18; 'mechanism': 0.18; 'odd': 0.18; 'subject:need': 0.18; 'algorithm': 0.20; 'first,': 0.20; 'do.': 0.22; 'class,': 0.22; 'oriented': 0.22; 'programming': 0.22; 'am,': 0.23; 'bit': 0.23; 'header:In-Reply-To:1': 0.24; 'this.': 0.28; 'figured': 0.29; 'purposes.': 0.29; 'thinks': 0.29; 'classes': 0.30; 'code': 0.30; 'class.': 0.30; 'another': 0.32; 'generally': 0.32; 'point': 0.33; 'problem': 0.33; 'message- id:@gmail.com': 0.34; 'add': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'ones': 0.35; 'could': 0.35; 'interact': 0.35; 'quite': 0.35; 'needed': 0.36; 'received:209.85': 0.36; 'data.': 0.36; 'flow': 0.36; 'to:addr :python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'turn': 0.37; 'done.': 0.37; 'received:209': 0.38; 'data': 0.39; 'enough': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'called': 0.40; 'some': 0.40; 'term': 0.60; 'your': 0.60; 'behavior': 0.61; 'header:Message-Id:1': 0.61; 'real': 0.62; 'making': 0.62; 'more': 0.63; 'believe': 0.66; 'letters': 0.67; 'skip:\xe2 10': 0.70; 'bernardo': 0.84; 'equation,': 0.84; 'listened': 0.84; 'subject:When': 0.84; 'to:name:python': 0.84; 'approaches,': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=6+A0iw+m6QlqNXBa/GxOq++fI66nYMjRYWTnTtseUP4=; b=YuQFncQynCyOlGsyv7fRq52i1EertMA+AI1ZWdxrGmWDYWE+dY8/D1TLwXiRVgRgVT D8AFA+nNnQv/OX+A8ldVq/qxFTbYOiRkhhCJtAbWX887Xliw3zouwW5ubX3834UCzjhh 7il6VgKhva/PtdoIKb8rYs+ZsgwwrifDzwFacIQH8IevwDTrI5P/XjKS8WBC3rTBo99L g13kAPVfFQNwYpTEHy3Mk77qSxA55gFqIrrzc0gWFCejBwR+0ou+4DF3FwbHrmIN+fDz m5rR8fQI62N1+ou0xY/MyRVi+krn2ja5rwIdIe4YXu8roe8VWrSGtauNQiUPhWxACtIW +wsA==
X-Received by 10.98.72.132 with SMTP id q4mr29600426pfi.53.1452555936574; Mon, 11 Jan 2016 15:45:36 -0800 (PST)
In-Reply-To <CAERt=-xWsUoy6bHdtE0W+VrLgGA3OE2=-GzwFfMWBxqi=s02bA@mail.gmail.com>
X-Mailer Apple Mail (2.3112)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:101498

Show key headers only | View raw


> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach <mafagafogigante@gmail.com> wrote:
> 
> Essentially, classes (as modules) are used mainly for organizational purposes.
> 
> Although you can solve any problem you would solve using classes
> without classes, solutions to some big problems may be cheaper and
> more feasible using classes.

As a long term OO purist practitioner, I would add to this. Obviously, you can organize your code any way you want, with or without classes. You could put all your functions with an odd number of letters in one class, and all of the even numbered ones in another class. 

Having listened to the guy (Alan Kay) who coined the term (Object Oriented Programming) quite a bit over the years, I believe that the focus of OO (of which classes are a particular implementation approach) is to bind behavior to data. In “traditional” programming approaches, one focused on the algorithm (behavior) first, and then figured out what data needed to flow where to get the job done. Classes provided a mechanism to turn that equation, generally speaking, around. One thinks about the data first, and then figures out what behavior binds best to that data. And how that data will interact (inter-object behavior, often called messages) to get your job done. For some (many) problems, this can be a real win. And for some, not so much.

I think, this is often why, for a simple script, OO just kind of gets in the way. You have a straightforward procedure that you just want to do. The state (data) is not rich enough to make making it the focal point of your program.

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


Thread

When I need classes? Arshpreet Singh <arsh840@gmail.com> - 2016-01-09 23:29 -0800
  Re: When I need classes? Michael Torrie <torriem@gmail.com> - 2016-01-10 08:02 -0700
    Re: When I need classes? Arshpreet Singh <arsh840@gmail.com> - 2016-01-10 22:45 -0800
      Re: When I need classes? Cameron Simpson <cs@zip.com.au> - 2016-01-11 18:27 +1100
  Re: When I need classes? Steven D'Aprano <steve@pearwood.info> - 2016-01-11 02:39 +1100
    Re: When I need classes? Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-10 15:48 -0200
      Re: When I need classes? Arshpreet Singh <arsh840@gmail.com> - 2016-01-10 22:24 -0800
    Re: When I need classes? Arshpreet Singh <arsh840@gmail.com> - 2016-01-10 22:28 -0800
    Re: When I need classes? Travis Griggs <travisgriggs@gmail.com> - 2016-01-11 15:45 -0800
      Re: When I need classes? Mike S <mscir@yahoo.com> - 2016-01-13 22:27 -0800
    Re: When I need classes? Michael Torrie <torriem@gmail.com> - 2016-01-11 16:59 -0700
    Re: When I need classes? Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-11 22:53 -0200
    Re: When I need classes? Chris Angelico <rosuav@gmail.com> - 2016-01-12 12:28 +1100
      Re: When I need classes? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-13 10:01 +1300
        Re: When I need classes? Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-12 19:08 -0200
    Re: When I need classes? Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-12 17:18 -0700
      Re: When I need classes? Steven D'Aprano <steve@pearwood.info> - 2016-01-13 12:33 +1100
  Re: When I need classes? Rustom Mody <rustompmody@gmail.com> - 2016-01-12 19:36 -0800
    Re: When I need classes? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-13 16:27 +1100
      Re: When I need classes? Rustom Mody <rustompmody@gmail.com> - 2016-01-12 22:31 -0800
        Re: When I need classes? Rustom Mody <rustompmody@gmail.com> - 2016-01-13 08:33 -0800
      Re: When I need classes? Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-14 10:00 -0800

csiph-web