On 30/06/11 10:37 -0500, Rob Martin wrote:
> Cédric,
> 
> In a post to the Tryton mailing list (about the manufacturing module), you 
> wrote:
> 
> > ... but you must keep in mind that in Tryton we try to make simple 
> > modules that just do the basis stuff (but it must be easy to extend
> > them to match the needs).
> 
> I'm very interested in this statement and I wondering you can expand
> on it a little bit. It sounds like a core statement or principal and
> I'd like to understand it well.
> 
> I've read Theo de Raadt's principal about OpenBSD, that every program
> and function will do what it is specified to do, and *only* what it is
> specified to do. Code that does something unexpected is buggy and
> almost always a security risk.

Did you read my mind? :-) I'm a big fan of OpenBSD.
So yes, it is the same idea we try to do with Tryton but of course it is a
little bit different because it is not at the same level (System vs
Business Application).

But I should say that this design principle works pretty well when you must
implementing the software in a company. Because it is faster to add the few
features needed for the company than removing/hiding the bloated options of
the system (follow my eyes :-).

> Your statement has a similar ring to it, that a module should perform
> the essence of a task in an uncomplicated way, leaving the variations
> in process to another module that builds upon the original.  Do I have
> that right?
> 
> What is the most 'trytonic' way to do this? I looked at the carrier
> module code you posted, and it appeared to me that it provides
> shipping cost using the simplest method - looking up a shipping
> (service) product in the database and retrieving the sale price and
> purchase price. If I wanted to create for example a module that
> retrieved rates from a carrier using their API, I think i would create
> a new module that depends on that module, then inherit the Carrier
> class, override the carrier_cost property to add an option for rated
> costs, and override the get_sale_price and get_purchase_price
> functions to get the prices from the API. (An overly simple example I
> think.) Do I have that correct, that this would be an example of a
> simple module that is extended to meet a need?

Exactly.
Also we try to reproduce the same design pattern when it is possible.
You will find that the code of Price List and the Tax Rule are almost the same
(the match method, apply/compute method). It is a design pattern is easy to
extend. I just made a custom module to add category on Price List in less than
30min.

> Maybe there are developer documents that explain this, and i just
> haven't located them yet. If so, I wonder if you might point me to
> them.

No, there is no documentation about this. It is more an implicit rule that
drives our development.
Also this happens because we use intensively the codereview and we talk about
design at the begining of the development.

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/

Attachment: pgpgBQD1u4zFZ.pgp
Description: PGP signature

Reply via email to