Re: OOP and databases in the real-world

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



First, the OOP methodology for working with a database varies greatly. A
database is simply a storage mechanism for any kind of data. The OOP
solution to working with the data is dependent entirely upon the usage of
the data and the business requirements involved.

IOW, there is no one OOP methodology for working with databases, any more
than there is one OOP methodology for working with files, or one OOP
methodology for working with any other form of data, stored or otherwise.

OOP is actually less of a methodoloy than a paradigm. It is a way of working
with and thinking about programming, with a number of extensions to
procedural programming that aid in the organization and usage of the code.
It is important to remember that all programming is procedural at heart,
including OOP. OOP is no more an academic exercise than high-level
programming languages are an academic exercise compared to pure machine
language.

OOP is a continuation of a series of derived principles that began with
Assembler language, continued to high-level languages, and is similar to the
use of functions, procedures, and structures in high-level programming
languages like C. It is a set of tools that facilitates the creation,
debugging, and maintenance of increasingly large and complex applications.

It is an abstraction of abstractions. Once you train yourself to think in an
object-oriented way, its power is apparent, and its usage becomes intuitive.
The hard part is re-training the way you think about programming in general.
As someone who started out doing procedural programming with C, I can
certainly understand the difficulty involved in making this change in one's
programming paradigm. It is similar in many ways to the change in paradigm
involved in understanding the mathematics of Calculus, or vector-based
graphics versus raster-based graphics. But it is well worth the time and
effort involved, as it leads to an exponential increase in one's programming
power. At least IMHO!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"Fred Exley" <fexley221@xxxxxxx> wrote in message
news:127jkhf56mvps43@xxxxxxxxxxxxxxxxxxxxx
I have a traditional application using a database and procedural code that
works fine. I'm re-writing it using the OOP methodology, just to see how
this may be the better way to do things. I think I've got a pretty good
grasp of the three pillars of OOP, and have objects properly defined using
inheritance, encapsulation, etc. as appropriate. Now it's time to do some
processing using real data, and the data resides on a relational database.

As best I can gather, the preferred OO way to do this in general is to:

Write a utility routine to load the data from the database into their
respective objects.

For tables in the database with a master/detail relationship (i.e., Order,
Order Items tables), represent this in OOP by creating another class, an
intersect object, that relates one Order with one Order Item instance.

Create yet another class, to be used as a container for these intersect
object items, using an ArrayList (to make use of that objects built-in
methods; insert, update, enumerate, etc.).

At this point, the actual data processing can begin. Create procedures
that solely operate on the objects we created, making use of the built-in
methods these objects provide, and writing our own methods as necessary.

When all the procedures are complete for whatever we're trying to do, use
another utility routine to write the resulting data transformations back
to the relational database we started with.

Is this about right? If so, doing it this way, what real-world advantages
do we now have using the OO methodology? Is all this added overhead
really worth it? The best scenario I can imagine is that maybe, once
we've set everything up in an OO model, the procedures that actually
process that data will be a fraction of the amount of procedural code
required to simply process against the database directly. In other words,
is OOP really the better way to go in real-world, production business
applications, or is it mainly a nice academic exercise? thanks

-Fred





.



Relevant Pages

  • Re: Creating your own software?
    ... IF you can find it, a decent Java package. ... Excellent database oriented programming package. ... towards OOP and classes, but it much easier to learn/use than VC++. ...
    (microsoft.public.windowsxp.general)
  • Re: Can a low-level programmer learn OOP?
    ... I have also found some articles profoundly critical of OOP. ... If it does, you'll find it easier, else choose another programming style. ... Starting in 1999 I got back into programming, but the high-level-ness of PC programming and the completely foreign language of OOP repelled me. ... Dynamic languages like Smalltalk, Python or Ruby are much more lightweight in this area, and tend to favor a much more exploratory style - sketch a quick draft on a napkin, start coding, and evolve the design while you're coding. ...
    (comp.lang.python)
  • Re: polymorphism (was: Poly Couples)
    ... but this is not really "business software"... ... Most of such applications are built as a combination of ... database with flat files or a different RDBMS vendor?" ... couldn't care less if I do it in using structured programming or OOP ...
    (comp.object)
  • Re: teaching a child - console or GUI
    ... > I don't agree that this is substantively different from natural languages. ... > The evolution of natural language follows similar paths. ... Popular TV shows have the biggest influence on programming languages? ... I think there is a good argument to made for OOP actually simplifying ...
    (comp.lang.pascal.delphi.misc)
  • Re: teaching a child - console or GUI
    ... >> level OOP programming etc). ... >> languages. ... > a world view that is centered on strict procedural programming. ... > few preconceived notions about the sequentiallity of computers. ...
    (comp.lang.pascal.delphi.misc)