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

B&S DB Design

 
Sham Delaney
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need some advice on best practices of the design.

How much can I assume about the Database file & Schema that was given to me in the assignment, when designing the Solution?
Can I assume the field names given in the DB file and create a record class based on these? OR should my solution be more generic and capable of reading in the fields and create a dynamic record class from there?

I would guess that its safe to assume the DB isnt going to change and I can create my Record Class with variables like name, location, specialities etc.
Is this correct?

Also, should i write a seperate class to read in the data and store it in a collection, OR can i add methods to Data.java to implement the reading in of the records to the collection. The Data.java implements DBAccess.java which has methods to read a record, delete a record, create a record, etc?

Any help appreciated?
 
Carlo Spelgatti
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sham

I think we can assume, that the database file is static. Otherwise we would need to know, how it can change. And I think a more generic solution is like
making a database system and not in the scope of the SCJD exam.

I think you can do everything in data.java, but I also need to do logical looking, so I will make at least two classes and possibly make the data.java a facade implementing the provided interface that calls FileAccess.java and LookingManager.java.

What do you think?

Carlo
 
Sham Delaney
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Carlo,

Thanks for your help, I agree with you, and thats what I thought. But i needed some clarification fom someone, just to be sure.

Good idea about the Design Patterns by the way.

Thanks
Sham
 
Bob Nedwor
hangman
Ranch Hand
Posts: 215
Eclipse IDE Oracle Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though there aren't any particular musts that talk about the schema changing, we need to be flexible due to the requirement about good OO design (worth 30 points).

I built some code that reads in the 54-character header, parses it out, and programatically determines the number of fields and their lengths, etc, rather than just assume that the "name" will always be 32, the location will be 64, etc.

Now everything that I have done so far will still work on a different data file, if they decide to change the width of a field, the number of fields, etc.

I suggest you read what SCJD Guru, Andrew's responses on this issue are at this posting
 
Yupp Cook
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bob

I did the same storing it in an object of class DbInfo. But I m unsure whats the best way to access dbInfo.
I could either pass the object around to whereever it's needed or just make all the fields in dbInfo static providing overall access.
Any suggestions?

Y.
 
Carlo Spelgatti
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bob

I agree with you. So I made my file access class more flexible. It now parses also the structure info's in the header and sets up a DbInfo class.
At the moment, my DbInfo class is a private inner class of the file access class. But thinking of input validation in the GUI I could use the information of field names and field lenghts in the GUI.
Maybe I should pass the DbInfo class to the client somehow. I will see later.

Carlo
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic