• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Mark's criteriaString builder

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark had this to say in the huge Connection lock/unlock thread (which was a very good read BTW):
"The points I lost was because I added two methods to the Data class that should have been in the CriteriaFindBuilder class..."
Glad I saw this. I've got
public String getFormattedCriteriaString(
String[][] fieldsAndValues) in Data. Was patting self on back til I saw Mark's post.
Question is: doesn't this method have a good home in Data? Data requires this format, and so should offer this formatting service.
Also, what were your string builder methods, Mark? Is there a more eloquent way to provide raw info to a string builder method than a 2-level array?
p.s. started coding the assignment in earnest just last week and have come to LOVE this site!
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I too like to know the reasons behind having CriteriaFindBuilder class instead of two methods in the Data.
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I can answer for Mark (he is on vacation to Mumbai ), -- each class should focus on the specific purpose. The criteria building (parsing, storing the key-value entries in some data structure, etc) have nothing to do with Data, whose purpose is to describe Data. But since we need the criteriaFind() implemented in data, the criteria building functionality should be isolated in a helper class.
Eugene Kononov.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eugene -- thanks. Sounds logical. Mark is on vacation in Mumbai???
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The GRASP patterns say something about this - your are looking for HIGH cohesiveness and LOOSE coupling. So, the functions provided by a class should be HIGHLY COHESIVE, i.e. related to a single purpose or objective and LOOSELY COUPLED to other classes.
So, the question is this: What does the parsing of query criteria have to do with the maintenance of a flat file database? Well, not much. To build both of these behaviors into a single class would NOT lead to high cohesion within the class.
It is important to note though that putting this behavior in a seperate class should be done in such a way as to keep COUPLING LOW, i.e. don't design CriteriaBuilder in such a way that it is highly dependant on the internal implementation or data structures of the Data class.
Matt
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CriteriaBuilder/Finder method will be using some kind of an Algorithmn. Instead of directly putting the algoritmn in the Data class, I have created a criteriaFinder class to the work.
Advantages is loose coupling between the Data class and the Algorithm used, and also ability to add and remove algorithms.
This is a combination of Functor Pattern and Strategy Pattern
Regards
Arup
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mathew, Arup, Thank you for the explanation.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for great explanations of why and how. Makes sense. This site is a great resource.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now aren't I a great Ventriloquist?
I am back from Mumbai, and I must say the weather has been a downpour of work issues.
Mark
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, hard work now pays off for the laziness in the future.
Eugene.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've noticed a number of vacations to Mumbai mentioned in other threads. Had not realized that Mumbai is such a popular tourist destination (at least no more so than Chicago, IL).
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I go to Mumbai when it is too expensive to vacation in Detroit.
Mark
[ June 21, 2002: Message edited by: Mark Spritzler ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic