Darwin
November 16th, 2009 by smm2497Expected:10
Actual: 6
Expected:10
Actual: 6
When there isn’t any OOP work to do other than read is great. Mostly because it won’t conflict with my automata work. It’s a more relaxing week and I love it. So I ended up reading all of the stuff early and mostly took the week off from OOP. Other than studying for quizzes and stuff like that. But regardless it was a nice week. Sudoku doesn’t seem hard to do. Which is going to be nice after Allocator. I’m glad we’re starting to talk more about objects which is great. I had originally hoped that the class would skip over alot of C++ basics (except pointers) and go straight to the meat of OOP and learn different techniques and implementations. It sounds like we’re going to start that soon.
So Allocator was a complete disaster. My partner was pretty good but the whole issue of pointers and different kinds of pointers was terrible. Getting the sentinels and the writing and combining of them wasn’t that bad. But then treating everything based on that type of pointer(double or int) was terrible as it would go too far or back up by 1 char pointer messing everything up. The amount of memory leaks was ridiculous. We ended up turning it in “unfinished” which was true but we got 90% of it to work so it became a question of loosing 10 points for turning it in tomorrow or turning it in now and missing maybe up to 10 ish points. We chose to turn it in early and take our chances. Having a lot of automata stuff to do ended up messing with my sleep. Huzzah. And I ended up doing really well on test 2.
Matlab ended up well, I finished it early which was great. Just didn’t implement the whole empty matrix thing.
The second test went well I think. I’m glad there were less pointer problems this time. It seemed to me that for the whole iterator question if I just copied and pasted my previous answer it would work. Other than the problem of me forgetting how to do a circularly linked list, I thought it went very well. I should be getting close to full credit.
Well this week went pretty good. MatLab wasn’t that difficult, it was mostly focused on learning what vectors can do and how they work. There wasn’t a lot of documentation on MatLab and some of the requirements I felt were vague, such as what to do with empty matrices and what they are. I finished it rather quickly which was nice. I wrote a lot of unit tests which is good. More than I usually do for the projects since I let the input text be the testing of it and since a lot of the methods I write can’t be tested well due to me not fully grasping the C++ language yet. Eh… that’s all.
Eh… This project didn’t go so well. Didn’t finish on time because my partner got really sick and couldn’t make it so I had to do it all my self. We spent the previous day working on reading in the string of votes, parsing it and dealing with newlines and EOF’s. And we didn’t get that part to work at all. I really hate C++’s input methods. I’m not sure why it can’t just do char* s = getline(); array of ints = s.split(” “); That’s all is really needed. Which is the problem, it’s I/O is too low level for me to write useful code other than parsing input because I’m spending so much time on parsing the input. It’s a headache. Also was a headache was creating arrays on the stack of different sizes. Yea. C++ doesn’t like that. Also I wish Downing had gone over 2d arrays and returning arrays from functions first. I’m assuming everyone else did this as well on the project. Creating a lot of globals because of not fully understanding how arrays work is not fun. And it led to some terrible code. Huzzah?
For those that know I work for Crossroads Systems as an intern. My job is mostly to write unit tests for their code. Unit testing code is a very very useful thing to do. I’ve primarily deal with code that was never designed to ever be tested. So I am quite good at dealing with code with high complexities, calls to exit(), and system calls. So I can really deal with just about any code.
So what I want to say about code coverage of unit tests is this. It is useful in helping find holes in your unit tests where there is not a test case. While code coverage tools are not perfect in finding all holes it does help to find the ones where you may not see them.
Unit tests should try to cover nearly all possibilities that a function can do. When writing them, it is best to try to break the code and designing edge cases. For example when you have a function that tries to find the minimum element in the array and you are sure that it can never be 0, set it up so one of the elements is zero to see how the code deals with it.
But I digress. I’m going to show you how to run GNU’s code coverage tool on C/C++ programs. As an example I will be show how to do it with main.c++.
On the linux machines when you have all of the tests running and hopefully passing run these commands:
g++ -ansi -pedantic -fprofile-arcs -ftest-coverage -lcppunit -ldl -Wall -DTEST main.c++ -o main.app
So I missed Monday because of the career fair. It was pretty sweet of Glenn not having a quiz. But yea, I spammed my resume and Oracle was I guess desperate enough to want me and I interviewed with them on Tuesday for a consulting position. It went pretty well I think.
But yea, I thought the test was pretty good. I learned to memorize the textbook from CS373 for questions about the book so I did well on that part. The only problem I had was the post increment and pre increment part. It’s one thing to use pointers and references in a straight linear fashion and a different thing to take them in as parameters and being returned. So I knew I had the right idea but the implementation would be off. I wish Glenn would talk more about that part before giving a question on the test about it. But eh. I probably did well.
This week went pretty well. The project I had done before in java and python so I pretty much had a solution already. And it turns out I did. I ended up getting a running time of 0.020 on UVA which was twice as fast as my Java version. So I guess C++ does run faster than Java. I don’t really remember my partner’s name. Sorry if he’s reading it but we only met for like an hour or so.
So far I’m enjoying the class. Not too bad. But all the stuff so far is primitive stuff. No real objects or anything with pointers yet. So it’s not so bad.
The quizzes seem to be going OK, nothing spectacular.
So yea, the 3n+1 project went somewhat well. Dumping all of the output into one file for valgrind made me realize that the default shell on the linux machines wasn’t bash but tcsh. The cache works well. Also I seem to have forgotten that the input can come in higher and lower order than just lower and higher and it took me quite a while to figure that out and set me back a few days. But other than that everything went fine.