[Tutor] OOP

alan.gauld@bt.com alan.gauld@bt.com
Thu, 21 Mar 2002 12:40:47 -0000


------_=_NextPart_001_01C1D0D5.A0517930
Content-type: text/plain; charset="iso-8859-1"

>  I wanted to know if my thinking is straight about OOP, cause I'm writing
notes  
>  one how to do stuff in Python as I learn them.   
 
Good idea, I often do that when starting a new project. 

- to use the characteristics you just name the behavior 

There is an important semantic difference at work here. It depends a bit on 
whether you want to understand OOP in general or just how Python does OOP.
 
In Python you are essentially correct. In general you use characteristics
(or more commenly termed: attributes) by *sending a message* to an instance.
In Python you send a message by specifying the name but in other OO 
environments (eg Lisp/Flavors, Actor etc) the message sending mechanism 
is decoupled from the method invocation mechanism. Thus sending the 
message "print" may activate a method called "output" say...
 
So in general you send messages to instances. Instances respond by
activating 
methods and returning the results in a message response.
 
It may seem like splitting hairs but in some languages the distinction is
very 
important and from a conceptual modelling basis its important to have the 
distinction clear in your head.
 
 >  - Max only plays when you tell it to 
 
 Again some OO environments allow for self energising 
objects which will activate methods (apparently) 
spontaneuosly. This is important in simuilsation type 
environments where a degree of randomness is required. 
Of course in practice there has to be some kind of 
trigger but again conceptually and in general objects 
can self activate.
 
HTH rather than just obfuscating things,
 
Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld
<http://www.freenetpages.co.uk/hp/alan.gauld>  

 

------_=_NextPart_001_01C1D0D5.A0517930
Content-type: text/html; charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>&gt; &nbsp;</FONT></SPAN>I wanted to know if my 
thinking is straight about OOP, cause I'm writing notes&nbsp;<SPAN 
class=890104012-21032002><FONT face="Courier New" 
color=#0000ff>&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>&gt; </FONT>&nbsp;</SPAN>one how to do stuff in 
Python as I learn them.&nbsp;&nbsp;<SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>Good idea, I often do that when starting a new 
project.</FONT>&nbsp;</SPAN></FONT></FONT></DIV>
<BLOCKQUOTE dir=ltr 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
  <DIV><FONT face=Arial><FONT size=2>- to use the characteristics you just name 
  the behavior<SPAN class=890104012-21032002><FONT face="Courier New" 
  color=#0000ff>&nbsp;</FONT></SPAN></FONT></FONT></DIV></BLOCKQUOTE>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002>There 
is an important semantic difference at work here. It depends a bit on 
</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002>whether you want to understand OOP in general or just 
how Python does OOP.</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002>In 
Python you are essentially correct. In general you use 
characteristics</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002>(or 
more commenly termed: attributes) by *sending a message* to an 
instance.</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002>In 
Python you send a message by specifying the name but in other OO 
</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002>environments (eg Lisp/Flavors, Actor etc) the message 
sending mechanism </SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002>is 
decoupled from the method invocation mechanism. Thus sending the 
</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002>message "print" may activate a method called "output" 
say...</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002>So in 
general you send messages to instances. Instances respond by activating 
</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002>methods and returning the results in a message 
response.</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002>It may 
seem like splitting hairs but in some languages the distinction is very 
</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002>important and from a conceptual modelling basis its 
important to have the </SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002>distinction clear in your 
head.</SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>&nbsp;&gt; &nbsp;</FONT></SPAN>- Max only plays 
when you tell it to<SPAN class=890104012-21032002><FONT face="Courier New" 
color=#0000ff>&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN 
class=890104012-21032002>&nbsp;<FONT face="Courier New" color=#0000ff>Again some 
OO environments allow for self energising </FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>objects which will activate methods 
(apparently) </FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>spontaneuosly. This is important in 
simuilsation type </FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>environments where a degree of randomness is 
required. </FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>Of course in practice there has to be some kind 
of </FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>trigger but again conceptually and in general 
objects </FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT size=2><SPAN class=890104012-21032002><FONT 
face="Courier New" color=#0000ff>can self 
activate.</FONT></SPAN></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT face="Courier New" color=#0000ff 
size=2><SPAN class=890104012-21032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=890104012-21032002>HTH rather than just obfuscating 
things,</SPAN></FONT></DIV>
<DIV dir=ltr><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=890104012-21032002></SPAN></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=890104012-21032002>
<P><FONT size=2>Alan g.<BR>Author of the 'Learning to Program' web site<BR><A 
target=_blank 
href="http://www.freenetpages.co.uk/hp/alan.gauld">http://www.freenetpages.co.uk/hp/alan.gauld</A></FONT> 
</P></SPAN></FONT></DIV>
<DIV dir=ltr 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"><FONT 
face="Courier New" color=#0000ff size=2><SPAN 
class=890104012-21032002></SPAN></FONT>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C1D0D5.A0517930--