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

Spec question

 
Michael Valentino
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone, I have a couple questions about the spec of the exam. I'm preparing my program for submission soon and re-reading the specs very carefully to make sure everything i have done is in compliance. I have a questions though.

1. My spec states that the find feature should "exactly match the name and/or location fields". However, in the Database's interface, the spec states that the find should return a record if "the field matches exactly or starts with the specified criteria - i.e. 'mark' matches 'mark' or 'market'. Any ideas how i should interpret the conflict in these two specifications?


Thanks guys
 
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 Michael,

Consider what would happen if you were working in a large company, where you had one programmer working on the database, and another programmer working on the front end. Isn't it possible that they might be given different requirements?

Alternatively, consider what would happen if the company intended to have several applications all using the same database (your booking application, and an application that performs reporting on the data). Since there is only one database, it makes sense to create an interface that both application programmers can develop to. The interface would have to be generic enough that both application programmers can use it - the more specific business logic would need to be in the application somewhere.

So, depending on your perspective, there is no real conflict in the specifications - it is just something you need to handle.

Also remember that the Data class' find method does not return records - it returns record numbers. So when you retrieve the records you would still need to verify that the records have not been deleted / modified.

Regards, Andrew
 
Michael Valentino
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That does make sense. The only thing that bothers me a little is in my opinion a "search" or "find" SHOULD return a set of possible matches as well as exact matches. i.e. say you forgot the full name of the company (was it inc.? or corp.?) and you can't remember their location. But you know that it was "International something or other". My design will make it easy to handle, i just figured that it was a mistake in the spec. Still iffy on it. But if i had a nickel for every time i didn't agree with a spec... well i wouldn't be taking this exam

Thank you for your help, Really appreciate it!
 
Eric Ellis
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I'm working out the same issue.


// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)


I've already built my search; really I'm just confused as to when a field should be searched, and when it should return all records. Let's take this appart piece by piece.

A null value in criteria[n] matches any field value.

Let's imagine a criteria looks like this:



If any field value matches null then it will reaturn all record numbers. This would negate the "a". Why even search at all. Why not just return all records if I encounter a null value. On that premise, what would the array look like if it were to search the first field?



Seems right... but what if I really do want to look for records with no value. These values are padded in the database so really there would never be a situation where a field returned a blank String.

Do you think it sounds right to treat "" as an indicator to leave a field unsearched? Should any null value return the entire set? This isn't how I would design the interface.

I would have a null criteria[] indicate a list all and a null field value indicate a skip. But then, this may be one of those things that Sun throws in to mess us up.
 
Eric Ellis
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A little more to add to that. I've spent so much time working on the client requirement that it didn't occur to me that the find method uses the && operator not the ||. Under that premise we're looking at a whole different ball game. Null fields would simply skip and a list all query would look like this:



 
Eric Ellis
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that adds to the conundrum. Hotel Name and City use ||. I guess the spec leaves enough room to implement this as:

criteria[n] with a value is paired using || to other criteria[n] with a value
criteria[n] as null is a free-bee match using the && operator.

That's a lot of assuming... I feel dizzy now
 
Eric Ellis
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I've got it!

Everything is an &&. Run two searches.

{"a", null, null, ...}

then again

{null, "b", null, null, ...}

combine the results
 
Michael Valentino
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Eric, sorry I hadn't checked the bulletins before you had figured it out. Congrats on that Wish I could have been there to help before though. Good luck with the rest of the exam!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic