March 2012 Archives

Iteration #1 blog post

| No Comments | No TrackBacks

When my partner and I began reading the specifications for the first Iteration our first impression was slight confusion. The requirements seemed vague even though we were given most of the code for the first iteration. After reading over the specifications for the scanner a few times, my partner and I discussed possible details of how we would go about designing the scanner.

Our first thought was to make a class that contains static variables that are all regex_t types and put all of the regex's in that class. Then the scanner could just make an instance of that class and call all of its static member variables as needed to match the regex's in the Scanner::scan method. After thinking about that implementation, we discussed just putting the regex's in the scanner class itself after realizing that no other class would need access to them. One other thing we discussed is our lack of experience with C++ and how that would affect our success on the project. My partner and I have never programmed in C++ but are fairly well versed in Java. We were quite unfamiliar with pointers and general C++ syntax. After discussing a few other implementation details, we decided to put all of the regex_t types in the scanner class primarily because no other classes will need access to the regex's and also due to the fact that it seemed easier at the time with our lack of knowledge with C++.

I believe our largest challenge throughout the iteration came at this point. Having never programmed in C++ before, it was most difficult to get started. We knew how to write class definitions and such from lab so that was not too difficult however we had trouble when trying to have members in a class as well as pointers. It was quite frustrating knowing since we both knew Java and that it will take much more time to complete just because of syntactical issues. At this point we were stuck for a number of days attempting to figure out how to assign and access member variables of a class from another as well as other obscure errors. We found it rather difficult because at this point we had not gone over pointers in class yet. Another difficulty we faced was receiving complicated error messages in the command line and not knowing what each error message meant. After several Google attempts to find the errors and no success, we made several trips to office hours. Being told was each error message was for and clearing them up was a tremendous help and a boost to our overall progress. We now felt that we could actually begin accomplishing our tasks after several days of frustration.
After defining a few classes and writing a few regex test cases, we felt confident that we could now finish the iteration. However, there was just one problem. At this point we only had 3 days left to finish the tasks and we had not even begun doing the bulk of the work. After this realization we knew we had to hurry. My partner and I decided that one person would write a few test cases while the other worked on the scan function and switched off every once in a while. This worked for a small period of time until we had trouble writing the scan method. Writing the test cases for matching the regex's was easy but time consuming. We thought that our time would be better spent working together on the scan method rather than writing test cases for matching the regex patterns.

After writing a few more test cases for matching the regex's and writing more the of scan method we are at a roadblock. We were so focused on the scan function assuming that our regex's were accurate that we spent hours trying to debug the scan method only to find out that a few of our simple regex patterns were incorrect. This was a devastating blow as we know knew that we should have written all of the test cases for our regex patterns before trying to write and test the scan method. My partner and I felt a little foolish for not writing the test cases first. Once that was done and we found out which of our simple regex patterns were incorrect we finally had a chance to finish the scan method. That was not the most difficult part of the iteration as we had to change a few errors in our logic but overall it was not a difficult process. We spent close to an hour trying to figure out why it was not working only to find out that we had an assignment statement inside the condition part of an "if" statement! Once we finished the scan method we wrote a few test cases relating to the scan method and each type of regex (keyword, variable name, punctuation) and to see if the linked list of tokens worked as well as matching the correct lexeme.

As it was approaching the due date my partner and I wrote the implementation details, added a few comments to our code, and cleaned up the style a bit. At about 4:40 pm we were going to commit the iteration to the repository however we ran into a few issues using SVN. We had not had any problems using SVN up until that point but thankfully we got it in just as it was due.

Looking back on the experience a few things went very well. The first was our ability to debug the program. We had tremendous success after the initial problems of syntax debugging the program without really using any tools other than GDB. I was quite surprised at the little amount of time it took to debug our errors using just print statements. Also, after the iteration was over, I am quite happy with how my partner and I worked together. We often worked together at the same computer and talked through bugs and means of fixing them. It was a great experience on the first iteration and hopefully will continue to be a functioning partnership.

In addition to the positives there were also a few negatives. The largest difficulty was C++ syntax as I stated earlier. In order to improve for the next iteration we will always have a C++ book for a reference near so we can look up any syntactical errors. My partner and I will also look into using an IDE instead of a simple text editor to develop in so that debugging will be easier. We will also be active on Piazza as usually our syntax questions are easily answered by someone well versed in C++. Another part of the process that did not work well was our timing. We did not start early enough and we will be sure to begin the next iteration earlier so we can get passed the syntax errors and on to the actual coding sooner. We will also be sure to give ourselves enough time to commit the tag correctly in the repository! The final and perhaps the most important negative was not writing our essential test cases first before writing other functions. This lead to some terribly difficult bugs to fix and many hours wasted. Not only in this course project but for all future coding projects I work on, I will be sure to test my code as I write it.

Overall I feel the iteration went very well. We finished and all of the test cases passed! I'm sure everyone knows the feeling when you finally finish the iteration and have that feeling of gratification! I have learned more in this class so far that I use at my job that I have in any other class. It makes it much more satisfying knowing what one learns in class is applicable to the real world software development.

About this Archive

This page is an archive of entries from March 2012 listed from newest to oldest.

Find recent content on the main index or look in the archives to find all content.