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

Urlybird 1.1.1 record design

 
Alex Bischof
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm near to finish my project and now faced a problem with my records.

I'm using a singleton 3-tier design which means that data tier and buissness tier are implemented as singletons and my Data class also has a cache.

And there is my problem.

1. Is it better to hold the objects in cache as String[] or Record (own class)?
I've tried both problems. The String[] version seem to be very poor. But i haven't got any problems with converting from Record to String[] and back to Record because i want to use the Record class in the cache of the database and also as an argument of my buissness interface and also in the RecordTableModel. Is it a bad design?

2. I've also got a problem with the record number itselfs because it isn't a really primary key rather then a physically number of a record in the database file.
So i don't know if i put the record number to the record data.

For example:


Should the implementation of read put the record number always on the first position?

I also think that this approach is hard to maintain because you always have to take care of it (for example: sometimes one more and sometimes not).

What are your expieriences?
Thanks in advance

Alex Bischof
 
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 Alex,

Welcome to JavaRanch and this forum.

1. Is it better to hold the objects in cache as String[] or Record (own class)?
I've tried both problems. The String[] version seem to be very poor. But i haven't got any problems with converting from Record to String[] and back to Record because i want to use the Record class in the cache of the database and also as an argument of my buissness interface and also in the RecordTableModel. Is it a bad design?
Using a Record within the Data class or within the remainder of your application is not bad in itself - what you have to decide is whether it makes your code more readable / understandable / maintainable.

You might like to take a look at the Transfer Object design pattern (which is a renamed Value Object design pattern (as their UML diagram clearly shows )) - you would certainly be using a recommended industry practice in using a Record class.

Note that the provided interface is very specific about what should be returned. So you could not change the read() method to return a Record.

2. I've also got a problem with the record number itselfs because it isn't a really primary key rather then a physically number of a record in the database file.
So i don't know if i put the record number to the record data.

For example:


Should the implementation of read put the record number always on the first position?
Why? The class calling the read() method knows the record number they are reading don't they?

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic