• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FBNS: criteriaFind()

 
Youji Tanaka
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all.

i read a thread(http://www.coderanch.com/t/183989/java-developer-SCJD/certification/FBN-criteriaFind-String-criteria-method)

In that thread, below solutions is written.

1. SOME PEOPLE DON'T CACHE ALL RECORDS IN MEMORY BECAUSE OF POSSIBLE MEMORY ISSUES IF THE DATABASE GETS HUGE
2. OTHER PEOLE DO IT, FOR THE PERFORMANCE ADVANTAGE
3. AND OTHER PEOPLE (LIKE ME) IMPLEMENT A CACHE WITH AN OPTIONAL MAXIMUM CACHE SIZE.

i selected 1.

my implementation is as follows. is this ok?



Thanks
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11852
185
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Youji,
In that thread, below solutions is written.

1. SOME PEOPLE DON'T CACHE ALL RECORDS IN MEMORY BECAUSE OF POSSIBLE MEMORY ISSUES IF THE DATABASE GETS HUGE
2. OTHER PEOLE DO IT, FOR THE PERFORMANCE ADVANTAGE
3. AND OTHER PEOPLE (LIKE ME) IMPLEMENT A CACHE WITH AN OPTIONAL MAXIMUM CACHE SIZE.

i selected 1.
Just being pedantic here - that was a comment by Phil, not a solution.

Having said that, have you tried to determine how big a record would be if stored in memory / how many records you would need to store in memory before you ran out of memory / whether you could still address that many records given the API limitations?

There are lots of reasons for implementing a cache, and there are lots of reasons for not implementing a cache. There is nothing wrong with you choosing to go with Phil's option 1.

my implementation is as follows. is this ok?
Have you considered using the Sun Code Conventions for the Java Programming Language? Personally I find:easier to read than

Why not validate each field name as you extract it from the criteria string? Why are you doing this as a seperate step?

At rough glance this all appears to work - have you tested it to confirm that it does work?

Regards, Andrew
 
Youji Tanaka
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrew


Have you considered using the Sun Code Conventions for the Java Programming Language? Personally I find...


I was not looking in detail.
Thanks you for the point.


Why not validate each field name as you extract it from the criteria string? Why are you doing this as a seperate step?


I made a point of readability. But is this bad way?
if bad way, i will modify.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11852
185
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Youji
But is this bad way?
if bad way, i will modify.
If you read enough of my posts, you will find that I rarely give a direct answer - I usually ask a lot of questions . The main reason for this is because there is no "one" right way to complete this assignment. Everything is correct, for a given value of correct.

So what you are doing is not bad in itself. And you have been able to justify it. You might want to put an implementation comment in your code stating that you have chosen readability over performance - or a similar comment in your design decisions document.

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