Saturday, November 2, 2013

data and object modeling using the real world

Recently we were working on creating object and data models for a various number of scenarios, including Auction, Magic Eight Ball, and Taxi Meters.  It was an interesting exercise, all using pseudo code, that got us thinking about how to set up models, attributes, actions, and how the models interacted with each other.  I'd like to take a second and review the Taxi Meter example because I found it particularly exciting.

Having walked through the various functions with my partner and come up with a very nice simple model and methods, I was looking at what we had, which looked something like this...


class Taxi Meter

  attributes: fare, extras, dollar_increment, time_increment

  #initialize(base, dollar_increment, time_increment)
  #start()
  #stop()
  #reset() 

... and what what I would describe as a little mini-epiphany. What I was looking at was basically a translation for the actual, real world object!


The attributes were what you could see (mostly) and the methods were the buttons.  Simple.  It was pretty cool seeing the direct connection between the model and the object and I will try to use this as a strategy of mine going forward.

No comments:

Post a Comment