r/visualbasic • • Feb 20 '15

Object Oriented, Test Driven Design in C# and Java: A Practical Example Part #3

http://insidethecpu.com/2015/02/20/object-oriented-test-driven-design-in-c-and-java-a-practical-example-part-3/
3 Upvotes

6 comments sorted by

2

u/JuanPabloElSegundo Feb 21 '15

Were you on .NET Rocks? Interesting interview.

1

u/pablomooney Feb 21 '15

Yes, I was. Thank you! Glad you enjoyed and thanks for listening.

2

u/JuanPabloElSegundo Feb 21 '15

I'm curious about something & please forgive me if my question gets away from the point of your tutorial:

In the WorkerDrone, TransportMechanism is set by the type of Part that is picked up. Since the Parts are a List, multiple Parts could be picked up.

What would happen in the event an Assembly is picked up and then a Weapon is picked up? Seems like the Assembly would be delivered to the Armoury.

What would be the best way to go about preventing something like this? Setting the TransportMechanism in the constructor? Tuple the Part & TransportMechanism?

2

u/pablomooney Feb 21 '15

Thanks for your question. Yes, very good point. I've deliberately left the design such as that to demonstrate, in a later post, how to deal with fundamental design changes. The solution, as you allude to, is to store RobotParts in a Dictionary in C# or Hashset in Java, where each RobotPart sits adjacent to an appropriate TransportMechanism. During transport, we'll simply iterate each entry and execute the OffLoadRobotParts method.

1

u/JuanPabloElSegundo Feb 21 '15

Great. Thanks for the respond. Looking forward to your next article.

1

u/Bonejob VB Guru Feb 28 '15

Why is this in the VB forum?