ultra newbie question (don't laugh)

George Sakkis george.sakkis at gmail.com
Tue Sep 26 11:21:28 EDT 2006


John Salerno wrote:

> So you see, what I'm asking for is very basic help, sort of along the
> lines of "what things do I need to consider before I even begin this?"
> Is OOP necessary here? Would utility functions work just as well for
> simply writing the information to a file?

To start with your last question, yes, they probably would, *IF* all
you need to do is take data from the user (through a GUI, command line,
etc.) and store them in some persistent state (text file, pickle, db,
etc.). In practice, chances are you'll need to do something more with
the data; I mean, what's the point in just storing data without using
them somehow ? Using the data is the core of an application, so the
question you should be able to answer beforehand is "what do I want to
do with all these data?". Compute statistics ? Print reports ? Create a
social network type of app ? All of the above ? You get the point.

After you have some good (or even rough) idea of what you want to do
with the data, the answer to "Is OOP necessary here?" would be
"strictly speaking, no, OOP is never necessary, but it's pretty often a
good idea". I mean, you can code the whole thing in plain old C, with
global functions and variables, and people have been doing this for
ages, but why build a fire from wood when there are zippos? In short,
OOP comes handy when:
a. you want to couple data with behavior (methods), AND
b. you have many instances of the same "kind(s)" around, interacting
with each other (deliberately using "kind" here to avoid starting a
"class" vs "type" theoretical discussion). If there's only one instance
of some "kind", in python it is usually better to have a module instead
of a singleton class (since modules are builtin singletons).

> Perhaps I should just take some kind of programming intro class! I read
> all these Python books, but when it comes time to write something
> non-trivial, I get stuck almost immediately with all the possibilities.

Or, if you're comfortable studying on your own, you could start with a
book or two that focus on software design and architecture, rather than
language details and small programming recipes. I can't think of any
specific title to suggest off the top of my head but I'm sure you'll
get some good suggestions from others if you ask here.

George




More information about the Python-list mailing list