Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26490 > unrolled thread
| Started by | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| First post | 2012-08-04 08:49 -0700 |
| Last post | 2012-08-07 11:23 +0100 |
| Articles | 20 on this page of 70 — 18 participants |
Back to article view | Back to comp.lang.python
[newbie] Looking for a good introduction to object oriented programming with Python Jean Dubois <jeandubois314@gmail.com> - 2012-08-04 08:49 -0700
Re: [newbie] Looking for a good introduction to object oriented programming with Python shearichard@gmail.com - 2012-08-04 17:11 -0700
Re: Looking for a good introduction to object oriented programming with Python Jean Dubois <jeandubois314@gmail.com> - 2012-08-05 05:38 -0700
Re: Looking for a good introduction to object oriented programming with Python Jean Dubois <jeandubois314@gmail.com> - 2012-08-05 11:04 -0700
Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-05 19:28 +0100
Re: Looking for a good introduction to object oriented programming with Python Jean Dubois <jeandubois314@gmail.com> - 2012-08-06 07:56 -0700
Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-06 17:17 +0100
Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 01:12 +0000
Re: Looking for a good introduction to object oriented programming with Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-07 11:23 +1000
Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-07 08:49 +0100
Re: Looking for a good introduction to object oriented programming with Python Roy Smith <roy@panix.com> - 2012-08-05 14:39 -0400
Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-05 19:53 +0100
Re: Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-05 18:45 -0400
Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-05 22:51 +0000
Re: Looking for a good introduction to object oriented programming with Python Roy Smith <roy@panix.com> - 2012-08-05 19:12 -0400
Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-06 00:30 +0100
Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-06 00:27 +0000
Re: Looking for a good introduction to object oriented programming with Python Dan Sommers <dan@tombstonezero.net> - 2012-08-05 17:50 -0700
Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 08:48 +0100
Re: Looking for a good introduction to object oriented programming with Python DJC <djc@news.invalid> - 2012-08-06 11:20 +0200
Re: Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-05 20:57 -0400
Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 08:43 +0100
Re: Looking for a good introduction to object oriented programming with Python Roy Smith <roy@panix.com> - 2012-08-06 09:16 -0400
Re: Looking for a good introduction to object oriented programming with Python Wolfgang Strobl <news4@mystrobl.de> - 2012-08-06 08:18 +0200
Re: [newbie] Looking for a good introduction to object oriented programming with Python dncarac@gmail.com - 2012-08-05 11:59 -0700
Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-05 20:46 +0100
Re: [newbie] Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-05 23:11 +0100
Re: [newbie] Looking for a good introduction to object oriented programming with Python Roy Smith <roy@panix.com> - 2012-08-05 18:53 -0400
Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-06 00:22 +0000
Re: [newbie] Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-06 02:02 +0100
Re: [newbie] Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-05 21:14 -0400
Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-06 06:08 +0000
Re: [newbie] Looking for a good introduction to object oriented programming with Python Paul Rubin <no.email@nospam.invalid> - 2012-08-06 00:25 -0700
Re: Looking for a good introduction to object oriented programming with Python alex23 <wuwei23@gmail.com> - 2012-08-05 19:44 -0700
Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 19:02 +0000
Re: Looking for a good introduction to object oriented programming with Python Terry Reedy <tjreedy@udel.edu> - 2012-08-07 18:37 -0400
Re: Looking for a good introduction to object oriented programming with Python alex23 <wuwei23@gmail.com> - 2012-08-07 17:07 -0700
Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-08 02:14 +0000
Re: Looking for a good introduction to object oriented programming with Python Chris Angelico <rosuav@gmail.com> - 2012-08-08 12:24 +1000
Re: Looking for a good introduction to object oriented programming with Python alex23 <wuwei23@gmail.com> - 2012-08-07 20:20 -0700
Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 09:55 +0100
Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 10:24 +0100
Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 05:35 +0000
Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 09:16 +0100
Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 05:19 +0000
Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 10:19 +0100
Re: [newbie] Looking for a good introduction to object oriented programming with Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-07 23:12 +1000
Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 15:13 +0100
Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 14:14 +0000
Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 15:34 +0100
Re: Looking for a good introduction to object oriented programming with Python rusi <rustompmody@gmail.com> - 2012-08-07 08:04 -0700
Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 18:00 +0100
Re: Looking for a good introduction to object oriented programming with Python Chris Angelico <rosuav@gmail.com> - 2012-08-08 07:57 +1000
Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-08 10:51 +0100
Re: Looking for a good introduction to object oriented programming with Python rusi <rustompmody@gmail.com> - 2012-08-08 09:27 -0700
Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-08 17:28 +0000
Re: Looking for a good introduction to object oriented programming with Python Chris Angelico <rosuav@gmail.com> - 2012-08-09 11:32 +1000
Re: Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-08 12:42 -0400
Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-08 20:31 +0100
Re: Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-08 22:59 -0400
Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-09 08:29 +0100
Geneology Packages -- WAS: Looking for a good introduction to object oriented programming with Python Simon Cropper <simoncropper@fossworkflowguides.com> - 2012-08-09 13:51 +1000
Re: Geneology Packages Ben Finney <ben+python@benfinney.id.au> - 2012-08-09 14:00 +1000
Re: Looking for a good introduction to object oriented programming with Python rusi <rustompmody@gmail.com> - 2012-08-06 05:19 -0700
Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 15:27 +0100
Re: Looking for a good introduction to object oriented programming with Python rusi <rustompmody@gmail.com> - 2012-08-06 09:34 -0700
Re: Looking for a good introduction to object oriented programming with Python Chris Angelico <rosuav@gmail.com> - 2012-08-07 08:44 +1000
OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 17:23 +0100
Re: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 09:44 +0000
Re: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 11:23 +0100
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2012-08-05 20:57 -0400 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <mailman.2990.1344214646.4697.python-list@python.org> |
| In reply to | #26580 |
On Mon, 06 Aug 2012 00:30:13 +0100, Mark Lawrence
<breamoreboy@yahoo.co.uk> declaimed the following in
gmane.comp.python.general:
>
> Ask nicely and I'll lend you my copy of Martin Fowler's UML Distilled
> which covers "version 1.2 OMG UML standard". What's it up to now,
> version 17.38?
Apparently only 2.4.1 http://www.omg.org/spec/UML/2.4.1/
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <lipskathekat@yahoo.co.uk> |
|---|---|
| Date | 2012-08-06 08:43 +0100 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <w42dnZxoF-IT6ILNnZ2dnUVZ8vydnZ2d@bt.com> |
| In reply to | #26579 |
On 05/08/12 23:51, Steven D'Aprano wrote: > On Sun, 05 Aug 2012 18:45:47 -0400, Dennis Lee Bieber wrote: > >> Don't look for Object-Oriented Programming -- since the first widely >> popular OOP language was C++ (Smalltalk was earlier, but rather >> specialized, whereas C++ started as a preprocessor for C). >> Rather look for Object-Oriented Analysis and Design (OOAD). An OOAD >> textbook /should/ be language neutral and, these days, likely using the >> constructs/notation of UML [which derived from a merger of two or three >> separate proposals for OOAD tools] > > Good lord. I'd rather read C++ than UML. And I can't read C++. This reminds me of a consultant I once worked with. He had worked on government projects for a decade or more and was a staunch supporter of the 'big bang' approach to software development. I asked him how many of these had been a success ... deafening silence. His attitude to UML was 'I'd rather cut my right arm off than waste time with that new fangled nonsense' UML works, non technical 'stakeholders' (yuk) can understand it at a high level and in my HUMBLE opinion the sequence diagram is the single most important piece of documentation in the entire software project jeez lipska -- Lipska the Kat: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2012-08-06 09:16 -0400 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <roy-78A875.09165606082012@news.panix.com> |
| In reply to | #26613 |
In article <w42dnZxoF-IT6ILNnZ2dnUVZ8vydnZ2d@bt.com>, lipska the kat <lipskathekat@yahoo.co.uk> wrote: > UML works, non technical 'stakeholders' (yuk) can understand it at a > high level and in my HUMBLE opinion the sequence diagram is the single > most important piece of documentation in the entire software project Yup. Sequence diagrams are the most common one I draw. I'm sure I use the wrong kinds of arrowheads and such, but the general idea is pretty powerful. I find they can be useful for figuring out some horrible piece of code you've never worked with before. Just sit down and start reading the code, drawing the diagram as you go. Sometimes things start to make sense that way when just staring at the code isn't doing it for you. My most successful experiment with UML was when trying to understand some big hunk of C++ somebody had thrown at me. I imported the whole thing into some UML tool, which not only found all the classes, but also sorted out how they were related. Pushing boxes around in the GUI tool turned out to be a useful way to get my head around how the code worked. The problem with UML is that, like so many good ideas, it has developed a mystique around it. With layers of gurus who know progressively more and more about the esoteric details. And who make a living writing books and giving seminars about it. Kind of like patterns, and agile, and scrum, and XP, and so on.
[toc] | [prev] | [next] | [standalone]
| From | Wolfgang Strobl <news4@mystrobl.de> |
|---|---|
| Date | 2012-08-06 08:18 +0200 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <b6ou185fkjm9ningfmqmd5qbmisnkp1jvq@4ax.com> |
| In reply to | #26577 |
Dennis Lee Bieber <wlfraed@ix.netcom.com>: > Don't look for Object-Oriented Programming -- since the first widely >popular OOP language was C++ (Smalltalk was earlier, but rather >specialized, whereas C++ started as a preprocessor for C). Well, C++ did to C what Simula 67 did to Algol 60, much earlier. Simula was quite popular at its time. <http://en.wikipedia.org/wiki/Simula> -- Thank you for observing all safety precautions
[toc] | [prev] | [next] | [standalone]
| From | dncarac@gmail.com |
|---|---|
| Date | 2012-08-05 11:59 -0700 |
| Message-ID | <696267e8-996a-45ac-97d9-b1d4d2453466@googlegroups.com> |
| In reply to | #26490 |
I found Mark Lutz's book Learning Python had two or three chapters on object oriented programming from starting principles to more involved Python object programming. It helped me immensely.
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <lipskathekat@yahoo.co.uk> |
|---|---|
| Date | 2012-08-05 20:46 +0100 |
| Message-ID | <sqednRxYjp0OUIPNnZ2dnUVZ8rednZ2d@bt.com> |
| In reply to | #26490 |
On 04/08/12 16:49, Jean Dubois wrote: > I'm looking for a good introduction to object oriented programming > with Python. <rant> Object Oriented programming is a mindset, a way of looking at that particular part of our world that you are trying to encapsulate in computer language. The language you use is (should be) irrelevant. The ONLY concept that you should never try to encapsulate is/are human beings or their aliases. So Person, User, Human etc should not exist in any way shape or form in your design. There is an argument that User is ok but I don't subscribe to that. If you want to represent human interaction in your software design use Account or Session or some other non human noun. </rant> Actually it should really be called Class Oriented programming as classes are the units of encapsulation. I really don't think python is a good language to learn OO programming, the problem is that Python doesn't enforce OO so you are never going to learn what is 'OO' and what isn't. Before I get told off/flamed/shouted at I've just started learning Python and I think it is a great language with a fantastic standard library. I've already managed to write meaningful code but I haven't invented a single class yet. Apologies if this sound negative, it's not meant to be it's meant to be constructive. There is a book you could try, it's a bit dry and I read it when I can't sleep, about 30 mins usually does it :-) It's called Design Patterns by Gamma, Helm, Johnson and Vlissides ISBN 0-201-63361-2. They do use C++ code in examples but as they say, this is just a convenience and shouldn't colour your view of the subject I still read the introduction and get something out of it after several years. You should be able to implement the patterns in Python although I must admit I haven't tried that yet Learn Python by all means, the interactive mode is particularly fun,just try and get a good idea of what OO is all about before you start. Just my opinion lipska -- Lipska the Kat: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-08-05 23:11 +0100 |
| Message-ID | <mailman.2980.1344204577.4697.python-list@python.org> |
| In reply to | #26550 |
On 05/08/2012 20:46, lipska the kat wrote: [snip] > There is a book you could try, it's a bit dry and I read it when I can't > sleep, about 30 mins usually does it :-) > It's called Design Patterns by Gamma, Helm, Johnson and Vlissides > ISBN 0-201-63361-2. > They do use C++ code in examples but as they say, this is just a > convenience and shouldn't colour your view of the subject > I still read the introduction and get something out of it after several > years. You should be able to implement the patterns in Python > although I must admit I haven't tried that yet > Please no, that's the worst possible book for someone trying to learn OOD in Python. It's mostly if not completely irrelevant, jumping through hoops that you don't need in Python because of its dynamic nature. Start with the factory pattern and I hope you'll understand why I say this. Search for "design patterns alex martelli" and you'll get all you need and more. > lipska > > > -- Cheers. Mark Lawrence.
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2012-08-05 18:53 -0400 |
| Message-ID | <roy-D3CB19.18534505082012@news.panix.com> |
| In reply to | #26573 |
On 05/08/2012 20:46, lipska the kat wrote: > Design Patterns by Gamma, Helm, Johnson and Vlissides In article <mailman.2980.1344204577.4697.python-list@python.org>, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote: > Please no, that's the worst possible book for someone trying to learn > OOD in Python. +1 what Mark said. It's certainly the classic patterns book, but most of it is about clever ways to work around the C++/Java style of type bondage. Trying to learn OO from that book is like learning to paint by reading a textbook on the chemical properties of oil pigments.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-08-06 00:22 +0000 |
| Message-ID | <501f0e4a$0$29867$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #26550 |
On Sun, 05 Aug 2012 20:46:23 +0100, lipska the kat wrote:
> <rant>
> Object Oriented programming is a mindset, a way of looking at that
> particular part of our world that you are trying to encapsulate in
> computer language. The language you use is (should be) irrelevant.
That depends on how you define OOP, and in particular, which aspects of
OOP your language supports.
There are lots of differences between styles and implementations of OOP
languages, and no two languages have exactly the same feature set, but in
general most OOP languages involve most of the following features:
- Dynamic dispatch when making method calls
- Encapsulation, or multi-methods
- Subtype polymorphism
- Object inheritance, or delegation
See here for more detail:
http://en.wikipedia.org/wiki/Object-oriented_programming#Fundamental_features_and_concepts
But beyond those fundamentals, the details of OOP can differ greatly from
language to language. Some languages treat classes as static, some as
dynamic. Some languages treat classes as objects themselves, others treat
them as non-objects. Syntax varies (although the dot operator has become
almost completely ubiquitous, there are still some exceptions).
In particularly, terminology varies -- I personally despise with the heat
of a thousand suns the terms "instance variable" and "class variable" for
attributes or members. Since a "string variable" is a variable holding a
string, and a "float variable" is a variable holding a float, an instance
variable should be a variable holding an instance, and a class variable
should be a variable holding a class.
> The ONLY concept that you should never try to encapsulate is/are human
> beings or their aliases. So Person, User, Human etc should not exist in
> any way shape or form in your design. There is an argument that User is
> ok but I don't subscribe to that.
>
> If you want to represent human interaction in your software design use
> Account or Session or some other non human noun. </rant>
Is this some sort of mystical "humans aren't objects, they're SPECIAL!!!"
rubbish? Because it sure sounds like it.
Can you give some non-religious reasons why you should not implement
human beings or aliases as objects?
If not, let me just say that I reject your prohibition and leave it at
that.
> Actually it should really be called Class Oriented programming as
> classes are the units of encapsulation.
Incorrect. You don't even need classes to have objects. You can have
class-based OOP, and prototype-based OOP, as in Javascript, Actionscript,
Io, and the language which invented the term, Self.
http://en.wikipedia.org/wiki/Prototype-based_programming
> I really don't think python is a
> good language to learn OO programming, the problem is that Python
> doesn't enforce OO so you are never going to learn what is 'OO' and what
> isn't.
I think that's exactly why Python *is* a good language to learn OOP,
because you can be productive even while learning. You can start off by
just adding a little bit of OOP syntax to your programs:
response = raw_input("What do you want to do? ")
response = response.lower() # Look ma, I'm using OOP!
while still being primarily procedural. Then you can gradually learn the
terminology ("what's an instance?"), graduate to writing your own
classes, and then finally move on to OOP techniques which some languages
don't even allow, like metaclasses.
> Before I get told off/flamed/shouted at I've just started learning
> Python and I think it is a great language with a fantastic standard
> library. I've already managed to write meaningful code but I haven't
> invented a single class yet.
And why do you think this is a problem?
Classes are one possible solution to problems that actually matter. What
matters is the solution, not the mechanism of the solution. "Writing
classes" is just a means to an end (the solution), not the end itself.
> There is a book you could try, it's a bit dry and I read it when I can't
> sleep, about 30 mins usually does it :-) It's called Design Patterns by
> Gamma, Helm, Johnson and Vlissides ISBN 0-201-63361-2.
> They do use C++ code in examples but as they say, this is just a
> convenience and shouldn't colour your view of the subject I still read
> the introduction and get something out of it after several years. You
> should be able to implement the patterns in Python although I must admit
> I haven't tried that yet
Two problems with "Design Patterns" is that many of them are excessively
abstract, and that often they only exist to work around limitations in
the source language (usually C++ or Java).
The first problem means that any half-decent programmer has probably been
using "Design Patterns" for years without realising it, or knowing the
name. I remember writing an "Object Pool" in procedural Pascal in the
1980s to recycle resources, long before the concept was given a name. Not
that I claim to have invented the concept -- I merely copied it from
someone else, who described the technique without giving it a name. Not
that he invented it either.
The emphasis on *names* is just jargon, design patterns are actually just
problem-solving techniques. Sometimes it's useful to have jargon that
everyone recognises, e.g. "factory function" and "singleton" are two I
consistently remember (and I use the first *all the time* and the second
*never*), but often Design Pattern proponents become side-tracked into
finer and finer differences of greater and greater abstraction, at the
expense of clarity.
In my not-so-humble opinion, the popularity of Design Patterns has a lot
to do with the fact that they are so abstract and jargon-ridden that they
have become a badge of membership into an elite. Shorn of their excessive
abstractness, they're not very special. People were writing helper
functions to assemble complex data long before the Builder pattern was
named, and a Facade is just an interface layer.
> Learn Python by all means, the interactive mode is particularly fun,just
> try and get a good idea of what OO is all about before you start.
As far as I am concerned, any language without an interactive interpreter
is incomplete.
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-08-06 02:02 +0100 |
| Message-ID | <mailman.2992.1344214866.4697.python-list@python.org> |
| In reply to | #26587 |
On 06/08/2012 01:22, Steven D'Aprano wrote: [snipped to death] > > In my not-so-humble opinion, the popularity of Design Patterns has a lot > to do with the fact that they are so abstract and jargon-ridden that they > have become a badge of membership into an elite. Shorn of their excessive > abstractness, they're not very special. People were writing helper > functions to assemble complex data long before the Builder pattern was > named, and a Facade is just an interface layer. > Design patterns being abstract and jargon ridden puts them alongside many other aspects of ICT, CS, call it what you like. Especially beloved by consultants as it means they can talk crap for hours and charge a fortune for it. -- Cheers. Mark Lawrence.
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2012-08-05 21:14 -0400 |
| Message-ID | <mailman.2994.1344215659.4697.python-list@python.org> |
| In reply to | #26587 |
On 06 Aug 2012 00:22:34 GMT, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> declaimed the following in
gmane.comp.python.general:
> Is this some sort of mystical "humans aren't objects, they're SPECIAL!!!"
> rubbish? Because it sure sounds like it.
>
> Can you give some non-religious reasons why you should not implement
> human beings or aliases as objects?
>
I think it's an over-simplification of humans being "actors" who
drive the software, and not something ("chess pieces") that the software
should be driving. (OTOH: how many remember that surge in "up-shift"
indicator lights on manual transmission cars, near the late 70s early
80s? The few times I drove one of those, it was telling me to up-shift
as soon as I let out the clutch from the previous up-shift).
Though to me, that really means there should be no requirements
phrased as "the operator shall <do something to the software>"; it
should be "the software shall <respond to operator activity>".
Taken literally, the prohibition would mean no modeling of Employees
in a payroll or HR system -- since Employee represents a person working
for the company.
> The emphasis on *names* is just jargon, design patterns are actually just
> problem-solving techniques. Sometimes it's useful to have jargon that
> everyone recognises, e.g. "factory function" and "singleton" are two I
> consistently remember (and I use the first *all the time* and the second
> *never*), but often Design Pattern proponents become side-tracked into
> finer and finer differences of greater and greater abstraction, at the
> expense of clarity.
>
While I've probably used singletons (usually as sentinels in queues,
I suspect), but can't say that I've ever used a "factory function"...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-08-06 06:08 +0000 |
| Message-ID | <501f5f65$0$29867$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #26598 |
On Sun, 05 Aug 2012 21:14:04 -0400, Dennis Lee Bieber wrote:
> While I've probably used singletons (usually as sentinels in queues,
I don't know your code, but if I were to take a wild guess, I would say
that apart from None, and True/False, you probably haven't.
NotImplemented and Ellipsis are two other singletons in Python. It is
possible to program a Singleton class in pure Python, but most people
don't bother, because 1) singleton is probably the most over-used Design
Pattern of them all and 2) it's quite trivial to bypass the singleton-ness
of classes written in Python and create a second instance.
Or they use a module, which is not really a singleton but behaves like
one. Or if they want to show off their Pythonicity, they use the Borg
pattern.
The common sentinel idiom in Python is to do this:
SENTINEL = object()
# and later...
if value is SENTINEL:
pass
but of course that's not a singleton because it's only one instance out
of a vast number, and anyone can create another instance. Also it misses
the point of the Singleton pattern, that the (lone) instance should hold
state. The sentinel does not usually hold state.
> I suspect), but can't say that I've ever used a "factory function"...
If you've ever used an ordinary function decorator, you almost certainly
have.
If you've every created a closure, you definitely have.
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-08-06 00:25 -0700 |
| Message-ID | <7x1ujka3dv.fsf@ruckus.brouhaha.com> |
| In reply to | #26608 |
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: >> I suspect), but can't say that I've ever used a "factory function"... > If you've ever used an ordinary function decorator, you almost certainly > have. > If you've every created a closure, you definitely have. Or anything with a __iter__ method...
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2012-08-05 19:44 -0700 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <a94208f5-2a61-40c9-889b-c62b39d4e84f@hv2g2000pbc.googlegroups.com> |
| In reply to | #26587 |
On Aug 6, 10:22 am, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> wrote: > In my not-so-humble opinion, the popularity of Design Patterns has a lot > to do with the fact that they are so abstract and jargon-ridden that they > have become a badge of membership into an elite. Shorn of their excessive > abstractness, they're not very special. People were writing helper > functions to assemble complex data long before the Builder pattern was > named, and a Facade is just an interface layer. I think you've entirely missed the point of Design Patterns. No one claims that the Go4 DP book introduced Builders, Singletons, Facades. The point was to identify _and name_ such patterns, so programmers could actually talk about repeated behaviour. Design patterns are an attempt to encapsulate and express experience, that's it. There's nothing mystical or special about them at all, and to be honest I never ever such claims come from proponents of them, only their critics. Why is it an "elitist" action to want to be able to share experience and learn from that of others? If anything, I find the problem is with the insular nature of most developers and the preponderance of NIH attitudes.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-08-07 19:02 +0000 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <5021664b$0$29978$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #26604 |
On Sun, 05 Aug 2012 19:44:31 -0700, alex23 wrote: > I think you've entirely missed the point of Design Patterns. Perhaps I have. Or perhaps I'm just (over-)reacting to the abuse of Patterns: http://c2.com/cgi/wiki?DesignPatternsConsideredHarmful or maybe I'm just not convinced that Design Patterns as described by the Go4 are as important and revolutionary as so many people seem to believe: http://perl.plover.com/yak/design/ or that they are a crutch for underpowered languages: http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures I haven't read the Gang of Four book itself, but I've spent plenty of time being perplexed by over-engineered, jargon-filled code, articles, posts and discussions by people who use Design Patterns as an end to themselves rather than a means to an end. (Singleton is notoriously bad in that way.) On the other hand, as I think I've stated before, the design patterns themselves aren't *necessarily* bad. They're just problem solving techniques and common idioms. I think that as languages get more powerful, "Design Patterns" just become language features, and people stop talking about them. Nobody talks about Function Pattern, but everyone uses it. In Python, we don't talk about the Iterator Pattern. We just use iterators. > No one claims that the Go4 DP book introduced Builders, Singletons, > Facades. The point was to identify _and name_ such patterns, so > programmers could actually talk about repeated behaviour. I'm pretty sure that people could talk about good coding design before the Gof4. As you say, they didn't invent the patterns. So people obviously wrote code, and talked about algorithms, without the Gof4 terminology. I don't think that "Memento Pattern" is any more clear than "save and restore". When you have a few standard patterns, everyone can know what they are. When you start getting into multiple dozens, it's not so clear to me that they are all *standard* any more. http://c2.com/cgi/wiki?CategoryPattern And the ever-finer distinctions between variations on patterns. Without looking them up, what are the difference between Default Visitor, Extrinsic Visitor, Acyclic Visitor, Hierarchical Visitor, Null Object And Visitor, and regular old Visitor patterns? -- and no, I did not make any of them up. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2012-08-07 18:37 -0400 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <mailman.3070.1344379062.4697.python-list@python.org> |
| In reply to | #26737 |
On 8/7/2012 3:02 PM, Steven D'Aprano wrote: > On Sun, 05 Aug 2012 19:44:31 -0700, alex23 wrote: > >> I think you've entirely missed the point of Design Patterns. > > Perhaps I have. Or perhaps I'm just (over-)reacting to the abuse of > Patterns: > > http://c2.com/cgi/wiki?DesignPatternsConsideredHarmful > > or that they are a crutch for underpowered languages: I still remember reading an article something like "Implementing the Composite Pattern in C++". The example for the discussion was Pictures that could contain sub-Pictures as well as Graphic elements. I eventually realized that a) this is trivial in Python, b) the article was really about how to lie to a C++ compiler, so it would accept recursive heterogenous structures, and c) I preferred Python. > http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures > I think that as languages get more powerful, "Design Patterns" just > become language features, and people stop talking about them. Nobody > talks about Function Pattern, but everyone uses it. In Python, we don't > talk about the Iterator Pattern. We just use iterators. In pre 2.2 Python, there was talk about the pattern (but not with Capitals) and how to lie to the interpreter with a fake __getitem__ method. > I'm pretty sure that people could talk about good coding design before > the Gof4. As you say, they didn't invent the patterns. So people > obviously wrote code, and talked about algorithms, without the Gof4 > terminology. 'Divide and conquer' is an old, descriptive name for an algorithm action pattern. It is only incidentally about static structures. 'Dynamic programming' is a rather opaque name for a) an action patter for using the optimality principle* (when applicable) and b) not disposing of data one still needs. * the best path from A to B that passes through C is the best path from A to C plus the best path from C to B. Lisp is based on a simple data pattern (or is it a principle): collection (of dicrete items) = one item + remainder, used to both construct and deconstruct. Python iterator embody the the same principle. next(iterator) = iterator: return one item and mutate yourself to represent the rest -- or raise StopIteration. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2012-08-07 17:07 -0700 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <d5e79e65-c9d7-4a8a-b756-933c6a711418@q3g2000vbc.googlegroups.com> |
| In reply to | #26737 |
On Aug 8, 5:02 am, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> wrote: > I haven't read the Gang of Four book itself, but I've spent plenty of > time being perplexed by over-engineered, jargon-filled code, articles, > posts and discussions by people who use Design Patterns as an end to > themselves rather than a means to an end. (Singleton is notoriously bad > in that way.) The Go4 book isn't perfect, and I don't agree with all of their patterns. But they themselves made it very clear that _you're not supposed to_. It's meant to provide a mechanism for discussion and debate. It's _just another tool for development_; it's not a silver bullet, and anyone who claims otherwise is just a desperate marketing shill. _Not_ using a pattern should be as much a part of any conversation as using it. (But then, I love the word "synergy" too. Just because something has been driven into the ground through marketing misuse or overeager misapplication doesn't make the basic concept itself worthless.) > I think that as languages get more powerful, "Design Patterns" just > become language features, and people stop talking about them. Nobody > talks about Function Pattern, but everyone uses it. In Python, we don't > talk about the Iterator Pattern. We just use iterators. I'm not making the distinction between "iterator pattern" and "iterators". Talking about one is talking about the other. That's _all_ I see design patterns as: naming and defining commonly re-used aspects of functionality. Not invention, recognition. > I'm pretty sure that people could talk about good coding design before > the Gof4. As you say, they didn't invent the patterns. So people > obviously wrote code, and talked about algorithms, without the Gof4 > terminology. So what did people call Singletons before the pattern was named? If I was talking about "global uniques" and you were talking about "single instantiation", would we even recognise we were discussing the same thing? The Go4 book was as much about the approach of naming and documenting patterns as describing the patterns they saw. It was just an attempt at formally approaching what we were previously doing anyway. > I don't think that "Memento Pattern" is any more clear than "save and > restore". And I don't think that everyone making up their own terminology helps with the _communicativeness_ of code. > And the ever-finer distinctions between variations on patterns. Without > looking them up, what are the difference between Default Visitor, > Extrinsic Visitor, Acyclic Visitor, Hierarchical Visitor, Null Object And > Visitor, and regular old Visitor patterns? -- and no, I did not make any > of them up. Why wouldn't I look them up? The point is that they represent experience with solving certain problems. _Someone_ felt the distinction was necessary; by their documenting it I can read it and decide whether the distinction is relevant to me. Maybe they considered edge cases I didn't. But telling me _not_ to look at the definition of a design pattern and just "intuit" it's meaning is, again, missing the point of having a means of communicating experience with specific problem domains.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-08-08 02:14 +0000 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <5021cb68$0$29978$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #26744 |
On Tue, 07 Aug 2012 17:07:59 -0700, alex23 wrote:
>> I'm pretty sure that people could talk about good coding design before
>> the Gof4. As you say, they didn't invent the patterns. So people
>> obviously wrote code, and talked about algorithms, without the Gof4
>> terminology.
>
> So what did people call Singletons before the pattern was named? If I
> was talking about "global uniques" and you were talking about "single
> instantiation", would we even recognise we were discussing the same
> thing?
But are we? If we're comparing code written in two languages, we don't
even know if "global" means the same -- it could be global to a single
module, or global to the entire program.
Singletons encompass many different behaviours under a single name. If I
delete the single instance, and recreate it, will it necessarily have the
same state? Calling it a singleton doesn't answer that question. We still
have to agree on what behaviour this particular singleton has.
NoneType raises an error if you try to create a second instance. bool
just returns one of the two singletons (doubletons?) again.
py> type(None)()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create 'NoneType' instances
py> type(False)() is False
True
And modules are singletons, even though there is no upper limit to the
number of distinct module objects you can get. So if I tell you that X is
a singleton, you don't even know something as fundamental as whether or
not X is the only instance of its type.
> The Go4 book was as much about the approach of naming and documenting
> patterns as describing the patterns they saw. It was just an attempt at
> formally approaching what we were previously doing anyway.
>
>> I don't think that "Memento Pattern" is any more clear than "save and
>> restore".
>
> And I don't think that everyone making up their own terminology helps
> with the _communicativeness_ of code.
Are you saying that Go4 shouldn't have made up their own terminology?
"Save and restore" is plain English which predates "Memento Pattern". I
was writing code in the 1980s like:
save := something;
do_stuff_to(something);
something := save; {restore old value}
which is the Memento pattern in non-OOP Pascal.
>> And the ever-finer distinctions between variations on patterns. Without
>> looking them up, what are the difference between Default Visitor,
>> Extrinsic Visitor, Acyclic Visitor, Hierarchical Visitor, Null Object
>> And Visitor, and regular old Visitor patterns? -- and no, I did not
>> make any of them up.
>
> Why wouldn't I look them up?
You claim that named Patterns simplify and clarify communication. If you
have to look the terms up, they aren't simplifying and clarifying
communication, they are obfuscating it.
The time I save in writing "Foo Visitor" is lost a dozen times over for
every one of my readers who has to look it up to find out what I mean.
And if somebody else uses "Foo Visitor" to mean something different to
what I mean, we now have a communication mismatch. The finer the
distinction between Foo and Bar Visitor, the more likely that people will
misunderstand or fail to see the distinction, and the less useful the
terminology gets.
There is a point of diminishing returns in terminology, where finer
distinctions lead to less clarity rather than more, and in my opinion
that point was already passed when Go4 wrote their book, and it's just
got worse since.
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-08-08 12:24 +1000 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <mailman.3074.1344392644.4697.python-list@python.org> |
| In reply to | #26747 |
On Wed, Aug 8, 2012 at 12:14 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> NoneType raises an error if you try to create a second instance. bool
> just returns one of the two singletons (doubletons?) again.
>
> py> type(None)()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: cannot create 'NoneType' instances
> py> type(False)() is False
> True
This is necessitated by the use of bool(x) as a means of boolifying
("casting to bool", if you like) x. I wouldn't want that to change,
and since type(False) is bool, what you see is bound to occur.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2012-08-07 20:20 -0700 |
| Subject | Re: Looking for a good introduction to object oriented programming with Python |
| Message-ID | <2436e0c0-8d60-4a34-a236-898abbb23646@k21g2000vbn.googlegroups.com> |
| In reply to | #26747 |
On Aug 8, 12:14 pm, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> wrote: > You claim that named Patterns simplify and clarify communication. If you > have to look the terms up, they aren't simplifying and clarifying > communication, they are obfuscating it. By that argument, an encyclopaedia is useless because if you have to look up the meaning of something by its name... Names are identifiers for exactly that reason, to make look up easier. Names aren't meant to encode every aspect of what they represent. Or why distinguish between quick sort & merge sort? Let's just talk about "sort", that's simpler. > The time I save in writing "Foo Visitor" is lost a dozen times over for > every one of my readers who has to look it up to find out what I mean. What would you call it that would remove the need for _anyone_ to look up/ask you what it meant? > And if somebody else uses "Foo Visitor" to mean something different to > what I mean, we now have a communication mismatch. Do we just not use names at all? How do you communicate what you're doing in this instance? > There is a point of diminishing returns in terminology, where finer > distinctions lead to less clarity rather than more, and in my opinion > that point was already passed when Go4 wrote their book, and it's just > got worse since. Can you please point me to a standardised way for talking about abstract patterns of behaviour across languages?
[toc] | [prev] | [next] | [standalone]
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
Back to top | Article view | comp.lang.python
csiph-web