Re: OOP/OOD Philosophy
- From: "Nick Malik [Microsoft]" <nickmalik@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 10 Jul 2005 13:17:41 -0700
Finally... We get to the crux of the matter... what does it mean to isolate
one from another?
You appear to assume that, in order to isolate the database from the gui,
that you have to abandon data bound controls.
I would challenge that assumption by asking you to look at the definitions a
little different.
In general, let's say that layers are bound to each other across interfaces.
In other words, the GUI layer uses a specific interface of the business
objects layer. Therefore, when data is transferred across these boundaries,
the specification of that data is included in the specification of the
interface.
You appear to be happy with using automated components that will actively
adapt to changes in the contents of the data view. I agree with this
notion. As much as possible, and where data transactional efficiency is not
a problem (as in the case of a CRUD interface), this is a good idea.
I'd like to point out that, in this case, the specification of data
interaction did not change even when the number of columns did, because the
interface will handle ANY and ALL fields, not just specific fields.
The problem for maintenance comes when you need to make exceptions to the
basic rules of "user knows best" to do things like restrict a single column
to a preset list of values, or to validate that a particular field, present
in the data structure, should not appear in a grid along with the rest of
the columns.
This is where you need to place logic against the data structure that
doesn't just apply to ALL fields. This is where headaches start.
I am hoping to encourage caution about this kind of binding. If changing
the name of a column in a database causes your code to break, because your
code was looking for that column name to exclude from a grid, and the column
is 500 bytes wide, and now the grid scrolls wildly, and the user won't be
happy, then it is fair to say that you have not isolated the db change from
the front end. This is because the name of the database column appears in
the front end code, potentially in many places, in order to perform this
very specific exclusion.
On the other hand, if your data layer always _maps_ a database column name
to a gui-friendly name that allows the db field name to change
independently, then you can continue to use a data-bound control without
fear that these exceptions can cause additional cost.
There is a little known feature of the Microsoft .Net framework that does
this for data sets. If you use the Visual Studio wizard to build a data
adapter, and then take a look at the code that was generated, you'll see the
use of the DataTableMapping object that allows for this level of
indirection, while still allowing you to use the data bound controls for
front-end mechanisms. I do not know if you use Microsoft .Net for writing
code, and I'm not trying to convince you to do so. However, it may be
interesting to take a look at the following topic in the documentation to
see how it works:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbcontablemappingindataadapters.asp
This keeps with the notion of independence between the database and the
front end while still allowing the use of automated tools that interpret the
data structure in a consistent manner for the creation of automated GUIs.
Also, another little known features of the .Net platform is that you can
create your middleware objects, and then bind the data controls directly to
them, giving you the ability to code your business rules directly to your
own objects, and then handle persistence downstream independently. These
are patterns that not often used, because their structural benefits are not
well understood by the majority of developers. However, they have the real
ability to make maintenance more efficient.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
.
- Follow-Ups:
- Re: OOP/OOD Philosophy
- From: frebe
- Re: OOP/OOD Philosophy
- References:
- Re: OOP/OOD Philosophy
- From: Nick Malik [Microsoft]
- Re: OOP/OOD Philosophy
- From: topmind
- Re: OOP/OOD Philosophy
- From: Robert C . Martin
- Re: OOP/OOD Philosophy
- From: Shane Mingins
- Re: OOP/OOD Philosophy
- From: frebe
- Re: OOP/OOD Philosophy
- From: Robert C . Martin
- Re: OOP/OOD Philosophy
- From: frebe
- Re: OOP/OOD Philosophy
- Prev by Date: Re: OOP/OOD Philosophy
- Next by Date: Re: OOP/OOD Philosophy
- Previous by thread: Re: OOP/OOD Philosophy
- Next by thread: Re: OOP/OOD Philosophy
- Index(es):
Relevant Pages
|