Objects, Data, and Actions

Objects, Data, and Actions

by blamoreaux 15. August 2007 09:08

I was recently asked what objects are in programming and how a database is related to them. Thinking long and hard about it, I came up with the following example:

Objects are containers that stores data and code. In fact objects are just like real life objects. Imagine an Animal object. Pick any animal you like, it will have Data and Actions. The data would be things like Height, Length, Age, Name, Color. And Actions could be Speak, Walk, Jump, Eat.

So a Lion could be:

MyLion.Height = 4

MyLion.Length = 7

MyLion.Age = 4

MyLion.Name = Mufasa

MyLion.Color = Yellow and Brown

Notice how these values can easily be stored in a database. But what about the actions? When MyLion performs an action, something gets done.

MyLion.Speak -> from my speakers I hear a  "ROAR!!!!"

MyLion.Eat ->  Now MyLion.Length = 7.5

See how actions can't really be stored as a value because they do something. A relational database can store all of my Properties but can't store what will happen when my object performs an action. But an OODB database can store objects. So I could save MyLion right to the database. I could also save MyChicken and MyHippo. Each object would do something a little different when I ask it to Speak or Eat.

Hope this helps.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag




Live preview

November 20. 2008 00:44

Gravatar

Powered by BlogEngine.NET 1.1.0.7
Theme by Mads Kristensen

Subscribe

About the author

Brig Lamoraeux Brig Lamoreaux
I'm a .Net developer.

E-mail me Send mail

Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

Pages

Recent posts

Recent comments

Tags

Categories


Archive

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2006-2008

Sign in