Crud Field Object

Often, screen or report (CrudScreen) fields have information that needs to be used in multiple spots. For example, the fields may be referenced on the input screen, rendering report headers, rendering report data, and when referencing the database columns. See DataDictionary for examples of typical attributes of such objects.

Although I prefer a DataDictionary (partly because of their compact and customizable view-ability), the existing tools and fad pressures don't support them very well. An alternative is a CrudFieldObject. (You can use associative arrays also, one per field, instead of actual objects.)

Typical attributes are listed under DataDictionary, but usually include at least field name, title, and type.

Without a DataDictionary or CrudFieldObject, info about fields will often be spread over multiple places in the code. If you add or remove a field, you have to visit multiple code areas.

One semi-tricky part is iterating over a list of CrudFieldObjects. Sometimes, you want to exclude some or have extra ones in different places. "Blind" iteration won't have this ability. One approach is to have a list such as:

  renderReportColumnHeadings(thisReport, fieldList, 'name, rank, serial_number, 
     IQ, salary, etc');
However, this may require a bit of parsing. But it is more compact and better OnceAndOnlyOnce than something like:

  thisReport.renderReportColumnHeading(fieldList.name);
  thisReport.renderReportColumnHeading(fieldList.rank);
  thisReport.renderReportColumnHeading(fieldList.serial_number);
  thisReport.renderReportColumnHeading(fieldList.ID);
  thisReport.renderReportColumnHeading(fieldList.salary);
  thisReport.renderReportColumnHeading(fieldList.etc);
The best approach often depends on the language being used.

-- top


CategoryBusinessDomain, CategoryUserInterface


EditText of this page (last edited November 6, 2012) or FindPage with title or text search