Exercises in Programming Style–Abstract Things

NOTE : read the rest of the series, or check out the source code.

If you enjoy read­ing these exer­cises then please buy Crista’s book to sup­port her work.


Fol­low­ing on from the last post, we will look at the Abstract Things style today.


Style 13 – Abstract Things


  • Larg­er prob­lem is decom­posed into abstract things that make sense for the prob­lem domain
  • Each abstract thing is described by what oper­a­tions the things of that abstrac­tion can do
  • Con­crete things are then bound to the abstrac­tions
  • The rest of the appli­ca­tion uses the things not by what they are but by what they do in the abstract


First, let’s define our abstrac­tions:


Unfor­tu­nate­ly, after this point the imple­men­ta­tion are basi­cal­ly iden­ti­cal to the Things style (except the rel­e­vant mem­bers in each type is defined as part of the cor­re­spond­ing abstrac­tion rather than as a mem­ber of the type):

Style13_02 Style13_03 Style13_04 Style13_05

Final­ly, remem­ber we need to “use the things not by what they are but what they do in the abstract”, so call the Word­Fre­quen­cy­Con­troller via its abstrac­tion:



You can find the source code for this exer­cise here.