#
Review No. 1
This page contains miscellaneous concepts briefly explained.
#
What is the meaning of "Clean Code" ?
"Clean Code" signify a code which is easy to
read
maintain
(fix bugs, add new functionalities with ease)test
Here we need to consider:
- Single Responsibility Principle
- meaningful names
- comments are not a substitute for Clean Code
- error handling
- no code duplication
- proper modularity
- keep the code simple
- good observability
- use code analysis tools like SonarQube or CodeClimate
#
Shared vs Exclusive lock
- A shared (S) lock permits the transaction that holds the lock to read a row.
- An exclusive (X) lock permits the transaction that holds the lock to update or delete a row.
#
Pessimistic vs Optimistic Locking
- Pessimistic Locking (when we READ/WRITE to a database) - a conflict is likely to happen and thus locks data before it is read or modified.
- Optimistic Locking (when we WRITE rarely to a database) - a conflict is NOT likely to happen and thus the data is not locked. However, a "version" column (which is incremented on each UPDATE or DELETE) and the 2nd parallel operation on the same row will not be done.
Info
The version field (integer or timestamp) is marked with @Version annotation.