OK, but what is the reason for this?
Is it sufficient to say, that the strict requirements do not allow to modify the method signature of the lock/unlock class?[/QB]
I would say that that is never a good reason. The requirements are there to guide your choices, but they also represent design choices that are valid in themselves. If you can only justify your design by referring to the requirements, it may signify a problem in the design. For example, if you would implement business methods like book() and findFlights() in Data, it becomes very hard to justify having a client-side object that implements all the public methods in Data. This should set alarm bells ringing.
In your specific case, you need the lock() and unlock() methods in DataInterface, because without them you cannot get booking to work reliably with more than one client. This immediately means that you need lock() and unlock() in Data, simply because Data must implement DataInterface.
The next question is, do Data.lock() and Data.unlock() need any specific behaviour or can you leave them empty? My own line of reasoning was that Data itself can only be used locally, from one single client, in which case you don't need locking [1]. As a consequence I felt it was perfectly OK to leave these methods empty in Data.
- Peter
[1] That was a bit too glib. In theory, it is possible that you might need to use a local database from multi-threaded code where threads compete with each other for locks. The Data class as I described it won't work in that case; however, if coded properly nothing prevents your networked classes from being used locally, and they
would work with multiple competing threads. If you extended UnicastRemoteObject, such code will open a couple of ServerSockets, but that seems a small price to pay for simplicity.