--
You received this message because you are subscribed to the Google Groups "yadic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yadic+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
1 package me.v.service.tm; 2 3 import com.googlecode.yadic.Container; 4 import com.googlecode.yadic.Containers; 5 import me.v.service.query.NotificationMessageFlowQueryService; 6 import me.v.util.logging.LogReader; 7 import me.v.util.logging.LogReaderService; 8 9 public class NotificationMessageFlowQueryServiceCreator { 10 11 public static NotificationMessageFlowQueryService create(String userName) { 12 Container container = Containers.container(); 13 container.addInstance(String.class, userName); 14 container.addInstance(LogReader.class, LogReaderService.create()); 15 container.add(NotificationMessageFlowQueryService.class); 16 return container.get(NotificationMessageFlowQueryService.class); 17 } 18 19 }
1 2 public static NotificationMessageFlowQueryService create(final String userName, LogReader logReader) { 3 return new NotificationMessageFlowQueryService(userName, logReader); 4 } 5 6 private NotificationMessageFlowQueryService(final String userName, LogReader logReader) { 7 this.userName = userName; 8 this.logReader = logReader; 9 buildNotificationUserJourneys(); 10 }
1 public class NotificationMessageFlowQueryServiceCreator { 2 public static void main(String[] args) { 3 create("bob"); 4 } 5 6 public static NotificationMessageFlowQueryService create(String userName) { 7 Container container = Containers.container(); 8 container.addInstance(String.class, userName); 9 container.addInstance(LogReader.class, LogReaderService.create()); 10 container.add(NotificationMessageFlowQueryService.class); 11 return container.get(NotificationMessageFlowQueryService.class); 12 } 13 14 public interface LogReader { } 15 16 public static class LogReaderService implements LogReader { 17 public static LogReaderService create() { 18 return new LogReaderService(); 19 } 20 } 21 22 public static class NotificationMessageFlowQueryService { 23 private final String userName; 24 private final LogReader logReader; 25 26 public static NotificationMessageFlowQueryService create(final String userName, LogReader logReader) { 27 return new NotificationMessageFlowQueryService(userName, logReader); 28 } 29 30 private NotificationMessageFlowQueryService(final String userName, LogReader logReader) { 31 this.userName = userName; 32 this.logReader = logReader; 33 buildNotificationUserJourneys(); 34 } 35 36 private void buildNotificationUserJourneys() { 37 throw new RuntimeException("cheese"); 38 } 39 } 40 }
You could argue that, but I feel the exception message is adequate. Yadic prioritises constructors by arity descending. It the calls each constructor in turn until one works without exception.
Sounds good
Really? I would think that every java dev should JUST do this anyway. That is, look down through the exception messages.
"Should" != "Will" ;)
Interesting that me and Nick both did the same thing. And I've got no excuse because I'd read all the source code at the time and "should" have known how it worked.
I guess it's because 99% of the time the cause of the exception is that a dependency isn't in the container. The code naturally conditions me into believing that the exception means I've forgotten to add a dependency.
In my case, I did look down the stack, but initially not to the bottom, for some reason. I think I jumped to conclusions about what dependency was missing and then it took a while to return to looking at the stack trace after that. It was only 5 or 10 minutes of my life, but they were annoying minutes.
It's similar to the utterlyidle thing where
Path("/resource")
class Resource{}
Didn't work because of the leading slash. Total programmer error, granted, but we can be friendly about it, so why not?
Honestly, I'm not sure that changing the message will make much difference- people's brains will probably still associate the stack trace with a missing dependency. But it seems nice to try, no?
A clean 30 second change that might save (5 minutes * no. of users) seems worth it?
I'm aware this change doesn't warrant this degree of discussion, but the general topic of devexp is interesting.
I guess for me I think more about the experienced user rather than the noobs.
Noobs just to mean, haven't seen this problem before (not trying to be mean).
Noobs just to mean, haven't seen this problem before (not trying to be mean).
Happy with message change--like you said, am enjoying the chat :)