Solved

Object Model vs Data Model

Posted on 2014-07-29
11
553 Views
Last Modified: 2014-07-30
Hello All

I was hoping someone could explain Object Model vs Data Model to me on a simple level.  Here is a situation we are in.  I have an Access database that is linked to another program (ODBC connection) so that I can add/edit/delete data in the other program.  I was told the way I am doing this is the data model and that I should be connecting via an object model (sorry if I am using the terms wrong).

From what little research I did it looks as if the object model just does more data validation than the data model (and that the object model deals with business logic).  Could I actually be interacting with this other program like an object model because on my forms I include all the code that handles the business logic.

Once again I am sorry if I sound like an idiot by using the terms wrong but I be just a simple Access programmer.

Thanks
0
Comment
Question by:alevin16
  • 5
  • 4
11 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40227938
on a High Level the Data Model simply spells out the tables and the fields within those tables.

The object model is more about the object oriented side of things (eg: classes and what not).

So for example:

you might have a table called vehicles in your database.
Vehicles
   VehicleType (int)
   NumWheels (int)

The object model could have a base class:
Vehicle

with Car inheriting from Vehicle
and Truck also inheriting from Vehicle.

They might be implemented completely different, but still refer back to the vehicle table in data model.


I hope that helps.
0
 

Author Comment

by:alevin16
ID: 40227958
I like how you explained the data model in high level (it really helped!), but I have a question.  Would the VBA programming I did for the forms be the business logic?  I see how the Data Model would define a particular field as text but the VBA programming I did could restrict entry to be an email address (as an example), so would this be more like the Object Model?  

Sorry again for the confusion.  You really are helping me understand it! (I have to admit though that I really do NO Object Oriented Programming)

Thanks again!!
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 40227989
OOP (object oriented programming) can be a pain in the neck to get your head around, especially if you don't  do it.

Business logic is business logic . . . and that can be implemented in the object model or in the data model.

So going back to the vehicle example:
The business logic says for cars we want to ensure that you can only have 4 wheels.
For trucks it can be 4,8,12, or 18  (not accurate I'm just making it up, but that's my business logic).

I could do a trigger to implement that logic, and say delete data that doesn't meet that criteria
I could write those rules in the object model (eg: when I create my car class) to say that I only take 4 wheels.

So is the vba programming you did business logic?  It can be.  If you enforce rules that the users put on you then sure.

The VBA code I'm sure is also taking data from the fields and putting it in the database.  But that's not really business logic per say as it is more making everything wire up so that it works.

The object model is it's own stand alone thing.  Think about it. . . what is an email address?  It's a set of text that follows a set of rules.  (must have 1 or more characters, followed by an @ symbol, followed by more characters and then ending in a valid domain).

If you were to create a class that implements those rules, that would be the object model.   When I'm programming in classes I visualize that I'm creating a real thing (even though it's in cyber space).  I put myself in the middle of that thing and build it.  My "world" begins when the constructor is called, and I only "know" and care about whatever I want my thing to know and care about.  I keep it disconnected from the outside application.

When I'm done with the class I then use that class in my application, but the code for my class lives in the object model . . . and then I'm invoking (using) that class to do things that may or may not effect business logic.

More on classes here:
http://www.di-mgt.com.au/classes.html

No need to apologize about the confusion . . . it's confusing as anything!  I'm just glad the analogies are helping you understand it all.  Feel free to keep asking until you think you have a solid grasp.  <joke> Then don't worry when you lose all of the understanding again . . . it likes to go out for walks and then come back. </joke>
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:alevin16
ID: 40228006
WOW where were you a few years ago when I walked out of a class on this.  I could have used you!  This is becoming very clear and I am really happy you are putting up with my "stupid" questions.

Ok so let me ask you this.  I connect to that program (I mentioned before) via Access (ODBC) there are people working on another program and they are telling the boss that their program is superior because it uses the Object Model to access and work with the data.  They say their method keeps the data in that main program "pure" and "clean" as opposed to mine.  If I use VBA to restrict what data goes into a particular field am I not doing the same thing but just in a different place?  As you say you have everything in your class (which probably makes it a hell of a lot easier to fix when things go wrong) and I just have it all in the code of the form.

The boss is the kind of guy who gets suckered into new and shiny things.  I have no clue how this man makes his money (he is the owner and a multimillionaire).  

Thank you again!
Andy
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40228060
I hear you.

Yes you are essentially doing the same thing.  Again, whether the business rules are implemented in the "data layer" or "object layer" as long as they are implemented correctly at the end of the day it doesn't really matter.  (There are pros and cons for each).

I would first test the hell out of it and challenge them to break the form and insert bad data.

The only other caviat I would throw out there is if someone could bypass your VBA somehow . . . I know there were ways of compiling the project as an add-in or stand alone running app so that it would be less probably someone could do this.

If you have any other questions feel free to ask.  If not then good luck with your boss :-).
0
 

Author Comment

by:alevin16
ID: 40228105
Thank you thank you thank you!!!!  This was GREAT!
0
 

Author Comment

by:alevin16
ID: 40228152
I've requested that this question be closed as follows:

Accepted answer: 0 points for alevin16's comment #a40228105

for the following reason:

This was terrific!  The answers were explained in a way I could understand and he was extremely patient with my questions.  I cannot thank him enough!
0
 

Author Comment

by:alevin16
ID: 40228175
I am sorry about that.  I did not realize that.  Yes he is the one who should get the credit and the points
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40229247
Thanks all.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question