small medium large xlarge

07 Jan 2012, 03:45
Mike Miller (9 posts)

Looking thru the code in section 8.6, is there a reason you didn’t use a String as the message type instead of creating the FileToProcess object, which only holds a String? Both objects are immutable, so is there something else I am missing?

07 Jan 2012, 13:56
Venkat Subramaniam (98 posts)

Mike, the SizeCollector receives one of three types of messages. In the onReceive, we right now check for RequestAFile, FileToProcess, or FileSize. This would become RequestAFile, String, or FileSize. FileToProcess conveys the intent better than a String does. Also, if we add another message type which also holds only a string, it would be easier with a different type than another String we’d have to parse to decide message type. So, yes we could use a String, it’s just that with two types already present, FileToProcess seems better than a generic String. Thanks. Venkat

You must be logged in to comment