Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Travis Griggs Newsgroups: comp.lang.python Subject: Re: When I need classes? Date: Mon, 11 Jan 2016 15:45:35 -0800 Lines: 32 Message-ID: References: <56927b37$0$1586$c3e8da3$5496439d@news.astraweb.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: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101498 > On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach = wrote: >=20 > Essentially, classes (as modules) are used mainly for organizational = purposes. >=20 > 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.=20 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 =E2=80=9Ctraditional=E2=80=9D = 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.=