"David Browne" <davidbaxterbrowne no potted (e-mail address removed)> a écrit dans
le message de news: (e-mail address removed)...
| Never said it was. Just that the partial class DataSet implementation
| allows you to overlay a buniess object design over the DataSet storage.
And that is one of the problems. A class should be a description of data and
related behaviour. It should have clearly defined boundaries and, even more
so, responsibilities.
Responsibility Driven Design is a very powerful technique that ensures that
every class does exactly what it should do, no more, no less. It is not the
responsibility of a Customer or an Invoice to know about dataset behaviour,
but purely the attributes and behaviour of being a Customer.
| No a DataSet is a set of sets. A DataRow stores the data for a single
| entity, a DataTable stores the data for a collection of entities, and a
| DataSet stores the data for one or more related collections of entities.
Sorry, Delphi datasets are single table entities, I still haven't made the
mental switch
)
| Um, what is OO if not a "computerified abstraction"? OO is a modeling
| technology. Relation Databases are a modeling technology. We're just
| talking about how to make them work together.
Ah yes, but relational theory, foreign keys, referential integrity, etc are
all much more "computerified" than stating properties like Name, Address,
Amount, etc as being attributes of an entity and Move(), Collide(), etc
being models of real world behaviour.
| Agreed. In the model I propose a customer would be modeled by an
interface,
| ICustomer. An ICustomer implementation might store its data in a DataRow,
| or in some fields, or in an XML document or some sort of BLOB. But it has
| all the right data and methods for a customer object, and client code need
| not know anything about the actual data storage.
FMPOV, separating implementation from interface does not necessarily mean
that implementation should have knowledge beyond the responsibilities
expected of the interface.
In the perfect world, we would not need databases, we should be able to have
a version of Windows (or other) operating system that allows us to just
create objects and keep them alive without having to store them to disk just
in case the power gets switched off.
In such a world, the idea of storage would only extend to keeping objects in
lists; there would be no need to translate from properties of classes to
fields of tables.
The only reason we need datasets, tables, fields, foreign keys, referential
integrity constrints, stored procedures, views, etc is because we had to
devise a mechanism for preventing data loss when the power get switched off.
My argument, and that of many other OO gurus, is that storage/retrieval
functionality is something optional and only needs implementing in this
imperfect world of interruptible power supply. Given that it *does* need
implementing, let's keep that functionality separate from the business
object world, thus allowing us to change, improve or update the technology
that is used to implement the storage of those objects.
Partial classes certainly have their place, although I remain to be
convinced of their likely pervasiveness. Certainly, they seem like a good
idea for form design, where they allow the IDE to maintain the visual side
of the form's design whilst allowing the developer to work in an uncluttered
part of the form class for other logic.
However, I do not believe that dividing a class up into several partial
classes means that we can introduce behaviour not intended to be part of the
original specification of the total class. This leads to inexperienced and
unwise developers adding more and more "partial" classes so that, in the
end, they have one class for the whole application !
In the last ten years of Delphi, I have consulted for companies where
developers have managed to get a whole application's logic in the main form
code unit which may possess many tens of thousands of lines of code !!! .NET
namespaces equate to Delphi units in some ways, I just hope I don't see too
many multiple module "partial" classes :-(
Joanna