Tim Driven Development | Test until the fear goes away
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Tim Driven Development | Test until the fear goes away
Stephan van Hulst wrote:Rob, flow 2 shouldn't cause any problems, should it? If you add two maps to the builder, it just takes the name of the latter. And in the case of collateLikes(), the maps are guaranteed to have equal names anyway, so flow 2 would overwrite the builder's name with the same name.
I added the check in the combine() method because combining two builders with different names just doesn't make a lot of sense to me.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Tim Driven Development | Test until the fear goes away
Tim Cooke wrote:Howdy Ranchers! I have a data processing puzzle I need to solve.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Stephan van Hulst wrote:Well, I disagree with making PersonalLikes a multi-map. It's not about what is easiest, it's what things are supposed to model. PersonalLikes is a type that encapsulates the likes of one person. I think that is a good abstraction.
Tim specifically wrote:and the collation part would be that it should transform into
[{"Name":"Tim","Likes":["CodeRanch","Twitter"]}]
where the Likes are grouped by the Name.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Stephan van Hulst wrote:In the first case, PersonalLikes is a multi-map that contains the likes of all persons. In the second case, PersonalLikes is just an object that encapsulates the likes of one person. Which is appropriate is probably up to the requirements, but if it's the former, then I would skip the creation of a custom type, and just use a third-party library to return something like a MultiMap<Person, Like>.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Step 4 seems to me to be a "termiinator" function, so I doubt it can be done in one pipeline...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tim Driven Development | Test until the fear goes away
Tim Cooke wrote:In reality the data structure has more fields in it. I'm reluctant to post the exact data, it being proprietary and stuff, but it's essentially the example I gave with a bunch more fields. A bit like this with a few more fields:
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Second: Is this a recognised format, like Ajax? And if so, could you simply read it into an un-normalized list of Person (or InputPerson) objects?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:... although it seems to have been a bit "prettified" (grouped and indented) as well.
Tim Driven Development | Test until the fear goes away
Tim Cooke wrote:
Winston Gutkowski wrote:... although it seems to have been a bit "prettified" (grouped and indented) as well.
Yes, that was my elaboration for readability but I'm just confusing matters instead.
The integration point with this other system is a programmatic one so the data is received as a Collection<Map<String, String>>. Actually in reality, to make it much moreicky"flexible", the incoming data is a Collection<Map<String, Object>> but we know for sure in our application that the Map value is always a String.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tim Driven Development | Test until the fear goes away
Tim Cooke wrote:I'll experiment with both for comparison and get my team involved for a code review. I'll report back with which approach I go for, but that might not be until next week now as I've moved on to the next pressing task.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:HIH, and Stephan, if I'm wrong, do tell.
although I'm sure Stephan will tell us if I'm wrong.
I'm sure Stephan will tell us if he's around.
Stephan van Hulst wrote:Am I that argumentative?
I told the program what to do, not how to do it.
The dirty details of instantiating objects, initializing variables, and possible concurrent execution are all hidden. To me, that's the advantage of streams.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Hmmm. Maybe, but it looks quite tortuous to me. My code has a for-each loop, a couple of method calls and one if statement; and anyone with a bit of Java knowledge is going to understand precisely what it does, because it's as plain as a pikestaff.
BTW, I assume that 'groupingBy()' is one of the 3 overloaded methods in Collectors. Do you not have to supply the class name?
It also seems that you still have to supply the method names for the other stuff.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |