I spent most of this week, and especially the weekend debugging the Project 6 - Matrix. An apparent simple project, turned out to be only hypothetically simple until I hadn't written the test cases. And as I took a step further to write my first test case to test the constructor, the program failed terribly. Lesson: write test cases as you code the program. The project Matrix is all about using Array class that was been created in the last project, though with a twist; this time Array had to be modified to use allocator's construct/destroy method to create a stack allocated array object. The Matrix, would then be implemented as an Array of Arrays.
The lectures this week, were mostly about containers, and iterators, and how the STL are implemented. The subtleties of C++ during compile time related to various constructors, and assignments didn't make much sense until I ran into the problem of having my Matrix class to work correctly. As it was discussed in the class, the compiler chooses to use a default copy constructor/assignment operation which fails to perform a deep copy for user defined classes. In order to have a deep copy, the programmer is required to explicitly define his/her copy constructor, etc. In context to project Matrix, before I created a copy constructor for the Array, I realized that doing operation such as m[2][3] = y would make m[i][3] = y for all 0 < i < R, where m is the matrix, and R is number of rows. Having developed the copy constructor for the Array overcame the problem.
Besides completing the project, I prepared for the Test #2 for which I read a paper on Unified Modeling Language (UML). It's quite interesting to see how a variety of tools/concepts help people collaborate on a project and successfully execute it.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment