mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-22 15:49:53 +01:00
akwizgran created page: pre review checklist
32
pre-review-checklist.md
Normal file
32
pre-review-checklist.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#### Thread safety
|
||||||
|
* Classes should be immutable where possible
|
||||||
|
* Classes that may be used by multiple threads must be thread-safe
|
||||||
|
* If a class is used by a single thread and is not thread-safe, add a comment
|
||||||
|
* Fields that are accessed by multiple threads must be volatile or guarded by locks
|
||||||
|
* If a field or method is guarded by a lock, add a comment
|
||||||
|
|
||||||
|
#### Visibility
|
||||||
|
* Minimise the visibility of classes, fields and methods
|
||||||
|
* Fields should be private or protected
|
||||||
|
* Fields should be final where possible
|
||||||
|
* Inner classes should be static where possible
|
||||||
|
|
||||||
|
#### Instantiation
|
||||||
|
* Don't allow `this` to escape the constructor
|
||||||
|
* Complex dependencies should be injected or constructed by factories
|
||||||
|
* Use executors rather than creating threads where possible
|
||||||
|
|
||||||
|
#### Exceptions
|
||||||
|
* Use checked exceptions rather than special return values to indicate errors
|
||||||
|
* Unchecked exceptions should only be used for programming errors
|
||||||
|
* If you catch an InterruptedException in a synchronous method, interrupt the current thread so the caller learns about the interrupt
|
||||||
|
|
||||||
|
#### Blocking
|
||||||
|
* Don't call blocking methods from the UI thread
|
||||||
|
* Don't call blocking methods from event handlers
|
||||||
|
|
||||||
|
#### Locks
|
||||||
|
* Avoid using locks where possible
|
||||||
|
* Use dedicated lock objects rather than `synchronized`
|
||||||
|
* Don't call into other classes while holding locks
|
||||||
|
* Don't start database transactions while holding locks
|
||||||
Reference in New Issue
Block a user