Sunday, July 19, 2015

Effective Java item 45: Minimize the scope of local variables

Summary of the item 45.

1. Declare a local variable where it is first used.
(Instance variables declaration should be at the top of the class. from Clean Code by Robert C. Martin, page 80)

2. Nearly every local variable declaration should contain an initializer.

3. Prefer for loops to while loops

4. Keep methods small and focused.

Those are very basic rules of clean code.







No comments:

Post a Comment