Benefits of nullable by default: -
Drawbacks: numerous
How is this a trade-off?
Drawbacks: numerous
How is this a trade-off?
Consider this piece of pseudo-Java/Spring code and think how you would do it if the platform you were using forced you to either declare a and b as optional (which they are not) or assign them some value between the IoC container instantiates the class X and wires the values for a and b.
public class X {
@Autowired
ServiceA a;
@Autowired
ServiceB b;
@PostConstruct
void init() {
// a and b are instantiated by the IoC container and
// are fully valid for the rest of the execution
}
}2. Do you not consider cyclic dependence a code smell? At least I have always avoided cyclic dependencies.
But in general yes; cyclic dependencies are a bad idea.