Re: Having difficulty refactoring a DB application
From: Topmind (topmind_at_technologist.com)
Date: 10/10/04
- Next message: Topmind: "Re: Having difficulty refactoring a DB application"
- Previous message: H. S. Lahman: "Re: How to assign responsibility to class, not objects"
- In reply to: U-CDK_CHARLES\\Charles: "Having difficulty refactoring a DB application"
- Next in thread: Robert C. Martin: "Re: Having difficulty refactoring a DB application"
- Reply: Robert C. Martin: "Re: Having difficulty refactoring a DB application"
- Reply: Universe: "Re: Having difficulty refactoring a DB application"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 10 Oct 2004 10:28:18 -0700
Why change it then? Don't let OO zealots mess up a working
data-centric
application. Databases and SQL are NOT evil. Nobody has proven them
evil.
RDBMS and OO will never get along because they have fundimental
differences in philosophy.
1. Declarative Vs. Imperative Interfaces - Relational thinking tends
to use data as interfaces, not behavior as interfaces. It thus has a
declarative tilt in design philosophy in contrast to OO's behavioral
tilt. (However, some relational proponents may perhaps propose going
hog-wild with triggers, etc. to provide complex behavior, but I have
not met any here.)
2. Schema Bound - Objects don't have to follow a "parent schema" as
far as which attributes or accessors an object has while table rows
must follow the entity's schema. However "dynamical relational" theory
may also provide this, although it does not exist in practice yet.
Still, a given row must belong to one and only one entity. The closest
thing in OO is inheritance, but it is generally tree-shaped and
optional.
3. Access Rules - In relational, attributes are accessed and altered
through predefined relational operators, while OO allows each class to
create it's own state alteration interface and practices. The
"self-handling noun" viewpoint of OO gives independence to each object
that relational does not permit. This boils down to a "standards
versus local freedom" debate. OO tends to argue that relational
standards limit expressiveness, while relational proponents suggest
the rule adherence allows more abstract math-like reasoning,
integrity, and design consistency. My view is that OO fails to factor
common "database verbs" to one spot, instead letting each class
reinvent them from scratch and clutter up an interface (getX, searchX,
deleteX etc. where X is every class), and this is a gross violation of
"once and only once" (poor interface factoring) and bad abstraction.
4. Uniqueness Observation - Row identities (keys) generally have a
text-representable form, but objects don't require an
externally-viewable unique identifier.
5. Normalization - Relational normalization practices are often
ignored by OO designs. However, this may just be a bad habit instead
of a native feature of OO.
-T-
oop.ismad.com
----------------original message-----------------
> List:
>
> Apologies if this is a repeat.
>
> My current project is a mess of close-coupling. I have sensible classes
> that work for my "business model objects"
>
> I have a sensible database definition that more or less works for the
> application. We're still refining certain aspects of it, but it's more
> or less set.
>
> The problem as I see it is that I've SQL statements scattered
> willy-nilly throughout the application.
>
> Seems to me an object should be responsible for its own creation,
> destruction and assignment.
>
> I've come up with two possible solutions to this.
>
> The first is to make the business objects aware of the associated stored
> methods. The problem with this is that should the underlying methods
> change, the classes will have to change to account for that.
>
> The second is to put in an adapter class that knows how to access the
> database.
>
> Much of the difficulty for me is reconciling SQL's idea of a "record
> set" with well-formed well-behaved objects. Some querys returns more
> than one record, and others return records in different form, ill-formed
> or partial objects. Some of this could be massaged, but I'm not certain
> about proven methods for doing this.
>
> Any other ideas about how to structure this aside from the two I've
> stated?
>
> Any relavant patterns, either in GoF or other references that apply to
> this situation?
>
> Thanx
>
>
> Charles
- Next message: Topmind: "Re: Having difficulty refactoring a DB application"
- Previous message: H. S. Lahman: "Re: How to assign responsibility to class, not objects"
- In reply to: U-CDK_CHARLES\\Charles: "Having difficulty refactoring a DB application"
- Next in thread: Robert C. Martin: "Re: Having difficulty refactoring a DB application"
- Reply: Robert C. Martin: "Re: Having difficulty refactoring a DB application"
- Reply: Universe: "Re: Having difficulty refactoring a DB application"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|