Solved

Why a Class for a Table

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now