Continuing with the series on 2E development standards.
A model-naming standard is very important, particularly for large models, to aid understanding and navigation. There are several types of naming standards to consider.
Model Names
A CA:2E data model has a 25-character object text names associated with files, access paths, fields, field conditions, functions and messages etc. The guidelines for each object type are detailed below. As a general rule:
Apart from files, try and only use 24 characters for the field, function, access path etc. This make it a lot easier to navigate around in the model and to use the ‘?’ prompting facility.
Capitalise all words except articles, prepositions, conjunctions, and the 'to' in infinitives. E.g. 'Currency of Invoice'
Avoid punctuation.
Try to establish a vocabulary of preferred names. Where abbreviations are necessary then they should conform to a common abbreviations list. It is recommended this list be generic across all of your development models and other languages and environments.
OS/400 Object Names
OS/400 object names and DDS names are required for actual implementation. CA:2E will assign names for all object types according to its own naming standard. Messages, DDS format names and fields will default to CA:2E assigned names.
If using a Multi-Version Multi-Model setup extra care needs to be taken to ensure that and new model objects are created equally if coding into multiple models i.e. Bug fixing a current and development release at the same time.
Queries can be written to keep tabs on objects and their names that do not cross reference satisfactorily. I.e. Model Name to Model Name as well as Implementation Name to Implementation Name. This forms part of a wider blog on model management techniques. Something for the future?
Some development shops have chosen to replace the 2e naming conventions for some objects in a development model. The Pro’s and Con’s of this approach are as follows:-
Pro's
Nicely named objects. Great for when calling programs from a menu or command line.
Encourages a standard form and reinforces the principle of the naming conventions.
Easy to detect if not renamed as 2e prefix is still associated to object.
Con's
After a while it is difficult to get a unique and meaningful object name, therefore, some names can seem ambiguous.
Extra work for a developer. Often forgotton.
Will generally require a mnemonic standard i.e. XXYYYYnnZ so may as well have the defaults.
Model Files
All new files and file changes should be managed by the Database Administrator (DBA) or a central owner for that model. This of course, depends on the size of your development shop but it good practice to separate the roles. This will allow good control of the model.
Implement a TLA?. I have implemented a Three-letter Acronym (TLA) following the name at some sites I have worked at. E.g. ‘My Sample File MSF’, The TLA will occupy the last 3 bytes of the available space for the file. Note this is the only model object type where I have deliberately use the last byte.
These 3 letters should precede all fields for that file.
File descriptions should represent a single instance of an entity, e.g. 'Customer' not 'Customers'. However, if the name describes many attributes of a single record then a plural may be ok, e.g. 'Account Parameters'.
Avoid using descriptive names like 'Details' or 'File'. E.g. 'Customer' rather than 'Customer Details File'. However, sometimes it may be necessary to differentiate between different levels of detail, e.g. 'Order Header' and 'Order Line'.
Short names will avoid truncation when assigned by CA:2E to default DBF functions or foreign key fields using 'For' text although the DBA processes of replacing or renaming of fields should negate the need for the developer to be to concerned.
Try to group Parent/Child file relationships by using common name prefixes.
Future blogs will expand on the area of model management and database administration guides.
Access Paths
Unlike files, access paths can be created by a developer with *PGMR access. It is recommended that you query the 2E model files and keep an eye on any new access paths that are created and their purpose. These should be reviewed from time to time to ensure that best practice has been considered when access path was created.
Do NOT create new access paths without thinking if there is an alternative e.g. Using one that is similar and/or doing selection within the functions. If in doubt, talk it through with your DBA or a senior developer.
Virtuals should, in general, not be used, and should NEVER be on standard access paths. There may be times when they are the best solution e.g. For resequencing a query access path rather than creating a work file.
The description should try and explain the purpose of the access path.
In general there should only be 1 UPD (Update) style access path per file.
In general access path relations should NOT be dropped. If this is used then the default access paths should be clean and an alternative RTV or RSQ created.
No Virtual Virtuals. Avoid multiple nested levels of virtual fields if you are going to use them.
It is highly recommended that default access paths should never contain Virtuals or have Select/Omit. Use an alternative RSQ or RTV if virtual fields are deemed necessary.
If creating an access path over an assimilated file from another model then care must be taken with the default naming of the access path.
Next time we will talk about functions and I will provide some recommendations for naming standards as well as some standards for default functions.
Thanks for reading.
Lee.
Model Names
A CA:2E data model has a 25-character object text names associated with files, access paths, fields, field conditions, functions and messages etc. The guidelines for each object type are detailed below. As a general rule:
Apart from files, try and only use 24 characters for the field, function, access path etc. This make it a lot easier to navigate around in the model and to use the ‘?’ prompting facility.
Capitalise all words except articles, prepositions, conjunctions, and the 'to' in infinitives. E.g. 'Currency of Invoice'
Avoid punctuation.
Try to establish a vocabulary of preferred names. Where abbreviations are necessary then they should conform to a common abbreviations list. It is recommended this list be generic across all of your development models and other languages and environments.
OS/400 Object Names
OS/400 object names and DDS names are required for actual implementation. CA:2E will assign names for all object types according to its own naming standard. Messages, DDS format names and fields will default to CA:2E assigned names.
If using a Multi-Version Multi-Model setup extra care needs to be taken to ensure that and new model objects are created equally if coding into multiple models i.e. Bug fixing a current and development release at the same time.
Queries can be written to keep tabs on objects and their names that do not cross reference satisfactorily. I.e. Model Name to Model Name as well as Implementation Name to Implementation Name. This forms part of a wider blog on model management techniques. Something for the future?
Some development shops have chosen to replace the 2e naming conventions for some objects in a development model. The Pro’s and Con’s of this approach are as follows:-
Pro's
Nicely named objects. Great for when calling programs from a menu or command line.
Encourages a standard form and reinforces the principle of the naming conventions.
Easy to detect if not renamed as 2e prefix is still associated to object.
Con's
After a while it is difficult to get a unique and meaningful object name, therefore, some names can seem ambiguous.
Extra work for a developer. Often forgotton.
Will generally require a mnemonic standard i.e. XXYYYYnnZ so may as well have the defaults.
Model Files
All new files and file changes should be managed by the Database Administrator (DBA) or a central owner for that model. This of course, depends on the size of your development shop but it good practice to separate the roles. This will allow good control of the model.
Implement a TLA?. I have implemented a Three-letter Acronym (TLA) following the name at some sites I have worked at. E.g. ‘My Sample File MSF’, The TLA will occupy the last 3 bytes of the available space for the file. Note this is the only model object type where I have deliberately use the last byte.
These 3 letters should precede all fields for that file.
File descriptions should represent a single instance of an entity, e.g. 'Customer' not 'Customers'. However, if the name describes many attributes of a single record then a plural may be ok, e.g. 'Account Parameters'.
Avoid using descriptive names like 'Details' or 'File'. E.g. 'Customer' rather than 'Customer Details File'. However, sometimes it may be necessary to differentiate between different levels of detail, e.g. 'Order Header' and 'Order Line'.
Short names will avoid truncation when assigned by CA:2E to default DBF functions or foreign key fields using 'For' text although the DBA processes of replacing or renaming of fields should negate the need for the developer to be to concerned.
Try to group Parent/Child file relationships by using common name prefixes.
Future blogs will expand on the area of model management and database administration guides.
Access Paths
Unlike files, access paths can be created by a developer with *PGMR access. It is recommended that you query the 2E model files and keep an eye on any new access paths that are created and their purpose. These should be reviewed from time to time to ensure that best practice has been considered when access path was created.
Do NOT create new access paths without thinking if there is an alternative e.g. Using one that is similar and/or doing selection within the functions. If in doubt, talk it through with your DBA or a senior developer.
Virtuals should, in general, not be used, and should NEVER be on standard access paths. There may be times when they are the best solution e.g. For resequencing a query access path rather than creating a work file.
The description should try and explain the purpose of the access path.
In general there should only be 1 UPD (Update) style access path per file.
In general access path relations should NOT be dropped. If this is used then the default access paths should be clean and an alternative RTV or RSQ created.
No Virtual Virtuals. Avoid multiple nested levels of virtual fields if you are going to use them.
It is highly recommended that default access paths should never contain Virtuals or have Select/Omit. Use an alternative RSQ or RTV if virtual fields are deemed necessary.
If creating an access path over an assimilated file from another model then care must be taken with the default naming of the access path.
Next time we will talk about functions and I will provide some recommendations for naming standards as well as some standards for default functions.
Thanks for reading.
Lee.
No comments:
Post a Comment
Thanks for considering leaving some comments about my random rants for everything software development and more.