Design
Principles of Object-Oriented Design
Single Responsibility Principle (SRP)
The SRP requires that a class should have only a single responsibility.Open-Closed Principle (OCP)
The OCP requires that each software entity should be open for extension, but closed for modification.
Liskov Substitution Principle (LSP)
The LSP requires that objects in a program should be replaceable with instances of their subclasses without altering the correctness of that program.
Interface Segregation Principle (ISP)
The ISP requires that clients should not be forced to depend on interfaces that they do not use.
Dependency Inversion Principle (DIP)
The DIP requires that high-level modules should not depend on low-level modules, both should depend on abstraction. Also, abstraction should not depend on details, details should depend on abstractions.
Test-driven development (TDD)
Test-driven development (TDD) is a software development process relying on software requirements being converted to test cases before the software is fully developed, and tracking all software development by repeatedly testing the software against all test cases.
Java Coding Best Practices
- 1. Use Proper Naming Conventions
- 2. Class Members must be accessed privately
- 3. Use Underscores in lengthy Numeric Literals
- 4. Never leave a Catch Blocks empty
- 5. Use StringBuilder or StringBuffer for String Concatenation
- 6. Avoid Redundant Initializations
- 7. Using enhanced for loops instead of for loops with counter
- 8. Proper handling of Null Pointer Exceptions
- 9. Float or Double: the right choice?
- 10. Use of single quotes and double quotes
- 11. Avoiding Memory leaks
- 12. Return Empty Collections instead of returning Null elements
- 13. Efficient use of Strings
- 14. Unnecessary Objects Creation
- 15. Proper Commenting
Tips to Optimize Java Code Performance
- Avoid Writing Long Methods. ...
- Avoid Multiple If-else Statements. ...
- Avoid Getting the Size of the Collection in the Loop. ...
- Avoid Using String Objects For Concatenation. ...
- Use Primitive Types Wherever Possible. ...
- Avoid Using BigDecimal Class. ...
- Avoid Creating Big Objects Often.
Comments
Post a Comment