Solved

Why a Class for a Table

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help Required 2 32
Query Syntax 17 34
VB.Net - MemoryMappedFiles - Confirm receipt 2 19
Convert datetime to time string 10 21
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

773 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