I want to talk about two things. I'm currently sick, so I hope I will write something meaningful.
1- Tetris
- My Role: Implementing the CollisionManager
As per the design, the CollisionManager was an intermediate entity between other classes. In order to perform its job, it needed to be supplied by a ShapeObject, and to be able to use methods in the GameBoardManager class.
When I started working on it, the two other classes that I needed weren't written yet, not even stubbed out. But I had to write something. Maybe someone else in another team who will need the CollisionManager methods, needs to see something written. That's exactly what I did, stubbing out my methods, writting some code and then commenting it out so that the project remains buildable, until the other classes that I needed were written.
What really worked well, is that we have agreed earlier on the APIs of all classes, and hence, there was almost nothing needed to change after the other the two classes were written. Earlier good co-ordination really paid off very well here.
- Problems:
Well, to be honest, from the efficiency stand point, a lot of things could have done much better and much faster. But during design phase, we all agreed on using all of the supplied code with out customizing it to suit our needs, and we all took the position of "Let's just get it to work"!
I have to say that this saved us going through a lot of complexity, which worked well and helped get the game working with the minimal amount of effort. Yet I can give examples of things that could have been done better.
In the ShapeObject class, in order to draw a shape, the method goes through all of these switch cases to find out what type of Shape it is, so that it can call the appropriate draw() method that was originally supplied. Again, that's totally NOT the mistake of the programmer who wrote the ShapeObject class, as he himself wasn't pleased about it. It's all due to our ealier decision of "Let's use all of the supplied code, and let's get it to work".
Another example, for my CollisionManager, and in order to detect collision, I needed access to the individual blocks of each shape to test for collision. I thought that those will be stored an encapsulated somewhere, but strangely, they were not. I had to calculate the positions of each of these blocks inside my class by deducing them from the Shape type. Again, this was done by a series of switch cases, ... very unefficient. It shouldn't be the responsibility of the CollisionManager to keep track the positions of each shape's individual blocks.
As a better solution to the above two problems, Why have just one ShapeObject class, why not have a class for each type of shapes. A Z1ShapeObject, a L1ShapeObject, ... and so on. And Each shape object knows how to draw itself (without going through these silly switch cases) and it also keeps track of its blocks positions and encapsulates that very well.
Again, it was all about getting it to work, efficiency wasn't something that we considered at all. In fact even with the presence of these many switch cases, their impact in a very basic game like Tetris is almost not noticable.
2- Smart Sourcing
I didn't read the whole book yet, I just read part one of it. I have to say, it's very boring for me to read such kind of books, specially that I'm a very slow reader. I was planning to get most of it read by Lecture day, but unfortunately I couldn't as I got sick over this last weekend till today, and I couldn't get much done. I even couldn't get much done in my final Space Invaders game which is much more worrying! Hopefully I will get better soon.
Reading the first part though, made me get the general idea that the book is trying to convey. That is, Smart Sourcing is not necessarily about cost reduction, it's more about establishing a partnership through which a company focus on its major core competency (What it is really good at) and let the other non major tasks be handled by those trust worthy partners who really know how to do those things better. This should give more room for innovation and for the company's products and services enhancement.
No comments:
Post a Comment