I am a Software Engineer with a passion for UI/UX design, backend development, and DevOps. Outside of work, I enjoy calisthenics, yoga, acrobatics, running, drawing, and CAM.
myVariable, calculateSum()).MyClass, CustomerOrder).MAX_COUNT, DEFAULT_PORT).This naming convention does not match with all languages, refer to your languages preferred naming convention.
Use explicit names for domain-related objects. For instance, a configuration object should include the word Configuration in its name for clarity.
Avoid using the prefix I for interfaces. Instead, opt for naming the base implementation with the suffix Impl to improve readability and consistency:
| Interface | Implementation | Recommendation |
|---|---|---|
| IMyExample | MyExample | ❌ |
| MyExample | MyExampleImpl | ✅ |
Use descriptive names for objects related to specific patterns. For example, a factory should include the word Factory in its name. This convention also applies to other patterns like builders, DTOs, POJOs, and similar objects.
Establish a clear naming convention for objects of the same type or hierarchy to maintain uniformity across your codebase.
Avoid using generic names like Data, Handler, or Manager as they lack clarity. Instead, use specific names that align with the domain language to improve code readability and understanding.
Consider using should as a prefix for naming tests. This helps to think about the behaviour of the software.
@Test
public void shouldReturnNonZeroValue() {
assertNotEquals(0, testSubject.execute());
}
calculateNearestSupermarketCoordinates to ensure its purpose is immediately clear.Exception is typically a code smell. Exercise caution when doing so, as it may indicate an overly broad or imprecise error-handling approach. try {
codeThatThrowsAnException();
} catch ( SomeException exception ) {
// Ignore exception
}
switch statements, as they can be difficult to read. Instead, opt for if statements for better clarity and maintainability.