This is like an application-specific session facade or business delegate, isn't it? Do you think that a business delegate interface "IS A" generic database interface? I don't...Originally posted by Geir Morten Hagen:
BookingDataInterface extends DataInterface -
Defines all application spesific functionallity.
What is application-specific about lock, unlock and criteriaFind? They strike me as completely generic functionality that should not reside in an application-specific class.BookingData extends Data implements BookingDataInterface - Implements all application spesific functionallity like lock/unlock, criteriaFind and bookSeats.
Maybe. At the same time, there is nothing application-specific in the semantics you have been given. You may have a case for implementing them in a subclass of Data. You do not, IMHO, have a case for implementing them in the same class as application-specific stuff like bookSeats. This would inhibit the reuse of some pretty generic functionality.I feel that lock/unlock and criteriaFind should be in a subclass of Data, because different applications might need different implementations of these methods.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
For criteriaFind, my answer would be an unequivocal "yes". If the totally braindead "find" method has a rightful place in Data, then so does criteriaFindOriginally posted by Geir Morten Hagen:
I get your point, but should I put lock/unlock/criteriaFind in Data then? I find that a bit concerning, because when running in local mode lock and unlock isn't necessary.
In that case, you can implement criteriaFind in a Data subclass. Although I would expect that the existing criteriaFind is simply enhanced as new needs come up, e.g. with a pattern matching facility ("Carrier='Speed*',Origin='SF[OA]'") or expression language (("Carrier='SpeedyAir' or Origin='SFO'"). These would be backwards-compatible enhancements of the Data class rather than completely different implementations of the search function.Another thing is that criteriaFind can possibly take a different criteria-format in another scenario where Data is to be used, and implementing that in Data will then hamper reuse.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
I almost agree with you. Yes, that "ANY" thing is application specific, and even locale specific. But there is no need for criteriaFind to understand "ANY"... if you look at the way criteriaFind works, the absence of a field in the search criteria means that no search condition is imposed on that field. In other words, if the user enters/picks "ANY" for a field, the client can just leave it out of the criteriaFind call.Originally posted by Geir Morten Hagen:
But I have a comment on what you said about criteriaFind. The requirements state that 'any' can be used for origin and destination. This applies only to this application. If Data is to be used in a totally different application, you will then need to change the implementation of criteriaFind in Data to adhere to the requirements of the new application.
As long as the extended search functionality is backwards compatible, it would probably be a straight modification to Data. (But we're getting into hypothetical territory here).Maybe a solution is to implement only <field>=<value> searches, and leave it to subclasses to extend this functionality with wild-card searches, etc?
Well, no, indeed. But you shouldn't code criteriaFind in that way anyway! Remember that you're coding for reuse. As the functionality offered by criteriaFind() is crucial to just about any application, I think it should be coded in a completely generic way. You know what the fields in the database are called (getFieldInfo()), so you can parse the search expression, find out where each of the fields lives, and check the search condition on a record by record basis. There is no need whatsoever to hardwire a particular field layout or particular field names in there. Done that way, criteriaFind is a completely generic method that will do its job for any database, any application.An example:
if(criteriaFields[src].equals("Origin airport") && criteriaValues[src].equals("any")) hardcoded into criteriaFind() in Data can't be good?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Get me the mayor's office! I need to tell him about this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|