So, lets say you added a new feature to an existing Java project, and when adding unit test you see that other similar tests are using null checks:
if(value != null){
assertEquals("Value should be 10", 10, value);
}
But you know about Optionals so your test could look like:
Optional.ofNullable(value).ifPresent(value ->
assertEquals("Value should be 10", 10, value)
);
Another example could be type annotations in Python
Which is more important to you? Keep the code consistent but not using new features or use new features even if code will end up looking inconsistent?
Only considering that using or not using new features is not a decision based on performance, security or any other concern
My initial approach would be keep it consistent but add a low priority task to refactor code if/when necessary, but curious to find out what others think.







I like to make sure everyone on the team supporting the codebase is on the same page. Once we all agree that yes, we want to use the new feature then we can incrementally improve the code. I would not use the new feature until that first step is taken because inconsistency when you're not expecting it can be pretty confusing.
If it's just me coding, I'll use it because it's probably a side project and I want all the new things~~