Not All Object Properties Are Created Equal (Part II: Says Who!?)
Join the DZone community and get the full member experience.Join For Free
it is said that
beauty is in the eye of the beholder
. if one were developing a data model for
there are various properties that might be attached. unlike some other
properties, it might be more self-evident that a property like
would be problematic because it begs the question
. there is a relationship between a particular
and a particular
, in which an
property would be more appropriately placed. it may even be a many-to-many relationship with multiple values of
coming from multiple beholders as in a beauty pageant panel of judges.
or, as in the case study below, the credit grade of a banking customer
is actually several grades, coming from different bankers and algorithms
over the life of the business relationship, and international banking
regulations now mandate their tracking and optimization.
of the many subcategories of properties that philosophers have come up with, an important pair are what john locke named primary and secondary properties ( aka qualities ). the distinction between them being that primary properties are those that are “objective” and “in the object”, while secondary properties are “subjective” and “in the mind of the perceiver”. primary properties of an apple would be its mass, shape, size, etc. secondary properties would be its color, taste, smell, etc.
that apple isn't really red??color is a classic case in point because it seems that color might be objective. there are surely some collection of wavelengths of light reflected off an apple that could be classifiable as “red”. alas, there are mountains of evidence that color perception depends on the person and the external conditions .
a famous mountain of evidence ( sorry, pun intended ) is ayer’s rock (aka uluru) in australia which attracts thousands of tourists to see it dramatically change colors right before their eyes. over the minutes of sunset or sunrise, “the color” ranges thru black, red, pink, orange, brown, etc.
in the rain it even turns blue and purple...
so, the mountain can’t really have a simple “color” property with a simple single value.
again, as with essential properties , how is this primary/secondary distinction supposed to make me develop differently than i do now?
- model clarity : keeping the properties of an entity or class limited to primary qualities helps to insure that your data model will match data models developed by others. you will be more likely to agree on what the properties are in the first place, and, on what data type best represents that property (see stronger types below).
- better normalization : your entity database tables are normalized when limiting to primary properties because those truly are properties of that entity. by recognizing and removing secondary properties, you won’t be mixing in columns that are really a flattened relationship with some other beholder entity.
- better keys : when deciding which properties of an entity are candidates for being part of it’s “key” or “identifier”, it definitely helps to verify they are really objective properties of the entity. otherwise, they are based on some external beholder & conditions that can change over time, even though the entity itself didn’t change! a drivers license search will fail if a witness’ notion of a suspect’s hair-color doesn’t match the dmv’s notion of that hair-color.
- data provenance : realizing that each value of a secondary property begs the question “says who?”, you need to identify the authority that provided each value for that property. as you can see, there could be anything from a one-to-one to a many-to-many relationship between the original class and the various authorities providing data values. if the answer is “all values of this property come from a single source x”, then that need merely be noted in the documentation. at the other end of the spectrum, there may need to be a sophisticated sub-model just to keep track of the source and circumstances of each of the several values that property could take on for a single object! (see the basel ii banking case study below).
- stronger types : authorities providing data values for secondary properties, usually define entire “types” rather than just values from some universal type. for example, authorities specifying colors usually limit them to a custom collection of colors (i.e. a palette ), or even collections of palettes. ralph lauren defines many palettes of colors, most with one or more “reds”, but none of them are the same as the “red” of a 1964 ford mustang which comes from the small palette of factory colors from ford for that year. if you need the simplicity of a single universal “red” value then you are looking at defining mappings from one palette to another. car salesmen do this mapping intuitively by showing you a "cypress pearl"infiniti when you ask to see either "black" cars, or "green" cars. do you need that sort of detailed modeling? you do if you are trying to make it easy for customers to find what they want (see the fabric.com case study below).
|ralph lauren palette|
case study: basel ii banking accord
one of the fundamental practices of banks is to keep a certain amount of money in reserve. when taking customer deposits in, and loaning it out to make a profit from the interest charged, there is a danger if all the deposits are handed out as loans. so, a reserve must be kept, but, there is a conflict between larger reserves for more safety and smaller reserves for more profit. because banks have erred on the side of more profit, over the past several years international banking regulations have added requirements that the amount of reserve be calculated on a more scientific basis, and be optimized over time.
one of the major criteria in determining how much reserve is required, is to base it on the quality of the customers that the bank lends money to, as measured by their credit grades. a credit grade is really just a prediction of how likely a borrower is to pay back a loan, and how much they would leave unpaid if they did default on a loan.
the regulators recognized ( though maybe not in these philosophical terms ) that “credit grade” is not a primary property of a customer; it is a secondary property based on the grader and the procedure or algorithm used . the basel ii banking accord specified that simply keeping track of customer credit grades was not enough. banks needed to start keeping track of “says who?” and “what did they base it on?”. with this data, it can be verified after the fact which of these predictions of future default panned out. this enables evolving better algorithms and weeding out graders and methods that were not very good.
case study: fabric.com
in the early days of marketing on the web, the start-up fabric.com (since bought by amazon) was building a web store to sell clearance fabrics and apparel. like all online retailers, there is the problem of making it easy for the customer to find the products they want. a common approach is to build a web site with a left-column navigation bar containing filter-by-property controls. this works fine for primary properties, but is more of a problem for secondary properties.
alas, if one doesn’t know that there is a difference, one builds all of the filters in the same manner. for fabrics, filtering by the dimensions of the piece being sold is straightforward and effective because it is a primary property. for color however, there are problems because it is a secondary property, and hence opinions differ on how to describe the color.
look, even though the “color” of a fabric may be in the eye of the beholder, it is an objective fact that the manufacturer described the color as x, right?. how about we use that since we have to pick something? well, two big problems:
- all those colorful color descriptions cause an overly large list of colors in the color filter, plus related colors are spread all thru the list ( e.g. avocado, green, lime, olive, etc )
- when the customer searches for “green” she doesn’t find all those fabrics with the color described as “lime”.okay, fine, we are going to have to go to the trouble of mapping each item to a simple set of colors that we pick. so, mr. programmer, go set up a set of simple colors in the database so that we can pick the color when we enter these items into inventory. well, one other big problem:
- while everyone is entitled to their own opinion, some opinions are worth more than others. the programmers did not have the industry experience needed to pick an appropriate set of colors. it was the brick and mortar fabric sellers that knew things like “stripe is a color”! so, it took someone who had experience with what buyers actually ask for to know that along with “green” in the color list, also needed was “green and white stripe” but not the manufacturer’s description “lime and white stripe”. they also knew that, in addition to simple color families like yellow and brown, subtle categories like "gold, “beige”, and “cream” were needed (and in fact the last two combined into a single category). on the other hand the green family did not need to be augmented by “lime” and "avocado".
Published at DZone with permission of Bruce Wallace. See the original article here.
Opinions expressed by DZone contributors are their own.