• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Data package

 
Hans ter Wal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I've started my assigment with trying to get the read/search/create to work. I did this by putting a file access in the data class. This works fine, but makes my class very unclear. Seeing as almost everybody is using a datahelper/dataschema helper class to do all file access, I'm wanting to do same.
Somethings are unclear to me though:
1. If I give my clients a data class each the dataHelper class is a singleton?
2. My assigment specifies that the data.java and all exceptions thrown from it should be put in the suncertify.db package. But can I or must I put my dataHelper in the same package or must I put it in one of my own packages
Regards,
Hans
 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about #1.
For #2, I put my helper/schema class in the db package rather than creating a new package of my own. I am trying to keep the number of packages fairly small - db, gui, remote, util, and test (test will not be included with submission)
TJ
 
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
Hoi Hans,
Originally posted by Hans ter Wal:
1. If I give my clients a data class each the dataHelper class is a singleton?

You would probably want to limit the number of instances of that class.
Before making it a singleton, though, try and decide whether it really does fit that pattern. The first question you should probably ask yourself is whether there is any conceivable circumstance where you might want more than one instance of that class. For example, what if a later enhancement required a second table to be used? If you make this class a Singleton, then it might be difficult to add additional instances of the class later.
You might be better off making it either a multiton (a controlled number of instances of the class - for example making an instance of the class for each unique database), or simply creating a single instance of it that you use throughout your application.
Originally posted by Hans ter Wal:
2. My assigment specifies that the data.java and all exceptions thrown from it should be put in the suncertify.db package. But can I or must I put my dataHelper in the same package or must I put it in one of my own packages

It is generally a good idea to group classes within packages so that they form a logical group. In this case, what is the logical group of classes that would be in the db package? If your answer is "database" classes, and your dataHelper class falls into the category of a "database" class, then you might find the answer to your question
I agree with Terry's packages. The only difference I had was that I called the "remote" package something like "connectivity" or something like that.
Regards, Andrew
[ November 23, 2003: Message edited by: Andrew Monkhouse ]
 
Hans ter Wal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx Terry and Andrew,
I'll go with the suncertify package then :-)
Thanks for the help on the singleton thing 'multiton' gives me a few more threads to read through, going to go through them first.

Hoi Hans

Do you know more dutch Andrew? ;-)
Regards,
Hans
 
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
Hoi Hans
Originally posted by Hans ter Wal:
Do you know more dutch Andrew? ;-)

Ik spreek een kleien beetje Nederlands, als ik gewond en geworkte in Maarsen (vlakbij Utrecht) vor twee jaar.
Even more amazing: I can pronounce the g's in that sentence! (But like most Aussies, I have a hard time with the r's). So I can make myself understood (not that many Dutch people are willing to put up with my Australian accent and terrible Dutch ) but as you can see, my written Dutch is terrible
I did complete my first year of a three year course to learn Dutch to the official level required for students (not that I was trying to be one), and I got close enough to a pass mark that I was told I could continue with the second year (which is another way of saying I failed )
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic