Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Assignment Comments relating use of Caching and RandomAccessFile

 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have some doubts relation the use of Caching for my assignment (URLyBird 1.1.3). The following comment in my interface delivered by Sun:


// Reads a record from the file. Returns an array where each
// element is a record value.
public String[] read(int recNo) throws RecordNotFoundException;


This read-method gets the record according to the recNo from a file? Do they mean a physical database file? So is it then impossible for me to use caching?
Am I too pedantic?

And here comes my doubts or gap in my knowledge relating the use of the RandomAccessFile class:


... All numeric values are stored in the header information use the format of the DataInputStream and DataOutputStream. ...


This tells me, that the db file was created by using the above streams. The RandomAccessFile implements superclasses of the above Streams (DataInput and DataOutput).
Are these informations enough to allow the use of the RandomAccessFile to access our database file?

Thanks for your help.
cheers Bob
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bob,

I used the RAF and I passed, and I think every scjd'er used that class

I used also a record cache. Regarding the comment of sun's interface, I left it there (completely unmodified, except for some class comments). I created my own interface, extending sun's interface (of course) and override the read-method (and all other methods) and added my javadoc comments in my own interface. And this is my javadoc comment I added to the method.



Kind regards,
Roel
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy, Bob!

As my good buddy Roel, I also used a memory cache. So when you read a record, the record is actually being accessed from memory, not from the physical .db file.
Regarding the RandomAccessFile class, please take a look at the database file reader I created. Even though I'm using FileInputStream there, you can just replace it by RandomAccessFile. It should continue to work normally.
 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roel,

Roel De Nijs wrote:
I used the RAF and I passed, and I think every scjd'er used that class


Seems I was a little bit pedantic here I will enter the RAF club.

Roel De Nijs wrote:
I used also a record cache. Regarding the comment of sun's interface, I left it there (completely unmodified, except for some class comments). I created my own interface, extending sun's interface (of course) and override the read-method (and all other methods) and added my javadoc comments in my own interface. And this is my javadoc comment I added to the method. ...
Kind regards,
Roel



I really think I have a big problem. I'm not CREATIVE enough. That has to be changed
From now on I will interpret the comment "Reads a record from the file" as "Reads a record from the file via the RecordCache". I will write that down in the choices and everyone is happy.
To modify one method (read(int recNo)) does not justify creating a new interface, I think.

Thanks for opening my eyes, Roel. I feel like a new man
cheers
Bob
 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bob,

Bob and Roel together in my thread. I feel honoured. The white knights in the night

Roberto Perillo wrote:Howdy, Bob!

As my good buddy Roel, I also used a memory cache. So when you read a record, the record is actually being accessed from memory, not from the physical .db file.
Regarding the RandomAccessFile class, please take a look at the database file reader I created. Even though I'm using FileInputStream there, you can just replace it by RandomAccessFile. It should continue to work normally.


I already used your database file reader. Works like hell (meant positive )
But I was to lazy to try it with RAF. I will try it, later.

Thanks and cheers
Bob


 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Wheeler wrote:
Bob and Roel together in my thread. I feel honoured.


You certainly should be
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured. The white knights in the night



Haha indeed they are "white knights".

Well I'm not going to say much since my good buddies Roel and Roberto did the job already.
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured.



Come on, Bob! We are here to help. We are a team, actually (I am the goal keeper)!
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured. The white knights in the night



Yeah - they are really great! Thanks guys!

Roberto Perillo wrote:Come on, Bob! We are here to help. We are a team, actually (I am the goal keeper)!


More football commentary.

(I've got my sister & her family over from Ireland at the moment - one Man-U, one Chelsea, & one Liverpool supporter. Sigh. )
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic