[Openstack] 回复: Python Design Patterns in OpenStack

Sandy Walsh sandy.walsh at RACKSPACE.COM
Fri Feb 28 13:43:45 UTC 2014


OpenStack (and Python in general) isn't big on the classic Gang-of-Four Design Patterns.

OpenStack code seems to stem more from a "set of idioms" starting with
https://wiki.openstack.org/wiki/BasicDesignTenets

Beyond that, PEP8 and the HACKING guide are table-stakes.

From there, look at the main food groups:
1. How configuration flags are dealt with
2. How the Service/Manager/Driver hangs together in most services (like Nova)
3. How DB access is abstracted and the use of Nova Objects (again, speaking for Nova)
4. The use of plugins everywhere (re: Design Tenets)
5. Proper logging/notification generation.
6. Good RPC etiquette ... versioning, cast() vs call(), dealing with retries/failures/etc.
7. The WSGI stack
8. API design
9. Command line tools

A simple look at DevStack output will show that everyone is kind of a unique snowflake. So, look at the project you're most interested in for their "local flavor".

From there, you should have a base understanding of "The OpenStack Way".

I've been meaning to do a blog post on this stuff, but perhaps this is a good start? I'm sure others can pile on.

Welcome to the party!
-S

________________________________
From: Craig Jellick [cjellick at godaddy.com]
Sent: Friday, February 28, 2014 1:09 AM
To: …eÌì…d; Dustin J. Mitchell
Cc: openstack
Subject: Re: [Openstack] »Ø¸´£º Python Design Patterns in OpenStack

I think you should take a look a this talk:
http://blip.tv/pycon-us-videos-2009-2010-2011/the-lack-of-design-patterns-in-python-2091776
TL;DR: Things that require design patterns in a language like java are so simple in python that they aren't really discussed explicitly.

/Craig J

From: …eÌì…d <54linhao at gmail.com<mailto:54linhao at gmail.com>>
Date: Thursday, February 27, 2014 6:55 PM
To: "Dustin J. Mitchell" <dustin at mozilla.com<mailto:dustin at mozilla.com>>
Cc: openstack <openstack at lists.openstack.org<mailto:openstack at lists.openstack.org>>
Subject: [Openstack] »Ø¸´£º Python Design Patterns in OpenStack

Thanks Dustin,

Actually, my friends learn design patterns from the source code like Java design patterns in Android.

They also learn it from some technical blogs! But after searching "openstack design patterns" in google, there is no useful information.

I am wondering whether the openstack developers will take some notes relevant to design patterns.
I think it can help the beginners to read openstack source code.


------------------ ԭʼÓʼþ ------------------
·¢¼þÈË: "Dustin J. Mitchell";
·¢ËÍʱ¼ä: 2014Äê2ÔÂ27ÈÕ(ÐÇÆÚËÄ) ÍíÉÏ9:38
ÊÕ¼þÈË: "54linhao"<54linhao at gmail.com<mailto:54linhao at gmail.com>>;
³­ËÍ: "openstack";
Ö÷Ìâ: Re: [Openstack] Python Design Patterns in OpenStack

----- Original Message -----
> Hi, guys:
> I am learning Python and Design Patterns, I want to know how Design Patterns
> can be used in real world project especially python project.
>
> I know OpenStack is developed using python. So is there some materials of
> Design Patterns used in OpenStack?

Design patterns tend to be fairly abstract concepts, and become part of the general design of a project, rather than being documented explicitly.  So it may be more instructive for you to look for them yourself.

As an example, the way that managers are specified in the configuration files to change the behavior of services is an example of a pattern - which one?

You may also want to look at some smaller Python projects - perhaps discovered by shopping around the cheese shop - to see where they have or have not used patterns, and maybe even practice applying a pattern or two where you think it would improve the project.

Dustin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20140228/9e251217/attachment.html>


More information about the Openstack mailing list