void useConcreteServiceImpl(ServiceImpl service) {
service.serveMe(); } void useAbstractService(Service service) { service.serveMe(); } |
void useConcreteServiceImpl(ServiceImpl service) {
service.serveMe(); } void useAbstractService(Service service) { service.serveMe(); } |
Note how the colour of 'serveMe' helps us detect the (accidental?) use of a concrete class. Also, in the case of an abstract method we know it's not useful to ctrl-click to it unless you really want to see the abstract declaration. Ctrl-T instead to select an implementation.
void accidentalFieldScope(Session session) {
useSessionAttribute(session.getAttribute("attr1")); // here we have so many lines of code that // we cannot see the method parameter declaration // anymore useSessionAttribute(theSession.getAttribute("attr2")); } |
void accidentalFieldScope(Session session) {
useSessionAttribute(session.getAttribute("attr1")); // here we have so many lines of code that // we cannot see the method parameter declaration // anymore useSessionAttribute(theSession.getAttribute("attr2")); } |
Even though we cannot see the method signature, colour tells us when we are using the given (current) session 'session' and when we are (accidentally?) using some other session, saved in the field 'theSession'.
public class GenericVsTypeDemo<T1> {
interface T2 { // a non-generic type } T1 handle(T1 in) { return in; } T2 handle(T2 in) { return in; } } |
public class GenericVsTypeDemo<T1> {
interface T2 { // a non-generic type } T1 handle(T1 in) { return in; } T2 handle(T2 in) { return in; } } |
No use trying to find a type called T2, which we can see from its colour.
See blah and todo and how the latter is better, and how IDE defaults are somewhere in between etc.