• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Urlybird 1.1.1 record design

 
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
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • 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
 
Acetylsalicylic acid is aspirin. This could be handy too:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic