473,809 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

object oriented design

I am fairly new to oo design and I am looking at developing an object
oriented asp.net application which will be built on top of a relational
database. I have read quite a bit of the theory but find it hard to put it
into practice. In particular I am confused in terms of interacting with the
database. It seems to me classes map quite closely to database tables and I
end up with a bunch of methods in each class which simply call stored
procedures to do data access eg. AddOrder method in an Order class. In that
case oo design just seems like a wrapper on top of the database. I don't see
what is gained over just using procedural techniques to group related
functions together into modules. I am sure I am missing something.
Any pointers to get on the right track? Specific advice or samples of a
good design would be more appreciated that a pointer to a general book
(although if someone knows of something dealing with this specific problem
that would be great.)
--
Scott
Nov 19 '05 #1
4 1790
Scott,
I don't think you are missing anything. For simple systems your database
does map very closely to your objects and you do end up with a lot of code.
Some solutions to this are to use (a) a code generation tool (google search
CodeSmith) and (b) a professional O/R mapper (google search WilsonOR)

I love codesmith :)

Anyways, back to the topic..the benefit you gain with OO is more noticable
as your system grows complex. You'll see that your relational data doesn't
map so well to your object world (google search Object-Relational impedence
mismatch). A classic example is inheritance which brings forth tremendous
benefits that you can't get from a more procedural technique.

A solution might be to use a Data Mapper Design pattern
(http://www.martinfowler.com/eaaCatalog/dataMapper.html). This would leave
your classes as more pure domain objects and move the mundane and repetivie
mapping to its own layer/class. Great for even more flexibility.

If you aren't taking advantage of encapsulation, abstraction, inheritance
and polymorphism in your classes, ask yourself if you could..or think ahead
and see if they might be necessary with future requirements. Chances ar the
flexibility you've given yourself by this approach will pay off for itself
....even if it seems a little straightforward now..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"scottrm" <sc*****@newsgr oup.nospam> wrote in message
news:4A******** *************** ***********@mic rosoft.com...
I am fairly new to oo design and I am looking at developing an object
oriented asp.net application which will be built on top of a relational
database. I have read quite a bit of the theory but find it hard to put it
into practice. In particular I am confused in terms of interacting with the database. It seems to me classes map quite closely to database tables and I end up with a bunch of methods in each class which simply call stored
procedures to do data access eg. AddOrder method in an Order class. In that case oo design just seems like a wrapper on top of the database. I don't see what is gained over just using procedural techniques to group related
functions together into modules. I am sure I am missing something.
Any pointers to get on the right track? Specific advice or samples of a
good design would be more appreciated that a pointer to a general book
(although if someone knows of something dealing with this specific problem
that would be great.)
--
Scott

Nov 19 '05 #2
Although it is quite hard to learn initially, Enterprise Core Objects from
Borland is an excellent tool.

You design the model in UML, it generates the DB for you, and you work only
with objects (never the db).

My website howtodothings.c om was written with it, and I don't have a single
SQL statement in the whole project.

--
Pete
====
Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/
Nov 19 '05 #3
Hi Scott,

Well, it sounds like you're on the right track, believe it or not. You have
to look at the evloution of programming to understand it more clearly.

In the beginning (almost), code was simply instructions that were executed
in the order in which they appeared in the source. It was soon discovered,
however, that certain blocks of code were commonly executed again and again.
This was initially solved with GoTo statements, which instructed the
compiler to go to a certain location in the code, execute the instructions
there, and return to the point it left from. And this lasted a while.

As the size and complexity of programs grew, GoTo statements made for some
serious spaghetti code, which became hard to maintain and modify. The
concept of more ordered source code, using functions and sub-procedures was
introduced to make code easier to manage.

Of course, this convenience only lasted awhile, as programs grew more in
complexity, and multi-tasking operating systems were introduced. Believe it
or not, Windows 3.1 was written in C, not C++. It used a heck of a lot of
loops and nested loops to do multi-tasking, messaging, and so on. You can
imagine the difficulty in maintaining such a huge program, which was made up
essentially of a single set of instructions that was immense in size.

At this point, due to the complexity of programs, new data types were
introduced called "structures ." A structure is simply a combination of
multiple data and types of data into a single unit. It made code
organization easier, and a structure could hold both State and Process. In
other words, a member of a structure could be a piece of data, such as an
integer, or it could be a process, such as a function. Are we starting to
sound a little familiar at this point? We should be.

Enter Object-Oriented programming. Structures evolved into
objects/types/classes. OOP enhanced the structure concept, and added a few
of its own:

Inheritance: Inheritance performs much the same function as functions and
sub-procedures in terms of what its purpose is. By defining a base class,
and inheriting it, one could build multiple classes that shared some of the
same state and process, but with additional characteristics as well. In
addition, the developer doesn't have to re-write the same code to create a
new class. The code in a class is relatively lean, as much of the code
resides in the base class. This makes code maintenance and debugging much
easier.

Encapsulation: OOP introduced the idea of hiding members of a class in a
variety of ways. By doing so, the possible errors that could occur were
minimized. Only the members necessary to access fro outside the class are
exposed. There is no way that something outside the class can modify
something that it should not. This also enhances code maintenance and
debugging, by reducing the number of variables that can affect performance
of the app.

Polymorphism: Plolymorphism was actually introduced in earlier procedural
languages, with the concept of overloaded functions, by defining a function
as accepting different data types, and behaving differently when using them.
Classes extend the concept with overrides and other similar mechanisms that
allow a class to behave differently in different circumstances.

Abstraction: A little harder to define. Abstraction is an outgrowth of
encapsulation, in a sense. By hiding the details of how an object performs
its tasks, other objects can treat the class as if it were a "machine" that
performs some task, rather than a set of instructions. This also simplifies
code creation and maintenance.

All of this has come about as a result of computer and software evolution.
Just as Assembler language was developed to reduce the amount of time
necessary to write an application in machine code, each evolutionary stage
of programming technology is designed to reduce the amount of time and
resources necessary to write, debug, and maintain software.

The better your object model, the easier and quicker you can write
applications with it. If you're wise, you will create re-usable classes that
will continually reduce the amount of time and effort spent in future
development.

So, in conclusion, what is gained by OOP is the same thing that is gained
with "just using procedural techniques to group related functions together
into modules." It is simply the next stage in the evloution of programming.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"scottrm" <sc*****@newsgr oup.nospam> wrote in message
news:4A******** *************** ***********@mic rosoft.com...
I am fairly new to oo design and I am looking at developing an object
oriented asp.net application which will be built on top of a relational
database. I have read quite a bit of the theory but find it hard to put it
into practice. In particular I am confused in terms of interacting with
the
database. It seems to me classes map quite closely to database tables and
I
end up with a bunch of methods in each class which simply call stored
procedures to do data access eg. AddOrder method in an Order class. In
that
case oo design just seems like a wrapper on top of the database. I don't
see
what is gained over just using procedural techniques to group related
functions together into modules. I am sure I am missing something.
Any pointers to get on the right track? Specific advice or samples of a
good design would be more appreciated that a pointer to a general book
(although if someone knows of something dealing with this specific problem
that would be great.)
--
Scott

Nov 19 '05 #4
Hi Scott,

On top of what's been said, the fact that your db classes are just
wrappers for the db allows for a very academic N-Tiers architecture.
Down the road, N-Tiers is (are?) safer and less error-prone.

PS : and if you read Kevin's answer, you'll see that oo teaches you to
be both synthetic and crystal-clear. Nice piece, Kevin.

HTH,

Michel

"=?Utf-8?B?c2NvdHRybQ= =?=" <sc*****@newsgr oup.nospam> wrote in message news:<4A******* *************** ************@mi crosoft.com>...
I am fairly new to oo design and I am looking at developing an object
oriented asp.net application which will be built on top of a relational
database. I have read quite a bit of the theory but find it hard to put it
into practice. In particular I am confused in terms of interacting with the
database. It seems to me classes map quite closely to database tables and I
end up with a bunch of methods in each class which simply call stored
procedures to do data access eg. AddOrder method in an Order class. In that
case oo design just seems like a wrapper on top of the database. I don't see
what is gained over just using procedural techniques to group related
functions together into modules. I am sure I am missing something.
Any pointers to get on the right track? Specific advice or samples of a
good design would be more appreciated that a pointer to a general book
(although if someone knows of something dealing with this specific problem
that would be great.)

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3477
by: ggg | last post by:
I'm looking for a complete project/application done with heavy use of of object-oriented programming & design. Preferably something well documented and/or commented so that I can pick it apart and learn how/why they designed it they way they did. Any suggestions?
1
2185
by: Robert Hathaway | last post by:
COMP.OBJECT FAQ Version II Beta now Available http://www.objectfaq.com/oofaq2 ================================================== - Latest Important Information on Object Technology - What's New Page - What professionals *must keep up on* in rapidly changing environment - Available on Homepage, email notification on updates now available - Good Resource Site - Latest in Object Technology - Complete Coverage of Object Orientation - Up to...
5
2930
by: Martin | last post by:
When was inheritance intruduced into object oriented programming? More generally, does anyone know or have any sources on when the different features were introduced into object oriented programming?
34
7120
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. Yensao
11
9283
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
8
2389
by: Dale | last post by:
I've searched Amazon and read probably 100 reviews but can't find what seems to be any book that is widely accepted as the definitive book on object oriented programming design and techniques. And most of the highest rated are all written 10 to 15 years ago. Any good suggestions?
2
1723
by: Chris Asaipillai | last post by:
Hi there Im starting a new course this Saturday. OBJECT ORIENTED DEVELOPMENT WITH VISUAL BASIC .NET and will cover the following concepts and principles. a.. Be able to build VB.NET applications using custom object design. b.. Utilise existing .NET Framework objects and extending functionality. c.. Become familiar with how to utilise the IDE to help OOP.
46
3038
by: ajba74 | last post by:
Hi fellows, I am reading some books to learn the C programming language, and sometimes I have the feeling that when somebody becomes a C expert, he must learn a more modern and object-oriented language. When I read things like "... C++ is an evolution of C ..." or "... C is a subset of C++ ..." I tend to believe that I will have to learn C+ + sooner or later. It sounds like C++ is the future and C is the past (and will be no longer...
5
1483
by: virtualadepts | last post by:
I have code here that explains my object oriented design model. I've been reading about other design models from what is documented on wikipedia about the key book on the subject: http://en.wikipedia.org/wiki/Design_patterns All of the models look fun and interesting but they are very specialized. I find myself writing bloated C++ code anyway, and not finding a way to use the basic design models. So I've invented my own. I call it...
0
9602
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.