What Happens When Code Values Are Scattered Across the Source
Suppose someone asks you to add an "On Hold" order status. If status values are hardcoded, you have to update the dropdowns on the list, detail, and reporting screens one by one, find and change every branch that checks the status, then test and deploy. The change itself might take half a day. Once you fit it into a release window, it can easily take one to two weeks to reach production.
Systems like this tend to show the same symptoms:
The same "order status" field has different options, in a different order, on each screenComparisons like `if (status == "03")` are spread across dozens of places, and without a comment nobody knows what "03" meansFlag columns mix 'Y/N', '1/0', and 'T/F' from one table to the nextWhat Belongs in Common Codes and What Doesn't
Common codes: classification values such as order status, defect type, or return reason. They have a handful to a few dozen entries and simple attributesMaster data: customers, items, and equipment have many records and their own attributes (business registration numbers, specs, and so on). They belong in dedicated tablesCommon codes also come in two kinds:
System codes: business logic branches on these values. For example, inventory is deducted when an order reaches "Shipped." If an operator changes them freely, the logic breaks, so they are managed together with code changesDisplay codes: values such as inquiry types that are only used for classification and reporting. Operators can add these from an admin screenDesigning the Common Code Tables
The basic design has two levels, groups and codes:
Code group: group ID (`ORDER_STATUS`), name, description, system-code flagCode: group ID + code value (composite key), display name, sort order, active flag, valid-from and valid-to datesIf you number sort orders 10, 20, 30, you can insert a new entry between two others without renumbering the rest.
Hierarchical codes: model parent-child relationships, such as defect type → root cause, with a parent code column. Past three levels, consider a separate classification tableMultilingual labels: `name_ko` and `name_en` columns are enough for two languages. If more languages are coming, move labels into their own tableExtra attributes: attributes that differ by group, such as "customer at fault" for return reasons, go into extension columns like `attr1` through `attr5`. Record what each column means in the group definitionSafeguards for Code Changes
Deactivate instead of delete: if you delete a code that past orders still reference, their labels show up blank. If you only clear the active flag, the code drops out of input dropdowns while historical records still show their labels. This is why code lookups for input and for display are kept separateApproval and history: require approval for system code changes, and log the old and new values, the user who made the change, and when it happened, for every changeEnvironment sync: ship system codes with the application as migration scripts. For display codes, treat production as the source and pull them down to developmentUsing Codes in the Application
Caching: common codes rarely change, so cache them in server memory and invalidate the cache when someone saves on the admin screen. With multiple servers, also set a short expiry of about 5–10 minutesA shared dropdown component: if a component like `` takes only a group ID and handles the options, ordering, and language, screens stop drifting apartValidate branch codes against constants and the database: define values used in branching as constants such as `OrderStatus.SHIPPED`, and check at application startup that every one of them exists in the database. A missing value then shows up at startup instead of in production trafficThe POLYGLOTSOFT Approach
It is safer to clean up legacy code values in stages. As a maintenance (SM) improvement project, POLYGLOTSOFT recommends this sequence:
Survey the source and database to list every hardcoded value and code columnGroup codes that mean the same thing, and separate system codes from display codesBuild the common code tables and admin screen, then switch the dropdowns to the shared component firstMove branch codes into constants and add startup validationIf adding a single status value still means booking a release, it's time to review how you manage codes. POLYGLOTSOFT supports this work through our subscription development and maintenance services, from consolidating common codes in a live business system to building the admin screens. Tell us about your current system, and we'll work out the scope and order of the cleanup with you.