-
Protected: Clear method invocation (avoid null parameters, different logic based on params)
There is no excerpt because this is a protected post.
-
Protected: @NonNull
There is no excerpt because this is a protected post.
-
Protected: How to avoid null?
There is no excerpt because this is a protected post.
-
Avoid null collections
I saw in the code patterns like this: We can use the Optional for fluent null logic: The better approach is to avoid null checking by collection initialization: Yes, more cleaner. No NullPointerException problems. The most important thing is that the code will work on non empty collection and also on empty collection! We do…
-
Protected: The ‘null’ problem
There is no excerpt because this is a protected post.
-
Protected: How to properly name the packages? – to finalize – replace picture after refactoring with more packages
There is no excerpt because this is a protected post.
-
Use the ‘final’ everywhere!
The use of the keyword ‘final’ should be the rule/best practice and the default behavior: Let’s see why: prevents accidental modifications In the case of ‘simple’ types (primitives, wrappers), this is easy because we can prevent value changes. In the case of objects, we can prevent reference changes, but not to the object content. Better…
-
Extract a logic from collections processing
Once again, you as a developer, get a task to simplify the below code: You can simplify a little with streams: but this is not what we want to achieve, because the logic/condition is sunk in collection processing and testing is not easy and as you see, leads to testing many cases (good client, bad…
-
Functional programming styles
Your task as a developer is to write a code for selecting clients that have a good credit history and age is above 30 and live in NY city. You wrote a code like this: A senior programmer seeing your code: You know that programmers don’t express any emotion, so you start to think that…
-
Do not clutter production code with test code
As a developer, you are writing new functionality. The implementation is ready, but you have to write tests. To simplify the tests, you create additional helpful methods in one of the production class: Completed. Code review – comments are not allowed, removed. Merged. After some time … a problem appeared in production. The financial report…