Thursday, April 26, 2012
Assignment 4 DataDriven
See I said I would get it done on time this time around!
Anyways, this took a lot longer than the other assignments, but I understand the concept I think. Shove instructions into a queue and then have a generic processing function take out the instructions.
I ended up learning a lot about some of the underlying stuff for c#. I have worked with it before, but I don't I have ever understood too well till now. namespaces are nifty little things I dare say. Also that all structs are actually derived from a single type called Object. That's kind of really freaking cool.
So yeah, for the most part. The test code that I used is the exact same as the test code given to us. That is... till I got to the interleaved part.
I was pretty confused on how the code was written, it didn't make a lot of sense to me. So I simplified it in my eyes at least. It does the same thing though.
I only have 1 queue instead of 3 and it is a queue of Objects. I just enqueue all the data as it is and then during processing I just check what type it is, Calc_Data or FSM_Data, and then typecast the Object Data and then doWork() on it. I honestly think it is pretty convenient, though I don't think you can do it like that in any other language since it abuses the all structs are Objects thing. Or maybe I'm wrong about that? Who knows, I'll get to it as it comes.
I don't know how efficient it is though because of the getType() calls, so that might be an issue if there was a lot of it.
I guess the other way would be to enqueue the two different types into their own queues, then have the interleaved q as a kind of marker q for the order that the stuff was put in and then during process you could just dequeue the interleaved q check what what type it was, then from that, dequeue the correct other queue. Though I think the dequeue calls would also be expensive so I dunno.
Pondering.
OH well. I got it working so I'm with this for right now.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment