Django as exemplary design

T

TomF

I'm interested in improving my python design by studying a large,
well-designed codebase. Someone (not a python programmer) suggested
Django. I realize that Django is popular, but can someone comment on
whether its code is well-designed and worth studying?

Thanks,
-Tom
 
C

Carl Banks

I'm interested in improving my python design by studying a large,
well-designed codebase.  Someone (not a python programmer) suggested
Django.  I realize that Django is popular, but can someone comment on
whether its code is well-designed and worth studying?

I once delved into django because I wanted to use a couple of the
administrative tools for non-web tasks, and found it to be
disappointingly ad hoc. It it makes some assumptions about file
locations and module names (unnecessarily, IMO). It works well as
long as someone sticks to the rigid conventions, but can't cope well
with deviances. Therefore I'd call its codebase less than exemplary.

As a tool it's quite good (as long as you can stick to the prescribed
layout) but that's a different question.


Carl Banks
 
B

Bruno Desthuilliers

TomF a écrit :
I'm interested in improving my python design by studying a large,
well-designed codebase. Someone (not a python programmer) suggested
Django. I realize that Django is popular, but can someone comment on
whether its code is well-designed and worth studying?

Carl makes some valid points in his answer, and there are indeed a
couple dark corners in this area - bit it's just a part of the whole
framework. There are still things worth studying in Django IHMO,
specially if you're interested in seeing metaclasses and descriptors at
work.
 
A

alex23

TomF said:
I'm interested in improving my python design by studying a large,
well-designed codebase.  Someone (not a python programmer) suggested
Django.  I realize that Django is popular, but can someone comment on
whether its code is well-designed and worth studying?

Here's a viewpoint that says no: http://mockit.blogspot.com/2010/04/mess-djangos-in.html

There's a lot of good counterpoint in the comments too.

(I also think there's value to be gained in studying _bad_ code,
too...)
 
M

Michael.Coll-Barth

From: alex23
(I also think there's value to be gained in studying _bad_ code,
too...)

Oh, very true. And not just true for python. But, only if an 'expoert'
points out why it is bad and provides an alternative. And saying things
like, "it isn't pyhonic" or that such and such is a more "pythonic way"
is NOT helpful.
 
C

Carl Banks

TomF a écrit :


Carl makes some valid points in his answer, and there are indeed a
couple dark corners in this area - bit it's just a part of the whole
framework. There are still things worth studying in Django IHMO,
specially if you're interested in seeing metaclasses and descriptors at
work.

Absolutely. I said it was "less than exemplary", i.e., still pretty
good.


Carl Banks
 
T

TomF

Thanks to everyone for their comments.

Here's a viewpoint that says no:
http://mockit.blogspot.com/2010/04/mess-djangos-in.html

There's a lot of good counterpoint in the comments too.

I read most of the discussion. Yep, there is a LOT of disagreement
about the code quality. I guess I'll dig in and see whether I can
learn anything.
(I also think there's value to be gained in studying _bad_ code,
too...)

True, although whether that's time well spent is another question.

Regards,
-Tom
 
B

Bruno Desthuilliers

TomF a écrit :
On 2010-05-04 07:11:08 -0700, alex23 said: (snip)

True, although whether that's time well spent is another question.

The more bad code (mine or not) I have to maintain (or even just read
and understand), the more I pay attention to my own design and code
quality. Sometimes you only understand why something is bad, why it is
bad and how bad it is when you have to deal with it :(
 
A

Aahz

The more bad code (mine or not) I have to maintain (or even just read
and understand), the more I pay attention to my own design and code
quality. Sometimes you only understand why something is bad, why it is
bad and how bad it is when you have to deal with it :(

....and sometimes it takes several months of living with bad code to
really understand how to rewrite it. I'm currently rewriting a chunk of
bad code that merges three datasources. If I had done the rewriting
five months ago (when I first started feeling that I understood the
codebase well enough to do the job), I would not be doing the complete
rewrite that I'm currently doing, which would have led to suboptimal
code lasting longer.
 
A

Albert Hopkins

I don't know how this applies to reading other peoples' code, but
recent research shows we learn more from success than failure

That's good to learn, because for years I have been intentionally
failing in order to learn from it and become successful, and it hasn't
really worked out for me :|

-a
 
M

MRAB

Albert said:
That's good to learn, because for years I have been intentionally
failing in order to learn from it and become successful, and it hasn't
really worked out for me :|
Failure just teaches you what you shouldn't do, not what you should...
 
T

Trent Nelson

I'm interested in improving my python design by studying a large,
well-designed codebase.

I'll tell you one of the best ways to improve your Python code: attend
one of Raymond Hettinger's Code Clinic workshops at a Python conference
and put some up of your work up on the projector for 20+ developers to
rip apart, line by line ;-) You'll pick up more in 30 minutes than you
ever thought possible.

Trent.
 
T

TomF

I'll tell you one of the best ways to improve your Python code: attend
one of Raymond Hettinger's Code Clinic workshops at a Python conference
and put some up of your work up on the projector for 20+ developers to
rip apart, line by line ;-) You'll pick up more in 30 minutes than you
ever thought possible.

I don't doubt it. But I'm not really interested in line (micro) level
code issues at the moment. Not that my code couldn't stand being
improved, but I'm more interested in seeing how medium/large OO python
systems are designed. If I could get this from a book I would, but I
suspect I need to study real code.

-Tom
 
A

Aahz

I don't doubt it. But I'm not really interested in line (micro) level
code issues at the moment. Not that my code couldn't stand being
improved, but I'm more interested in seeing how medium/large OO python
systems are designed. If I could get this from a book I would, but I
suspect I need to study real code.

My suspicion is that very very few medium/large systems are truly
"well-designed". I've had occasion to dive into the CherryPy and Cheetah
code, you might look there.
 
P

Paul Kölle

Am 07.05.2010 04:48, schrieb TomF:
I don't doubt it. But I'm not really interested in line (micro) level
code issues at the moment. Not that my code couldn't stand being
improved, but I'm more interested in seeing how medium/large OO python
systems are designed. If I could get this from a book I would, but I
suspect I need to study real code.
Then trac might be a good candidate, start here

http://trac.edgewall.org/wiki/TracDev/ComponentArchitecture

then read

http://trac.edgewall.org/browser/trunk/trac/core.py#latest

there is one rather dubious hack in the implementation of implements()
but I like the conceptual simplicity.

cheers
Paul
 
L

Lawrence D'Oliveiro

MRAB said:
Failure just teaches you what you shouldn't do, not what you should...

But there are more different ways to fail than to succeed, therefore more to
learn.
 
L

Lawrence D'Oliveiro

My suspicion is that very very few medium/large systems are truly
"well-designed".

Conway’s law applies: the product of any human endeavour reflects the
organizational structure that produced it. If the individuals/groups writing
the different parts of the software were in regular communication, and
working towards a common goal rather than at odds with each other, that will
be reflected in the way their contributions interact.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top