Solved

Why a Class for a Table

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This is about my first experience with programming Arduino.
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.

752 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