Looking for a good introduction to object oriented programming with Python

lipska the kat lipskathekat at yahoo.co.uk
Wed Aug 8 05:51:45 EDT 2012


On 07/08/12 22:57, Chris Angelico wrote:
> On Wed, Aug 8, 2012 at 3:00 AM, lipska the kat<lipskathekat at yahoo.co.uk>  wrote:
>> I'm still undecided over the whole 'User' thing actually,

[snip]

> This makes little sense to my mind. If you can have a "class User:",
> why can you not have a "class Person:" ?

User and Person are entirely different concepts, surely you can see that.
A User can be anything that interacts with our system, not necessarily a 
Person.

> Now, that said, I can't remember the last time I actually had a class
> called "Person" in anything other than a demo. But that's merely
> because of terminology; I've had classes representing human beings,
> but named according to what part these people play in the system
> (Customer, Employee (haven't done that one, actually, but there's no
> reason not to),

Customer is a 'business Class'. Businesses without Customers don't 
exist, at least I don't know of any. A Customer however can be many 
things, Organisations can be customers of other organisations. Is a 
LampPost a Customer of the Electricity company that supplies it with 
power ? possibly, it depends on your business model. A LampPost sure 
isn't a Person though. Limiting the Customer class to representing human 
beings is exactly that, limiting.

[snip]

> The Person class details what data you store about a person,
> a Person instance stores that data about one particular person. This
> works for other things;
> a QueueEntry isn't actually standing in queue,

Ah but it is, that's exactly what we are doing when we encapsulate a 
Human concept, where do you think the idea comes from, why is it called 
a queue, because it's analogous to what we do when we go to the cinema, 
go to the bank, do queuing type things. In fact it's a very precise, 
well defined encapsulation, First in, First out. We enforce our ideas of 
what it means to stand in a queue by writing the code in such a way that 
is impossible for anything other than thing at the head of the queue to 
get out first. If we change the concept we change the name, 
PriorityQueue ? Highest priority out first regardless of position. This 
is an extension of the original concept that exists in the real world, 
the casualty department for example, triage sorts the urgent cases from 
the non urgent, you get seen depending on the urgency of your case not 
depending on when you arrived at the hospital.

The point I'm obviously struggling to make is that words convey concepts
The word Person conveys a whole lifetime of experience of People and as 
imperfect human beings many of us are unable to tease out 'bits of being 
a person' that are relevant to the system we are developing. Inevitably 
other seemingly irreversibly entwined bits keep popping up to cloud our 
thinking. This is my experience, not an isolated case but one that has 
popped up again and again.

> but it holds the data you store about the thing that is.
>
> Or maybe that doesn't help, in which case just ignore it.

I don't need any help with this but thank you for contributing

lipska

-- 
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun



More information about the Python-list mailing list