Pull to refresh
4
0
Dmitrii Ponomarev @dimpon

Java Developer

Send message

Small things that pollute your code

Reading time 4 min
Views 2.3K
I'm not going to discuss global things like design patterns and so on, as there's enough literature on that topic. Instead, I'd like to attract your attention to some small things that still affect lucidity and maintainability of a code.

Polluting code with 'test-only' methods or access modifiers


First of all, if you give access to something that shouldn't be used in production code, it gets used sooner or later. Just because it exist. The argument that it's an internal stuff doesn't work as it absolutely shouldn't be matter, writing you a library or isolated project! Treat people who will add anything to your internal codebase the same way as if they use your existing code as a different library.

Thus, if for some reason in test, you need to call something that should not be called on prod — use reflection or whatever else but do not expose it in production code! And there's no reason to afraid of reflection for test proposes, at the end, you using Mockito, shouldn't it be bad in that case as well?
Read more →
Total votes 4: ↑3 and ↓1 +2
Comments 1

Information

Rating
Does not participate
Location
Frankfurt am Main, Hessen, Германия
Date of birth
Registered
Activity