Solved

Why a Class for a Table

Posted on 2014-02-16
3
54 Views
Last Modified: 2016-06-17
Hi,

I hope that I can convey what I want.
At first, I know what is Class and Object. Also, I work with C#.

In OOD, almost Classes example is Person, Account ...etc. These are the same as the tables in the database!. In DB, you use CRUD.

So, why to create a complete class?.

Regards
0
Comment
Question by:Abdurahman Almatrodi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
ID: 39863750
First of all, it is easier to work with a class that with a table. The constructor or internal methods handle all the database connections, so once it is done in the class, you do not need to deal with them in the application.

Then, if you ever change the database, say, moving from Access to SQL Server, you simply make the necessary changes in the class. You do not need to touch the application. This is particularly interesting when the class is used in many applications, which often happens with database applications.

Also, in a class, you can add code for validation and transformation that does a lot more than what you can do in a table design or in SQL. Also, if you perform these operations in SQL, the same validation might need to be made in many stored procedures, while in the class, it is mane in only one place.

In development environments where a lot of programmers are involved, it might also help you isolate the database from less knowledgeable programmers. The senior programmers write the class and have access to the database. The junior programmers never see the database and need to go through the class to save information. It might insure better database integrity from programmers who are less experienced.
0
 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 250 total points
ID: 39863761
Object modelling is used to identify the objects required in the problem definition, these objects then will usually become your main tables in the database, in the same respect the classes represent the same objects in code.

Representing the object in code and then using the objects rather than retrieving a set of records from a database  is the basis of object-orientated approach.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

626 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