Currently working with Spring and I've been learning about methods I can use to help the readability of my code, with one example being replace complicated conditionals with an easy to understand method call. For example:
private void myMethod(){
//Bad
if(userAge < MIN_AGE){
//logic
}
//Good
if(userTooYoung()){
//logic
}
}
private boolean userTooYoung(){
return userAge < MIN_AGE;
}
My question is: is it worth while creating a custom annotation to show that userTooYoung is simply there to help the readability? For example:
@Assistant
private boolean userTooYoung(){
return userAge < MIN_AGE;
}
I can't really think of another function the @Assistant annotation could serve, thus, it begs the question of is it really worth it?
EDIT: I've been playing around with the idea of an @Assistant annotation and come up with the following:
Definition:
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.METHOD)
public @interface Assistant {
enum With {
CONDITIONAL_LOGIC, CONSTRUCTION_LOGIC
}
With help() default With.CONDITIONAL_LOGIC;
}
Usage:
@Assistant(help = Assistant.With.CONDITIONAL_LOGIC)