Solved

Why a Class for a Table

Posted on 2014-02-16
3
51 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: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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hive vs Impla in Hadoop 1 73
Amazon S3 Images with .Net 3 30
Updating a single record in forEach using C#/Entity 7 23
How to fix  socket closed error 11 25
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

735 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