Channels ▼


Disentangling Concepts in Object-Oriented Systems

Source Code Accompanies This Article. Download It Now.

Stephen is a software engineer who works primarily in UNIX-based C++ for a medical-devices company. He can be contacted at

A class interface can be deceptively simple. Even though it may consist of only a few functions, those few functions may confound a number of distinct concepts. Consider, for instance, a class whose interface consists of only three functions: getStandingBlueBall(), getSittingRedDoor(), and getRunningYellowDog(). There are, in fact, three distinct concepts bound up in this interface: action (standing, sitting, or running), color (blue, red, or yellow), and object (ball, door, or dog). Although these three functions are named in accordance with their respective purposes, these single-token names do not clearly distinguish the three aforementioned concepts. Using object-oriented techniques, you can better "unpack" a class interface to distinguish the various concepts bound up in it. To illustrate these techniques, consider how best to implement the interface to a polar array class.

Overview of a Polar Array

A polar array is a representation of numeric measurements on a globe. Each measurement (altitude, for instance) is located at a unique intersection of a latitude and longitude. If a globe is subdivided into 8 latitudes and 8 longitudes, there are 8×8=64 unique measurements on the polar array, at each unique intersection of a latitude and longitude. In addition, there are measurements at the north and south poles. A set of arbitrary measurements on a globe with 8 latitudes and 8 longitudes might look something like Table 1.

You can also specify a location via a "great circle" coordinate. A great circle is a longitude that traverses the entire globe, rather than half of it. Imagine starting your traversal of the globe at the North Pole. Pick a longitude (such as #3). Follow the longitude south along the front of the globe until you reach the South Pole. Follow the longitude north along the backside of the globe. Technically, you are now traversing longitude #7 (in the geographic coordinate system). In the great circle coordinate system, you are still traversing the same longitude. Thus, the measurements on a globe with 8 latitudes and 8 longitudes are described by an 18-row-by-4-column matrix. A great circle representation of the globe just described would look like Table 2.

(North pole) 100
0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31
32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47
48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63
(South pole) 200

Table 1: Arbitrary measurements on a globe.

100 100 100 100
0 1 2 3
8 9 10 11
16 17 18 19
24 25 26 27
32 33 34 35
40 41 42 43
48 49 50 51
56 57 58 59
200 200 200 200
60 61 62 63
52 53 54 55
44 45 46 47
36 37 38 39
28 29 30 31
20 21 22 23
12 13 14 15
4 5 6 7

Table 2: A great circle representation of a globe.

To simplify the internal class implementation, the actual measurements on the globe will be represented by a vector of values, in which the geographic coordinates will be listed in row-major form first, followed by the values at the North and South Poles, respectively:

1 2 ... 63 64 100 200

That said, the requirements for a class representing a polar array are:

  • Accept a set of measurements at construction and store them.
  • Provide the measurement at a location specified by an absolute index coordinate.
  • Provide the measurement at a location specified by a geographic coordinate.
  • Provide the measure at a location specified by a great circle coordinate.

Now, consider a variety of approaches and refinements to the interface to such a class.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.