Question about Object Oriented + functions/global vars?

Christopher J. Bottaro cjbottaro at alumni.cs.utexas.edu
Mon Jun 6 10:57:09 EDT 2005


flamesrock wrote:

> ok, so to my knowledge, object oriented means splitting something into
> the simplest number of parts and going from there.

That sounds like normal top down imperative (procedural) programming to me.

> But the question is- when is it enough?

Thats a judgment call on the programmer's part.

> For example I have the following code:
[...snip...]

> would the lines with '>#' best be split up into a seperate function,
> for example:
> #def upload(ftp, file):
[...snip...]
> and then doing the call 'upload(file_id)', or is it a better practice
> to leave things the way they were? I'm confused.

Judgment call...=)

> Finally, is it considered 'un-object-oriented' in python to have
> functions inside a module that are called by objects (ie the upload
> function above) and/or use global variables in combination?

1.  The upload function is not an object.
2.  Functions are made to be called.
3.  Some people think globals should be avoided if possible.  I think it
depends on the size of your project and how much convenience they can give
you vs. how much confusion they can potentially cause.

> -thanks in advance

Btw, object oriented programming is the splitting up of the program into
things called object which are data and their related methods.  Bah, its
hard to explain, but its like instead of focusing on functions that
manipulate a square, you instead have a square and its related methods.
Also, I can't think of OOP without thinking of polymorphism.  Ehh, this
stuff is too hard for me to explain, it would be easier with examples (but
too long for me to write)...=)

-- C




More information about the Python-list mailing list