Build names of local and instance (used only in a particular object, NOT all over the application) constants from 2 parts:
1. Constants group (like ORDER_STATUS or INV_STATUS);
2. Code name (like OPEN or CLOSED).
Divide them by two underscores (in contrast to one underscore dividing words inside of each part) by this pattern: CONSTANTS_GROUP__CODE_NAME.
• Helps code readers to distinguish between two the parts.
• Allows many constants with a same name to co-exist in a same scope, for example:
- Code: Select all
constant string ORDER_STATUS__OPEN = "OPN"
constant string ORDER_STATUS__CLOSED = "CLS"
constant string ORDER_STATUS__CANCELED = "CNCL"
constant string INV_STATUS__OPEN = "OPN"
constant string INV_STATUS__CLOSED = "CLS"
constant string INV_STATUS__CANCELED = "CNCL"
- Site Admin
- Posts: 111
- Joined: 19 Feb 2013, 20:33
Return to Elegant Code
Who is online
Users browsing this forum: No registered users and 2 guests