Language and development rules: Difference between revisions

Jump to navigation Jump to search
Line 349: Line 349:


There is 3 way to make links:
There is 3 way to make links:
* The '''Table And Row Data Gateway'''
* The '''Table And Row Data Gateway'''
This is the most simple. You have one class per table and each class is a link to the table with CRUD methods (Ceate, Read, Update, Delete). A class instance is a record a the table. The class contains only code to reach lines and fields of table.
This is the most simple. You have one class per table and each class is a link to the table with CRUD methods (Ceate, Read, Update, Delete). A class instance is a record a the table. The class contains only code to reach lines and fields of table.
Line 360: Line 361:


* The '''Data Mapper'''
* The '''Data Mapper'''
Les classes représentent les entités du problème et non les données. Il faut donc doubler, tripler... ces classes avec des classes Mapper pour accéder aux données.
Classes represent entities of the problem and not the data. So you have to double, triple ... theese classes with Mapper classes to access the data.
Plus "puriste" sur le papier car plus proche du métier, ce mode a aussi l'inconvénient d'être plus complexe sur le plan pratique.
More "purist" on paper (closer of business), this method also has the disadvantage of being more complex in practice.
Exemple: C'est le choix si on utilise le Framework d'ORM '''Propel''' (http://propel.phpdb.org/trac/). On le trouve donc sur des applications plus lourdes basées sur cet ORM entre autres.
Example: This is the choice if you use the ORM Framework'' 'Propel''' (http://propel.phpdb.org/trac/). We find this model on heavier applications, based on this ORM among others.


-> Pour les développements Dolibarr, il est recommandé d'utiliser le mode de liaison '''Active Record''' qui offre les avantages d'un modèle proche du métier sans en avoir la complexité et sans trop masquer non plus la technique. C'est dans ce mode que le développement, la compréhension du code et la maintenance technique et/ou fonctionnelle semble la plus productive (ceci est toutefois un éternel débat entre les puristes et les pragmatiques, débat dans lequel personne ne peut vraiment avoir raison, car tout dépend des objectifs à atteindre).
-> For Dolibarr development, it is recommended to use the connection mode '''Active Record''', which offers the advantages of a model close to the business without having the complexity, without obfuscating the technique. It is in this way that the development, understanding of code and technical maintenance and / or business seems the more productive (this is however an ongoing debate between the purists and the pragmatists, debate in which nobody can really be right, because it depends on the objectives).

Navigation menu