I am currently working on the B&S locking strategy.
There is a simplistic approach to just synchronize all read and write methods in the Data class (server side) and implement wait/notify in the lock/unlock methods (with a Map recordId -> cookie).
Can one really score 80/80 Points using this approach (assuming it is implemented correctly of course)? Sounds too good to be true. No fancy ReentrantReadWriteLock fuss needed?
Somehow this appears "too simple" to me. And it means that you practically have a database lock because no two threads can execute methods of the Data class simultaneously.
I'm doing UB not B&S but I'm sure locking is locking. Synchronizing all methods may be the simplest but may NOT be the most effective. For me anyway, I use "critical section" and "read/write lock" design patterns for my Data class.
K. Tsang , thanks for your reply. I agree that locking all methods is not the most effective. In a "real world" project this is very important. Here, the goal is different: score 80/80.
Would you say that efficiency a "must" for the assignment?
Efficiency isn't the most important. But do need to consider code clarity and maintainability and of course the overall design. Of course making it work and not hang (eg getting deadlock) is the key.