[Tutor] dicts&lists vs objects

Andrei project5 at redrival.net
Thu May 12 10:59:15 CEST 2005


Chris Somerlot <csomerlot <at> gmail.com> writes:

> is a premutation of another, and I'm having trouble following the code
> I've written.
> Is there a golden rule to knowing when to use objects instead of dictionaries
and lists?

It all depends on the programmer, the project, etc. I'd say that the fact that
you're having trouble following your code is an indication that it might be time
to drop the procedural/inline approach for something more structured. Not that
it's impossible to write unmaintainable OOP code by the way, far from it :).
E.g. imagine having one huge big Application object with everything that was a
function having become a method of this monolithic object. Not an improvement at
all.

Depending on what/how you write, I'd say that for code over 50 lines (say 1h of
work) an OO approach at least deserves consideration and will often turn out to
have some benefits (it's possible to mix OO and procedural code). If a project
runs into thousands of lines of code, it virtually always makes sense to bring
OO into the picture.

Yours,

Andrei



More information about the Tutor mailing list