Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data as Context Independent Concept

 
Javini Javono
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've decided to implement Data in a slightly more abstract manner; by
"abstract," I mean that Data should be able to handle any type of database
following the general schema Sun has given. In short, Data should be
context independent. Or, more generally, the server serves up data and
is not involved with the interpretation of that data: the client worries
about that.
Thus, even though my project has no need for a duplicate key concept,
a more general Data would. So, I would create the necessary support
classes to recognize when a duplicate key could be created, and take
appropriate action. If actually checking for a duplicate key gets to be
a hardship, either because I don't want to read every record in the database
or I don't want to code it because it is not relevant to my project, then I will
at least have an outline of how primary keys could be supported by the database.
I've also decided to let my server expose "Data" to the client, wherein the
client will write business methods. The reasoning here is that I might want
to have my own, personal database, using this project code; and, if I place
the business methods on the server, creating what has been referred to as
a "database kit," this is not context independent anymore, for a database kit
refers to one, particular database, and only one.
So, two different databases, URLBird and the Airline reservation, would have
different business methods. My server won't be concerned with what people
do with the data in their business methods, but it will focus on being a general
purpose data server, including cases dealing with duplicate keys.
The client has to write the business methods.
Later, though I will not submit this as my project, it's always possible to design
a smart factory which returns any of the following:
1. Let the client interface directly with Data for any database.
2. Let the client interface directly with BusinessMethods for a particular database.
So, I've decided to expose Data to the client to focus on making Data as robust
as possible, and to keep my focus on making it context independent.
Thanks,
Javini Javono
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Javini,
This is (IMHO) a very good way to approach the Data class and the concept of a database in general.
It sounds like you are trying to programattically determine whether you could have a primary key or not. I would recommend against this - there is too much chance that your program will decide on (and enforce) a primary key where the user did not require or desire it. Perhaps you could have a method in your data class which allows the user to specify what the primary key is?
Regards, Andrew
 
Javini Javono
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for your response Andrew.
Concerning your comment:

It sounds like you are trying to programattically determine whether you could have
a primary key or not. I would recommend against this - there is too much chance
that your program will decide on (and enforce) a primary key where the user did not
require or desire it. Perhaps you could have a method in your data class which allows
the user to specify what the primary key is?

my writing was unclear. Your right, though, the server-side software has no way of
knowing without being told by the client if there is a key, and if there is a key, which
fields in the record comprise that primary key; so, the client must supply this info.
Thanks,
Javini Javono
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic