Python for RAD (was: [Tutor] Re: q about method(self))

Erik Price erikprice@mac.com
Sun, 1 Sep 2002 10:31:02 -0400


On Saturday, August 31, 2002, at 12:28  PM, Emile van Sebille wrote:

> ISTM that when you
> get to the point of having a class method that turns out to be more 
> useful
> as a function, you'd want to refactor it that way.

In regards to this very notion, I have had a question burning in the 
back of my mind for a few weeks now:

Many people prefer Python over a language such as Java because you are 
not forced to use the OO methodology, and in many cases (especially 
smaller scripts) this lets you write your program more quickly.  For 
instance, it's much easier IMHO to write a function to do some work 
than it is to incorporate a special class into the design of the 
program overall (thus possibly changing the entire design) simply to 
provide this feature.  Similarly useful features of Python are the 
dynamic typing and the fact that vars don't need to be predeclared.

Yet, at the same time Python is often described as a useful environment 
for rapid application design, so that a model can be tested quickly 
without dealing with these sorts of inconveniences, even though in the 
end the final application will be implemented in one of the more 
cumbersome languages.

I've never done anything like write a program in a scripting language 
to test a design model which is to be later implemented in another 
language.  I've never even seen code like this, either.  So here is my 
question:  If you are eventually planning to migrate code to, say Java 
(since that is the only other OO language I am familiar with), is it 
unwise to take the easier route of writing functions to do some work 
that would normally be implemented [more tediously] using a class?

I would think so, since this would violate the very thing which is 
being tested -- the design/model of the application.  Obviously the 
design should have accounted for the need for this feature and there 
should be a class to represent it (or it should be handled somehow 
without the need for a separate function, since this won't be possible 
in the final implementation language [Java]).  At least, that is what I 
would assume.

But if you're staying within the Python language then a pure 
object-oriented methodology of using only classes might be more trouble 
than it's worth, it would seem.




Thank you,

Erik

PS:  I know that there are some strong feelings about different 
methodologies (including one guy on Slashdot who apparently devotes his 
life to combating the popularity of OO: http://slashdot.org/~tablizer) 
and languages so I'm not trying to be controversial.  Rather, I am 
asking as someone who is studying Java in addition to Python so the 
"pure" OO methodology is something that I have to consider in my 
designs.





--
Erik Price

email: erikprice@mac.com
jabber: erikprice@jabber.org