Monday, December 10, 2012

Week 15 - Wrap Up (Dec 2 to Dec 9)

The final week of the semester has come and gone. This is the 7th time for me. One more year before I graduate and what I can say looking back is that I have somehow managed to find less time for myself with all of my classes. I feel like I keep taking fewer and fewer hours every semester, and I end up with more and more work.


The last test was trickier than the previous tests in my opinion, but that was to be expected because the material gets trickier and more nuanced as the class goes on and we have had less time to experiment and learn those concepts than we had for earlier concepts. I think the tests were fair. Although the daily quizzes could be a bit of a nuisance when the quizzes didn't cover the day's reading -- especially when a quiz covered a reading from several lectures ago and that reading is not fresh in your mind. Overall, the quizzes were another good tool to keep people on track with the material, encouraging students to study the tricky topics between every lecture, rather than waiting until the test is imminent.

Lectures



Overall I have a pretty positive opinion of the class. The lecture style was good for keeping everyone alert and learning, and was extremely clear. The papers were excellent reading. (The textbook on the other hand was dry and outdated.) The projects started off very simply and taught us the foundations of C++ and Object Oriented Programming (OOP), and then built upon those concepts. I wouldn't say the projects were particularly challenging on average, with the exception of the last project. Mostly they involved learning a simple concept and then building around that. I feel like I learned a lot about C++ and got some valuable experience and knowledge about C++ that benefitted me immediately because I was taking Computer Graphics this semester as well, wherein all the projects were in C++. Some knowledge of the trickiness surrounding certain concepts in C++ like copy constructors and copy assignment definitely bailed me out of some tricky problems that I saw other students [who had not worked with as much C++] struggle with. Immediate payoff is very validating.


One negative to the lecture style that poses a lot of questions to the students is that the learning is very instructor-driven, which can be a bit stifling to the types of learners that would prefer to digest an idea, interact with it (perhaps by experimenting with the code), and ask questions which explore tangential subjects. There were definitely topics that could have been explored in more detail and I wish I had been able to ask questions in the heat of the moment but we move pretty quickly through every detail that it's hard to really slow down and address some possibly interesting questions.

Programming Labs 



The programming labs were generally a good learning experience, at least as far as the implementation of the project was concerned. I understand that testing is important, but the fact that I spent nearly half of my programming hours devising unit tests is, I think, a problem. For instance, sometimes you want to create a function which encapsulates some extremely simple functionality. Maybe it wraps another method. There are a lot of circumstances where being required to write 3 unit tests per method, no matter how simple, is extremely frustrating. There are also functions which don't lend themselves to unit testing at all. For instance, functions that generate text output. Instead of writing directly to the console or a file, I found myself constructing strings in the unit test code which have to exactly match the output of the function, down to the number of newlines. Isn't that what acceptance tests are for? Weren't we running acceptance tests anyway?

I would recommend slightly relaxing the requirement for unit testing. Default constructors shouldn't need testing. Constructors which do trivial assignments of arguments to variables in the class and no other code, really shouldn't need testing either. Functions that output text shouldn't need testing. Functions that simply return the value of an instance variable most likely don't need explicit unit testing. The threat of getting a serious reduction in the lab's score scares us into doing all of these things, rather than focusing on unit testing the functions that are likely to be incorrect, and especially the functions that are more likely to break as the functionality is extended.

I even became aware that some people were attempting to circumvent the requirement to test all their methods by making "simple methods" into complicated #define macros! They engineered around the problem of testing simple code, but ironically they made their "simple" code much more likely to break (and more difficult to debug)! I hope examples like this help to expose the flaw in the requirement, and that the requirement will be relaxed to be something like "write at least 3 unit tests for non-trivial methods" (and define trivial methods as you see fit).

For Computer Graphics, I spent about 40 hours on one project. This project had many parts, and a lot of opportunities for exploring and expanding the programs for extra credit. Every half hour or so you feel like you solved an interesting problem, added a small feature, or fixed a funny detail of the code. I don't view any of that time as wasted, and it was so rewarding that I actually plan to continue to work on several of the projects from that class. Unfortunately, I hardly remember my solutions to any of the projects in this class except the most recent one, which I will surely soon forget the details of.

Sadly, the projects for this class were simply not inspiring. I suppose that is to be expected for a class which is essentially an introduction to C++.

Skills Learned



Skills we learned in the class:
  • C++
  • CppUnit
  • Git/Github. I like that there is a class which actually requires using source control in a sane way (i.e. not in a way that involves pushing to an repository that belongs to the instructor, for instance, where you don't have direct control over problems that arise). Using a VCS, especially a DVCS, is a good skill to have. My opinion is that Git should be required for programming labs beginning with a freshman- or sophomore-level required class.
  • UML Diagramming. Nice to do, not too time consuming, good for designing solutions to OOP projects.
Skills we should also learn in the class (since we're already making the effort to learn Git):
  • Make (Makefiles). This doesn't even really need to be explicitly taught. Providing a Makefile with the project would probably be enough. Students will be smart enough to figure out how to update a simple makefile to add to the list of files that get compiled. My Graphics class did this and it worked very well. This allows students to turn in a project without worrying especially about how their files are named, because the grader will simply run "make" instead of a predefined build command, using the students' Makefiles.
  • Multiple-file projects (when you have a lot of classes, we should make additional C++ files and update the Makefile as above -- also, executable code should be by-and-large in .cpp files, not in .h files. Even though the latter makes compiling much easier, it is bad style and confusing to teach this way in a class where most students are seeing C++ for the first time.)

Workload



There are some classes that are really hard, and that difficulty translates to the time you're likely going to spend on projects and studying. And then there are some classes that are just very time consuming. I've had some of both in my time at UT. I'm happy to say that there is less busy work as time goes on, and that as the classes get harder they also get more interesting. I very rarely find that the projects I do these days are a poor use of my time.

Unfortunately, this class toed the line between productive learning experience and busy work. The first labs were helpful to get oriented in C++ but they took way too many hours for what they were. For the first couple of labs, 75% or more of my time was spent writing unit tests, or updating the issue tracker in GitHub.

I think the class website is very accurate about the amount of time you'll spend on this class, in all categories. I was just a bit disappointed that the hours spent programming were mostly spent in mechanically devising unit tests, rather than in solving interesting problems. I wouldn't have minded 20-hour-a-week programming assignments if the assignments were legitimately interesting, as they were in computer graphics.

I expected more interesting and inspiring projects from a class which is numbered as Senior-level (371) and named "Object-Oriented Programming." Most of the OOP we covered in this class is covered in a standard Data Structures class taught in Java, and there is so much more to learn about OOP. I wish we had gone into more depth in that regard.

I know I sound like I'm complaining about the class more than I am praising it. Simply put: what was good about this class was good, and there's not much more to say about it. In fact, most of the class was good. I'm simply hoping that students who take this class in the future will benefit from the professor's consideration of these criticisms.

Sunday, December 2, 2012

Week 14 - Off to the Races (Nov 26 to Dec 1)

This week was the combination of too much to do and the premature celebration of the end of the semester.

As we approach the end of the semester we all tend to get sucked into festivities. Celebrating the last midterm before finals, going out with your clubs for banquets, and hanging out with friends and playing video games because you can afford a little break. It doesn't always work out that you can afford that break, but you try to fit it in anyway...

So, this week, my honor society had officer elections -- which tend to drag on and on every semester (but at least there's free food!). Of course, I ran for President, and although I know I wouldn't be a horrible choice, I lost to a better candidate for the 3rd semester in a row. I wouldn't say I wasn't trying, but not getting elected is a favor to me because it means less unnecessary responsibility for next semester. I'll still have one more chance before graduating next December.

On top of spending an extra 3 hours for elections on Wednesday night (yeah, pretty inefficient), I had an exam on Wednesday afternoon in my hardest class, Computer Architecture (EE 460N). And of course, I had the Life project to finish.

Between working alone on this project, and Thanksgiving holidays filling up the weekend, I was no where close to done with the project by Wednesday morning and I REALLY needed to study for my test that afternoon. I was fully prepared to submit my half-baked solution on the project so that I wouldn't get a zero and I could just move on with my life, but when Professor gave us a key piece of code we needed for the project and announced a 24-hour extension, I felt like my life had been saved.

I managed to get the project done after spending several all-nighters this week, and ended up missing rehearsal because I took a nap that ran too long, but I think in the end it was worth it.

Next week I have a paper, two projects, and 3 tests. Gonna be FUN! [1]

[1] For certain definitions of fun.

--------

I've learned a few important lessons from this week:

* Don't take holidays for granted. Make sure you get your work done ahead of time or your neck will be on the chopping block.

* Don't work alone if you're given the option to work with a partner (unless you can't help it). The time you save just by having someone to keep you focused and prevent you from spinning your wheels is probably even more useful in a college setting than in a work setting, because HERE we are surrounded by a million-and-one things to distract us, not the least of which is our other classes. On the other hand, I didn't feel guilty about spending some time exploring some other concepts of the class which weren't strictly necessary for the project, because I didn't feel like I was wasting a partner's time.

* It's okay to make sacrifices for more important things. I'm going to go into more detail about this one, below.

If I had tried any harder to get the project done on time instead of studying for my test, I probably would have failed my test. As things were, I was well-prepared for both my test and the officer election. I would have learned the material from the project one way or another and I probably could have afforded that setback in my grade for this class. The test was way more important.

I also went into the Thanksgiving break knowing that it was important for me to spend time with my girlfriend, my parents, and my best friend while I can, and I will cherish the memories of a nice relaxed Thanksgiving break in the long run, no matter how I ended up doing on the project.

See, the things that stay with us in the end are the good memories, and those silly little setbacks we have along the way will always get buried in more important memories. Maybe you end up with a mediocre grade on your transcript, but 10 years from now you probably won't remember exactly how that happened.

Do what you need to so you don't fail your important classes, and no matter what grade you get, make sure you learn the material that is most important to you at the end of the day. Maybe it's okay to blow off a homework assignment every now and then so that you can take a sanity break and play some of that video game you bought in the Autumn Steam Sale. But remember above all to make time for the stuff that's important to you and the people you love.

Some wisdom from a legendary philosophy professor:
http://www.pickchur.com/2011/03/golf-balls-in-the-jar-the-philosophy-professor/

Monday, November 26, 2012

Week 13 - Thanksgiving Break (Nov 19 to Nov 25)

This past week was Thanksgiving week and that means that we only had one day of class. Unfortunately I couldn't leave campus before Wednesday evening, due to a computer graphics project which for some reason I was unable to get to compile on either my Windows or Linux machines.

Anyway, during the break, I was able to find some time between eating and socializing with my family and friends to try to digest the project. I got a good start on the ConwayCell and FredkinCell classes but I'm not sure I really have a sound strategy for the Cell container class. I think I'll be able to figure it out but I'm hoping for a bit of a class discussion to recap the intended function of Cell, since that's obviously the core challenge in this project, and I want to make sure I understand it before I spend a lot of time trying to implement it and later finding out that I did it totally wrong.

---

This class has won me over as a convert from Mercurial to Git (in certain situations). I still feel the same way about Mercurial, though: it is much easier to learn, it is much simpler to accomplish basic tasks, and it works infinitely better on Windows for much less effort. However, I was working on a project in the Linux computer lab and since my Windows dev box crashed this week, I knew I would only be working in Linux. So, even though all my other graphics projects used Mercurial, I used Git for this one, and found that the power and flexibility it gave me was worth the extra complexity in the commands.

The use case for Git in this situation was more like insurance that I would always have a recently saved, working version of the project, which incrementally implemented more features. Essentially, in this case, there would be no branching and merging, and it was unlikely I would want to revert, so I was using it for its most basic features. Once you start getting into the more complex stuff, I think that the analogy

Mercurial : Git :: Python : C++

You give up a bit of power for expressiveness, but when you need to execute complex tasks quickly, the expressiveness is what you are going to care the most about.

Having gotten comfortable with both systems, I feel like there is actually very little difference in the actual functionality, and my preference for which one to use is going to depend mostly on the project's platform. If I'm on Windows, I will still hands-down prefer Mercurial. On Linux, it will depend on what I need my VCS to do for me, and how I plan to use it.

Sunday, November 18, 2012

Week 12 - Taking it Easy (Nov 12 to Nov 18)

This past week was pretty mild across all of my classes. I got to celebrate my birthday in peace, and since the deadlines for my projects are somewhat more spread out this time around I finally have a chance to relax and work through the projects relatively slowly. I can finally be careful not to miss out on the details.

I'm enjoying the discussion in class, although if you asked me to group the lectures into one phrase I wouldn't be able to say, exactly. I guess that means I need to review the material a bit more.

I'm looking forward to working on the next project alone. Compared with working alone, pair programming has been more interesting, in many cases more fun, and sometimes more productive. However, with Thanksgiving break coming up I think it will be easier for me to work on the project on my own time rather than try to squeeze in time to work with someone else. And this will give me a chance to see how programming on my own for this class stacks up against pair programming. I imagine I will struggle a bit more, but I am looking forward to the challenge.

---

My desktop computer's HDD is malfunctioning a bit, but it hasn't been too much of a problem yet. I'm keeping regular backups in case of imminent failure and I've ordered a replacement. I'm just not looking forward to having to set up my computer from scratch again in the middle of the semester. It shouldn't take too long but it's definitely time that could be spent studying or working on my projects. I hope all goes well with the hard drive replacement and OS reinstall.

Sunday, November 11, 2012

Week 11 - Private Testing (Nov. 5 to Nov. 11)


Another week gone. I'm glad to be done with the second test. The most recent project was pretty rough to get through as I had several projects due Monday, Tuesday and Wednesday evenings, in addition to the makeup test on Monday. Another thing which made this project somewhat difficult to get through is that I had implemented a more complex form of this same project in CS 315H a few years ago.

Fortunately, my partner Zesen was very accommodating of my schedule and we were able to complete the entire project without too many hangups.

I enjoyed the design component of this project. I would have expected that more of this course would involve designing classes and actually writing code in object oriented style, but the amount of experience I'm getting with C++ is also very valuable, even if it's not precisely what I thought I was signing up for.

My birthday is Tuesday, so I'm happy that this week is going to be relatively light for once.

---

I read a blog post about how unit testing private functions is supposedly evil. The primary argument seems to be that you shouldn't care about implementation details when testing, but I think that is a somewhat closed-minded approach. There are many algorithms that have a very simple public interface but which might contain relatively complex components in some implementations that should be tested individually. It could be rather difficult to know if the test of the public interface is getting good code coverage, or it may be extremely difficult to construct tests which adequately test the nested components. More likely, the algorithm is so complex that in order to make it readable, and thus maintainable, you would want to refactor the method into several utility functions. Sometimes refactoring makes sense because a number of public methods may have to handle the same functionality and thus refactoring private methods allows for code reuse, which is always a good thing.

About that latter point, the writer of the blog had stressed that if you find the need to refactor relatively complex behavior into private methods, why not refactor that same functionality to public methods in a helper class, so that the functionality can be tested in that way? I can't even think how to rebut that point except that the author seems to be missing the point. Some of these private methods might modify the state of the object directly, and do so in such a way that calling these functions without executing any other part of the algorithm might leave the object in a bad state, or a state which doesn't make sense from any external interface.

So yes, I agree that unit testing functions which are not part of a public interface will break encapsulation, but it seems that this author (and many others) are saying that these methods shouldn't be tested at all!

I think that any sufficiently complex implementation warrants tests of one kind or another. Perhaps I can simply write a static method, check(), which runs a bunch of "unit tests" on the private methods of a class. Calling this method will create instances of the class as necessary and test behavior of the implementation details that warrant testing. The method will return true if the tests all pass, and the method will be meaningless to anyone who wants to just use the class rather than verify that it passes its own correctness checks.

Of course, this method could be removed or conditionally-compiled out in production code to clean up the interface. If it is removed though, the information about the correctness tests on the class disappears and this seems like a poor option. I wonder why no one has devised a test framework which allows the testing of private methods, even if the philosophy seems to be that it would be a bad idea. If it's such a bad idea, shouldn't developers be allowed to shoot themselves in the foot if they so desire? I hardly see how this would be the case, but it seems there is enough of an argument for unit testing private functions that the functionality shouldn't be so easily overlooked.

Here's an article which summarizes the pro's and con's of private testing:

I think my final opinion on the matter is going to be the one which seems most in line with the unit testing philosophy, and is the opinion that I started off with: "Anything that can break, should be tested." Furthermore, those tests should be as direct as possible and not have to go through the middle layer of a public interface, if the code in question is in fact a private method.

Sunday, November 4, 2012

Week 10 - Fall Back (Oct 29 to Nov 4)

This program has forced me to look at things in a new way. I disagree with the design not through feeling that the expected implementation is wrong but that it lacks the kind of features I would expect to see in a reasonably complete program. I feel like the structure of the programs in this class require a minimum of implementation work and the amount of emphasis on testing is taking us away from the actual concepts at hand now. At first, it was good to have us focus on unit tests, but now the fact that unit testing is mostly a pain has caused me to limit my designs in some pretty serious ways.

In the real world, would you really unit test a method with a trivial function? Probably not.

Anyway, the make up test was once again moved from Friday to Monday. This is again outrageously inconvenient for me with the mass of projects that I typically have due at the beginning of the week. This time my project deadlines are going to keep me from studying for the test, or studying for the test (and taking the test) will prevent me from making my deadlines. I know there's not much you can do but to plan ahead but when every minute of your week is already absorbed in other school things there's not much you can do.

Senior year as a double major sucks because even if you take the minimum number of hours possible, you still don't have time to sleep.

Sunday, October 28, 2012

Week 9 - Burnout Recovery (Oct 22 to Oct 28)

This week opened up with a nice hearty exam. The kind of exam that is designed to be so unlike any previous exam or homework ever given in the history of the class so there's absolutely nothing you can do to study except know the material inside and out and pray.

I can see the pro's to giving a test like that but overall it seems a bit unfair when you can look at your test grade and say: When I practiced with the test that was given last year, I aced it without studying, and then after studying for days, I failed the actual test? What? There's too much variability in what people will know after studying that some people get lucky and other people get screwed.

---

Luckily, OOP has reasonable, well-designed tests by comparison.

But after finishing up project 4 and recovering from the last couple of weeks of not getting enough sleep and being totally burned out, I look back on this test and it seems similarly inconsistent. Luckily when it's a project you're talking about, it's much easier to sort out the confusing issues over a long period of time but what I'm talking about is design.

I find it hard to believe that the same professor who teaches a software design class would also teach a class where good design is so readily ignored. I'm sure not a single student in this class who has ever worked with C/C++ would say that the way we're organizing the code in a reasonable way. We write all of our code in a single .h file! I mean, I understand that this makes it easier for the grader in a sense, but it makes it much more difficult for the students to deal with, and we're learning bad habits.

We've gone through the effort of learning Git/GitHub, Doxygen, UML diagrams, etc. And for some reason, we aren't using Makefiles? Why not provide us with a simple Makefile for every project and explain briefly how it works, and tell the students to update the Makefile with additional source files and header files as needed, and then encourage us to use that. Then the grader only has to type "make" and then he can test our programs. So, rather than requiring a set of files and ONLY those files, we can turn in AT LEAST the required files and any code files needed to compile our programs. This way we are free to design freely and organize our programs in a way which makes the most sense for our implementation.

In earlier projects this was a minor inconvenience, but in the next project, we are given no starter code or guidance for how to design our custom creature, "Best." I would like to put all the creature definitions in files and have a constructor which takes in a filename and reads the creature from the definition. I have no idea how they're planning to test the creatures since they said to just put the definition of the creature in the comments of the code. This doesn't make any sense.

Normally I can get around the strange restrictions the project turn in policy has been putting on us but when we're kept in the dark like this, I feel like it's very likely we're going to lose a ton of points and not know why until it's too late.

Even asking on the class forum for help hasn't yielded any usable information. =[

Pressing forward...

Sunday, October 21, 2012

Week 8 - Week of Project Hell (Oct 15 to Oct 21)

This past week has been absolutely awful for me in school. I had Comp Arch, EE Senior Design, and Graphics projects due Monday, Tuesday, and Wednesday respectively. I hardly had enough time to get any one of those projects done, but somehow managed to do it amidst many all nighters AND performing in the University Orchestra concert on Tuesday night.

After finally turning my Graphics project in on Wednesday, I was so used to not sleeping much that I couldn't sleep until 5am. From then until now, I've pretty much been sleeping at around 4-5am, all while trying to get organized and regroup for my Comp Arch midterm on Monday and get my sleep schedule back to normal.

At least I started getting more sleep after Wednesday night, even if it was at an odd time. One drawback of sleeping so late is that you're likely to miss class. Which I did. That's 3 missed quizzes. I have to start treading lightly.

Luckily the material in OOP is starting to feel more coherent and I'm doing better on the quizzes. It's a shame that I missed Friday's quiz because I heard it was pretty straightforward and didn't really cover the reading.

I'll definitely make sure that I'm caught up on the reading by tomorrow morning, though!

Monday, October 15, 2012

Week 7 - Midterm Week (Oct 8 to Oct 14)

Well, this week has been a roller-coaster of good and bad happenings in school. I had two midterms this week, several projects, and an orchestra concert coming up this week (and the week before a performance is always really stressful).

The makeup midterm for OOP was on Monday. I really would have preferred the Friday the day after the original test date, especially since we didn't have class on that day, anyway. I had planned to take the midterm on that day and I was really surprised when it was moved later. I know many people would welcome the chance to spend more time studying, but the problem with moving a midterm closer to another midterm is that you have to spend some of your time studying for each and you don't get as much quality focus time on one thing. Luckily the results were good.

Unfortunately the morning following my late-Monday exam was my graphics midterm. There is only one midterm for that class. Due to a bad test environment (especially the very sick, noisy, and smelly guy that sat next to me for the test and distracted the hell out of me), my grade will be quite bad. I am very worried about that class now and I originally thought it would be totally fine.

Tuesday afternoon and evening, struggle to finish Project 3. It's really hard to know when you're done without good acceptance tests. The unit testing was also rather difficult for this project because you're essentially limited to the common interface with std::allocator. Once you can "cheat" to make everything public and you can test the internals of your implementation, writing tests for it is ridiculous because you have to know how the heap is supposed to look and then check whether it matches. Very very difficult to test, indeed. My normal inclination to be thorough ended up wasting a lot of time because it was hard to come up with things to test.

I've enjoyed the quizzes lately. I did reasonably well on that portion of the test, and we're getting a good look at C++ under the hood. Since I am using C++ in Computer Graphics, I have sometimes wondered if knowing this much about C++ is actually a good thing. I find myself wondering whether the default constructor is good enough and wasting some time trying to get things to work because I implemented a non-default constructor, and lost the default constructor as a result and had to spend time implementing a reasonable copy constructor and copy assignment to make sure everything gets assigned properly. C++ definitely takes a lot of work to really understand what's going on.

Friday was the due date for a big project in computer graphics. I skipped some classes on Thursday and Friday to work on it and finish the whole thing by midnight, and just barely got it working to my satisfaction when it was announced that the deadline was extended 5 days. WHAT? Now I have to spend time catching up on the classes I missed to finish the thing on time, as well as dealing with two new projects (not even counting OOP), and I can't even take advantage of more than a couple hours of the extended deadline. What a waste.

Midterm weeks are terrible. I've got another one coming up, and I don't think I'll even be caught up from last week yet.

Wednesday, October 10, 2012

Outlook Crashes from Youtube and Google Drive emails

Even though I seem to be the only CS major outside of industry who uses Outlook, I feel like I have to say something about a ridiculous bug related to the fact that Microsoft and Google don't know how to share their toys.

Now, Outlook is an industry standard application. It supports all the standard email formats, and it's got a bundle of cool features besides that. It's more than just an email client. I essentially use it to manage my life, calendar, and contacts.

Google has apparently decided that standard email formats aren't good enough and is now sending emails through its services (Google Docs and YouTube are the ones I've encountered so far) which do something "special." The emails work just fine in web browsers but when opened in Outlook some script or something related to fetching a user's Google avatar causes Outlook to crash.

These videos show the problem and a simple fix:




If you use Google Docs / Google Drive, you'll also have to add docs.google.com to your block list.



I would think that there should be a way you can set up a rule to move these emails to a folder and then set  that folder to display emails in plain text, the way the Junk email folder does, because I don't actually want these emails to be Junk, but this is the only workable solution I have found for now, since it is an incredible waste of my time for my email to crash every so often when I get a new email from one of these services and "open" it by switching to my email tab in Outlook, and finding that the preview pane has tried to display my most recent email, and Outlook has now crashed.

I'm not sure we can expect a patch from Microsoft because they're busy with the next iteration of Office and until this looks like a security hole, it won't be high priority. Google, on the other hand, can cut out the fancy crap and send me the emails I want without all the nonsense scripting garbage.

Sunday, October 7, 2012

Week 6 - Pair Programming Round 2 (Oct 1 to Oct 7)

Yesterday, I posted a blog which goes into some depth about const expressions in C++.

Since Andy and I recently encountered an issue with "const" in our project, I will add an extra comment about that here. Note that you can add "const" right before the opening brace of a method declaration, which tells the compiler that the code in that method will not alter the state of the current instance of the class.

Since a[] is an instance member of class Allocator, "bool valid() const {" says that it won't try to modify the values in a[]. Depending on how you write validate, you might run into the situation where the compiler complains about something like:

char* first = &a[0]; // error

So the simple solution to that is instead writing:

const char* first = &a[0];

Note that this is a side effect of the compiler trying to protect you from making unintentional changes to a[] inside of a function which says you won't modify it. In a non-const function, the first version would be okay.

Technically since valid() is a private function, you can change its interface to not say "const", but I would recommend against that because they provided the method stub for us.

Project 3 So Far



Going into this project I was a little less enthusiastic going into previous ones, because in CS 439 last semester, I implemented a memory allocator (specifically, a malloc package) using this algorithm (and also a more complex algorithm that uses a O(log(n)) algorithm for selecting which free block to use (to improve performance for a workflow involving many alloc()'s and many free()'s in an arbitrary order)).

Basically, I felt like I had already done this project and that it would be a waste of time.

I'm pleased to say that it definitely wasn't! Working with Andy has been a really pleasant experience. Since I already knew the project really well, I had the opportunity to really slow down and explain how it worked to someone who is really willing to absorb and learn.

Also I have the chance to slow down and make sure that the whole thing is adequately tested and documented.

The cool thing about this project is seeing how templates let us take the same unit tests and apply them to different implementations of the same interface. I like Java generics a bit better in this respect because you can declare a generic with a certain type or interface and any class which subclasses that class can substitute in, but in C++, you don't exactly get that sort of information. As long as you know what you're doing, however, that's not too much of a problem.

One thing which saved us a lot of grief in this project was modularizing the code A LOT and using macros for common "gestures" like finding the header and footer of the previous and next block. Once nice thing about macros is that even though they appear to be functions, they can be used as lvalues as long as the expression works (like you have a pointer p and you have a macro which does *p, which is an lvalue).

I wonder if there is a way to make the return value from a function act as an lvalue. There is probably a trick with references that can be used in that situation.

Convoluted Const Expressions

A past manager of mine once asked me an interview question, for fun. He asked me to describe the type of something like the following:


Boy, am I glad I already had the job! I was totally lost, and at the time, I only vaguely understood his explanation of what it all meant. Of course, it always helps to have a compiler around to fiddle with.

After what we've been covering in OOP class, however, I thought I would have another shot at understanding this cryptic statement.

Not surprisingly, Wikipedia has a wealth of knowledge on the topic. I highly recommend reading through it if you're curious. It discusses how types and pointers are made immutable in several languages.

I also found a more "human" explanation. It's a bit less organized, but you also may find this to be a useful explanation.

Const Data Types



So with that preamble out of the way, let's get down to it.

Here's a brief sample, adapted from the blog entry I linked above.


I only want to explain the syntax, below, but these lines are part of a complete file (const.cpp), which shows these types in action. You can compile it and see for yourself.

Here's the intuitive way of looking at the types above:

You can split the whole type statement into two parts.
(1) the part before the star
(2) the part after (and including) the star

If the const is before the star, then it means that the data is constant. If you have a normal type, you cannot alter the data (making it a constant!). If you have a pointer or reference*, you cannot alter the data it points to.

If the const is after the star, it means the pointer is immutable -- you cannot change the address it points to. This means that the pointer is always bound to the same memory address, and you cannot change it, similar in effect to how a reference is always bound to the same location in memory.

* In the case of references, just use the ampersand as the delimiter instead of the star and the same discussion applies. However, placing the const after the ampersand is redundant because you cannot reassign a reference anyway.

I highly recommend playing with the code I linked above (const.cpp) to get a feel for what's going on.

The Interview Question



So with that information in mind, I'd like to revisit the interview question. Here is the question again, for reference: "Describe the type of 'ptr' in the following expression:"


We don't quite understand the syntax well enough yet to really answer this question, so let's take it back to const syntax and note a pattern.

When declaring a pointer (rather than its data) as const, you place the const after the star that it refers to. So if that's true, then why don't we also put const after the data type?

Well, actually, you can. These two variables have the same type:


The const keyword can always follow the type it refers to. For pointers, that's the only way you can do it. For the data type you have the option of putting it before or after. Putting it before helps with readability, so that is the preferred style.

Putting it together: a and b have the same type in the code below. c is illegal.


Armed with the new knowledge, let's revisit that interview question:


The last two lines above have the same type and point to n. We were given a, but b might be easier to figure out.

Reading from right to left: we have a pointer to an immutable pointer to an immutable int.

Some popular wrong answers my manager would get include:
1. Constant pointer to a pointer to a constant int.
2. Can you even do that?

#2: Yes you can!

And to be clear, if you wanted to get #1, you could write:



Awesome!

Sunday, September 30, 2012

Week 5 (9/24-9/30) - Cruising Along

For over a week I've been up against deadline followed by deadline. Following the submission of the Collatz lab on Wednesday of Week 3, I had to write an assembler for LC-3 for EE 460N (the ECE Computer Architecture class), which took me all the way until Sunday night, with the project due Monday of Week 4. That Friday, I had a computer graphics project due, which took almost all of the rest of week 4, but I had to also find some time to work on the Voting project, since pair programming isn't exactly something you can cram in at the last minute...

End of week 4, I attended the ACM LAN party right after turning in my graphics project and then got started on the next computer graphics project due Monday. OOP due Wednesday. Graphics due Friday. At least I got a cool 2D Billiards game out of it.

But by Friday's OOP class I had pulled so many nearly-all-nighters (3-3.5 hours of sleep per night), I was exhausted and fell asleep in lecture. I'm glad I wasn't called on. Or at least, I hope I wasn't called on...

Anyway I caught the gist of the lecture, a discussion about the next programming lab. I've written a memory manager in CS 439, and studied an implementation of a memory manager in EE 312, so I'm sure this project won't be too difficult to understand. But I know better than to think that it will be a short project.

With the midterm coming up, I can feel the panic rising. I'm not actually panicking yet, but I feel like I should be. This past Wednesday, I understood everything on the quiz and yet somehow misinterpreted everything, and got 0 right answers. That's at least a good learning experience. For Friday's quiz, I did the reading in what I thought was sufficient detail. Turns out even when you do the reading, if you happen to focus on the wrong details, you're going to get everything on the quiz wrong. So essentially, there goes two more of my dropped quizzes.

Now's when that familiar fear/nerd rage is going to come in handy. Armed with no project deadlines this week, I can actually take some time to study up for all of my midterms. Also, I will take care not to forget about my projects.

I can only hope things work out.

See you all on the other side of the midterm!

Sunday, September 23, 2012

Week 4 (9/17-9/23) - Source Code Organization

Definitely had a rough week. It was interesting to learn about the way exceptions are handled in C++. It still seems like the Java way of dealing with exceptions is a little bit better. If you're going to go through all the trouble of inventing a system that could cause your program to halt if used incorrectly, at least in Java, the use of Checked Exceptions requires you to tell someone about it. In C++ if you miss catching an exception that you didn't know about, your program halts/crashes and there's nothing you can do about that once it's in production except to track down the cause of the problem.

I still haven't quite gotten a handle on the daily quizzes. I forgot to do the reading but for some reason I had convinced myself that the quiz over the reading wouldn't be until Monday morning. I definitely won't be making that mistake again. Luckily there are dropped quizzes to make up for the "duh" moments like this.

The quiz mentioned the canonical way to build classes in C++. However, beyond mentioning the canonical class methods, we didn't go into a whole lot of depth, although I wish we had. So, I went and looked up an article that would tell me a bit more (http://www.cplusplus.com/articles/y8hv0pDG/). It's nice to see a write up but I hope that we still visit these topics in more detail during the lectures.

Project 2

The project was going pretty well until Saturday. About 9 pair-programming hours into the project and we thought we had the problem solved. Then we submitted to UVa and got a Runtime Error. We figure something went wonky with our assertions. Maybe a first troubleshooting technique would be to comment out all the assertions and see where that gets us. We definitely need to do more acceptance testing. Perhaps "random" inputs will help us discover the Runtime Error on our end. We definitely plan to take advantage of the public tests repo to help us figure out this problem.

Source Code Organization

Something that still feels wrong about the structure of the projects is that the executable code is being written in a giant header file. Now I know this isn't the software engineering class, but shouldn't we be paying a little more attention to good coding style?

I mean, a good way of handling a submission would be to let us turn in whatever source files we want for the actual submission, and provide a Makefile that will generate the required executable that they will use for testing. Makefiles aren't all that hard, but we could even be provided with a template Makefile and given instructions on how to use it. Considering that the class is already having us learn Git, it would make sense to have us learn Makefiles as well, which is another, more ubiquitous, and equally useful technology.

Anyway since my partner, Tri, and I wanted to be a little more organized, we made our class definitions in separate header files which we include in the Voting.h file.

We will have to remember to move those definitions directly into our source file before submitting our project.

Sunday, September 16, 2012

Week 3 (9/10-9/16) - Collatz Wrap-Up

As the first project wrapped up, my biggest frustration was figuring out how to write valid acceptance tests essentially using the very logic that should be under test. I settled on the reasonable [I think] assumption that if my solution worked for sphere at any point then the acceptance tests I generated from that particular version of the code would be valid. I wrote acceptance tests that would exercise both large and small ranges, and which would run long enough that I would be able to see a real improvement when I implemented my metacache. I decided to save a lazy cache for later ("if I get to it") because I've done similar work with dynamic programming and a metacache is something new.

Many unit tests later I finally got my metacache to work and it is very satisfying to see how blazingly fast the program becomes when you make that change. I turned the program in with a less-than-optimal metacache, which was accepted by V2 of the Sphere problem.

However, after turning in the project, I pushed the cache to the max source file size, and only got a little less than 2x improvement from the submitted version, which is really small compared to the almost 20x improvement between no cache and the first version of the cache.

CACHING



So I wanted to a take a moment to reflect on what I learned about caching from this project. Rule of thumb: a good time to use caching is when all or part of a result will not change as you perform more computations. In other words, if you've got some computation with a lot of intermediate results, and all of those results can be entirely determined from the inputs to some algorithm, it may be beneficial to save the results. A cache takes up space, but it can save a lot of time, and since memory is so abundant these days, it's not something you ALWAYS need to worry about. Sometimes a little bit of information can save you a lot of time. Looking up a cached result is a constant time lookup (using an array or hashtable), and even if that only gives you some information, that can save a lot of time.

LAZY CACHE


Since I've done a bit of dynamic programming the idea of a lazy cache seemed pretty familiar. Basically, you store intermediate results while you perform other computations, so that you can reuse that information when you need a particular result again.

Storing intermediate computations is similar to storing the result of a method call in a local variable, when your code uses that result more than once. You as a programmer might know that the method will return the same thing each time you call it, but most of the time the compiler won't be able to tell that nothing has changed and the program will actually call that method again. So, it is best to save a local copy of the result and use it in various places. Much less expensive than a function call.

I admit that working with a Lazy Cache might have given me an opportunity to learn something about the types offered by the STL, but after seeing the dramatic improvement my program got from using the Metacache, I thought that optimizing the Metacache would give even better results, more quickly.

EAGER CACHE


On the other hand you could spend the time calculating everything things before the program even does anything useful. This is best when you can afford to have a long startup time and your program will be running for a long time. Otherwise, you should think carefully before doing this.

METACACHE


Here's why a metacache is cool. In some applications, a lot of things that you might want to compute during the course of running the program don't actually change between runs of the program. Wouldn't it make sense to do some of this computation intensive work before the program even runs? Why not store the results in the program itself so that the only person who has to do the computations is the person writing the program.

In early programming classes, they tell you that storing results in your code is a bad thing to do because it causes your code to rely on work that you did outside the runtime of the program (not kosher for many programming contests, or for understanding algorithmic material). Sure you could make a lookup table to solve every problem, but then your computer isn't really doing the work for you, or you've moved the work to a different program, which seemingly defeats the purpose of writing the original program. However in a problem like the collatz problem where the range of inputs is so vast, you have more of a problem to deal with. Storing those results doesn't take the work from your algorithm, but it does reduce the time-intensive work that needs to be done.

In this iteration of the collatz problem (finding maximums), many of the results can be folded into bins which represent a large number of inputs, so the cache is not even as large as storing every result would be.

In my case, a first-draft metacache improved runtime by nearly 20x. A second pass at optimizing the cache brought that to over 30x improvement from the non-cached version. That's awesome. This is a great take-away from this project.

Monday, September 10, 2012

Eclipse 4.2 is UGLY (simple "kinda fix")

So if you're like me and you wanted to have a real IDE for the sake of working in a nice environment for C++ without having to learn a new tool, and if you're like me and you wanted to have the latest and greatest of CDT tools for Eclipse, then you needed to downloaded Eclipse 4.2.

If you're anything like me, you found the new theme very ugly and unpleasant to work with. Lots of unused dead space and a weird color scheme that seems to hide the separation of toolbar and content pane in inactive panes.

wat.

(^ If you haven't seen that video it's good for a laugh.)

Luckily, there is a bug open that is working to get this resolved. Hopefully.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362423

I won't bother posting screenshots because there are some posted in the bug.

Here's a simple fix, from one of the replies:

In the 'Appearance' preference page you can switch to the 'Classic' theme.

I'm much happier now, although the Classic theme still seems like a thrown-together and not quite polished version of the old theme.

I hope that helps someone else =]


Referenced blog: http://www.jroller.com/andyl/entry/eclipse_3_8_vs_4

Sunday, September 9, 2012

Week 2 (Mon 9/3 - Sun 9/9) - Settling Into a Workflow

This week was another chaotic week for me... Labor day was no class, Tuesday and Wednesday morning were lectures and trying to squeeze in as much work as possible, because I was flying out to Redmond on Wednesday afternoon for an interview with Microsoft's Visual Studio team on Thursday morning. Returned to Austin on Friday night.

Commence a weekend of trying to catch up for class on Monday.

Unfortunately, the majority of my time so far has been spent on OOP, so I haven't had that much of a chance to start projects or do readings for my other classes. Good news about that, the deadline for the first project in this class will be much sooner than for my other classes, so I've got some time to get my other classes figured out before my time away from school comes back to bite me in the butt.

As several other people have mentioned, the threat of an all-or-nothing grade for this assignment is making this a very stressful project indeed. I don't expect a zero, but I can't shake the feeling that I'm going to miss something important and get totally screwed.

Some good news, I finally figured out that I had an invalid assertion somewhere that was causing some of Sphere's inputs to get rejected by the assertion. Now Sphere is accepting my solution and I can move on to implementing a cache.

Labor Day Git Session



Labor day was definitely much-needed time to get some reading done for class and to get some extra practice with Git. One of the things I had been meaning to do was to source control my .bashrc and .bash_aliases (and various other settings files) so that I can easily transfer them between my various Linux boxes/VMs and the lab computers. Since I had some settings on several different systems, this gave me a chance to try out Git's branching and merging features.

From trying to use Git's branching and merging features, I've come away with some impressions about Git compared with Mercurial. Anyone who has spoken to me in class probably knows I prefer Mercurial over Git, mostly because Mercurial integrates better with Windows, but I've definitely come to like some aspects of Git.

One thing which really stood out as a clear advantage that Git has over Mercurial is that branches in Git can be deleted, and in fact they often are. This is one of the major changes in workflow that I'll have to get used to. Git encourages creating a branch to work on an issue, and then when the issue is resolved, merge the branch into master and then delete the new branch. In Git you can keep your experimental branches to yourself.

In Mercurial, the whole idea around using branches is somewhat different because branches are around forever and are part of your commits, so they are pushed to the remote repository when you do a push. You can't keep experiments to yourself, or overwrite history of the repository, so once you push to a Mercurial repository, it is there forever, even if you abandon whatever you were working on. This makes collaborating on experiments a much more difficult, costly, or embarrassing affair in Mercurial. If you want to create a "branch" in a Mercurial repository to do an experiment, Mercurial encourages you to clone the repository into a different directory, and work on your changes there, and then if you like what you did, merge your changes with the main branch. Branches in Mercurial are good for keeping track of collaborative work that spans a long period of time, or keeping an active Dev branch and then merging into the main branch when everything has been stabilized (รก la many corporate systems for version control management).

I would definitely say based on the above that if creating branches to work on issues is your preferred way of doing things, then Git is the system for you. However, I have found that Mercurial gets along just fine without that and since there end up being more branches in Mercurial repositories, the branches tend to have more utility in Mercurial.

The big thing that's going to keep me with Mercurial though when I'm working primarily by myself and/or on Windows is the simple fact that Mercurial is written in Python and so is naturally cross-platform. This makes it a wonderful experience on Windows. Git for Windows bothered me so much that I'm now primarily working in a Linux VM or on the lab computers.

I was so excited when I learned about making command aliases in Git because that means a little less typing for me. However, it seems that the Windows version of Git is not able to deal with command aliases. Thanks Git. -.-

Settings Repository

Well anyway the happy result of my experiments with Git is that now my Settings repository is available on Git. If you'd like to check it out and take any of the snippets for yourself, feel free to have a look.


I rely heavily on aliases that will mostly only make sense on my systems, since I use them to quickly switch to specific directories in my file structure.

However, I do like the colorful prompt I've come up with. This started when I tried out Arch Linux for the first time and saw that the default prompt is colored, which makes it very easy to differentiate your prompt from the output in between, which also happens to make it easier to see when the output of a command begins and ends.

Here's a screenshot of my prompt and the specific lines you'll need to make this work on your system as well. (Assuming bash obviously.)


..

Project Progress



Now that I've gotten more comfortable with Git and I have my Linux VM up and running, I'm making a lot more progress. One of the most frustrating parts of the project is writing the unit tests. Since this project is primarily focused around computations which would be tedious by hand, properly testing the evaluation functions is either going to require that we trust that our program already did it correctly (which will be useful later after the unit tests have been created with the quick-and-easy approach and then changing the implementation to use a cache), or to find some table of solutions online, or having to compute the answers by hand.

I'm still working out the best way to do this, but either way I'm making some progress with adding unit tests to my project.

Does anyone else think it is funny that we can technically see other peoples' unit tests and acceptance tests? I'm not planning to look at anyone else's until I've done my fair share of my own work, but it could definitely be helpful to add some extra tests if we're allowed to borrow other peoples' unit tests and acceptance tests as extra assurance that our programs are behaving correctly.

Monday, September 3, 2012

Git on Windows, MSysGit Context Menu, and Git Bash

Well, as I mentioned in my last post, installing Git on a Windows machine can be a bit of a hassle, and if you're not careful during the installation (like me) you can end up with a context menu which is cluttered with Git commands that you'll rarely use unless you use Git for every file on your computer....

Here's a quick forum post which describes how you can clear those nasty context menu options out of your Windows Explorer context menu.

http://stackoverflow.com/questions/2459763/how-do-i-remove-msysgits-right-click-menu-options

Now, one of those commands (Git Bash) which opens the Git shell at the current folder location, is extremely useful. Unless you plan on using TortoiseGit for everything in your file system, you probably want to have it, because starting up the Git Bash from your start menu and then navigating to the folder you want is a pain in the butt.

CMD Solution



Well the obvious answer is to add Git to your path. For me, this was:

D:\Program Files (x86)\Git\bin

If you have Cygwin installed and you have Cygwin's version of Git installed (which is probably out of date), you definitely want to make sure that the Git path appears before the Cygwin path. For me, this looks something like:

D:\Program Files (x86)\Git\bin;D:\cygwin\bin;

One caveat: Git will incessantly annoy you with warnings that the terminal is not fully functional. Don't know what to do about that. If you can live with it, then you don't need the following solution.

Cygwin Solution (Hack)



If you've got Cygwin installed I've got a solution for you.

Cygwin's shell and Git Bash operate in entirely different environments but they treat paths similarly (using the Unix-style forward slashes as path delimiters and using the drive letter as part of the path).

If you add Cygwin to your PATH (on my box, D:\cygwin\bin), you can use those Unix tools from the Windows command shell (not just in your Cygwin Terminal environment). The particular tool we're interested in is the "pwd" command.

  • Navigate to your Git repo on disk.

For me this is E:\Users\Doug\Dropbox\Classes\12f\cs371p-oop\projects\cs371p-collatz

  • Shift-Right-Click and select "Open command window here" (see below)
  • Type pwd at your prompt, to get the directory name you're currently in according to Cygwin.

E:\Users\Doug\Dropbox\Classes\12f\cs371p-oop\projects\cs371p-collatz>pwd

/cygdrive/e/Users/Doug/Dropbox/Classes/12f/cs371p-oop/projects/cs371p-collatz

  • Copy the part starting with your drive letter (e.g. /c/, or /e/ in my case)
  • Run "Git Bash" from your Start Menu
  • Type "cd " and paste the path you copied. Hit Enter and you should see something like the following:

Doug@DEFIANT ~
$ cd /e/Users/Doug/Dropbox/Classes/12f/cs371p-oop/projects/cs371p-collatz

Doug@DEFIANT /e/Users/Doug/Dropbox/Classes/12f/cs371p-oop/projects/cs371p-collatz (master)
$

  • Congratulations, you're now exactly where you want to be, in your Git Bash, and you're ready to Git away.

Yes it's convoluted but you should be fine as long as you keep your command window open while you're working. Otherwise you'll have to go through the whole process again.

Okay fine, it's definitely more fun to hack around with things like this than to actually use them. I'm thinking that I'll work on a general solution based on the below section.

General Solution to Context Menu



I haven't quite figured out an actual solution to the context menu problem yet, but I'm thinking the following article may yield a solution after some study:

http://www.howtogeek.com/howto/windows-vista/how-to-clean-up-your-messy-windows-context-menu/

Basically, what I want is to get rid of most of the context menu options and be left with just "Git Bash", which only appears when you "Shift-Right-Click," like when you want to launch a command window at the current location:


I'll give that a shot later. Maybe...

Sunday, September 2, 2012

Week 1 (Wed 8/29 - Sun 9/2)

While the first week of classes usually feels pretty slow, this semester it's been pretty hectic. This is my first time living off campus, and commuting to campus from my apartment every day (sometimes multiple times a day) has been exhausting. I'm trying to work out how I can best spend the time between my classes, which I've never really had to do before since I could just go back to my dorm to work for a while. Additionally, with my new fitness goals this semester, I've been going to the gym more often -- and that hasn't done much to help the fatigue.

Normally, I would wish that Labor Day would come later on in the semester, but this semester I'm happy the first weekend is actually the 3-day weekend.

Preliminary Thoughts on the Class



The class has been pretty fair so far. I'm happy that the class will involve a considerable amount of coding in C++, and I'm also happy that we're not completely abandoning Java, which is far and away my most comfortable language.

I think that learning OOP concepts in a language-agnostic environment will be a good learning experience. By comparing and contrasting C++ and Java we'll be able to explore the key ideas of the OOP paradigm, rather than focusing on how one language happens to deal with things.

From what I know, the OOP implementations in C++ and Java also differ by a considerable amount, and I'm hoping we'll get around to discussing the design decisions that went into each language's implementation of OOP, and what tradeoffs were made in those implementations.

In Class



I was skeptical that the first thing we did in class was to compare a Hello World program in C++ and Java, but I was pleasantly surprised with the level of detail with which we treated that discussion. Seeing the parallels and the differences between the languages, especially in how they deal with symbols and namespaces, was very interesting.

Even though I knew that you could technically leave out the import statements in Java and still have access to all of the libraries, it hadn't occurred to me that the Java import command was analogous to the C++ using namespace... and that there is no Java language feature which is analogous to C++ #include, because package linking in Java, IIRC, is handled at the compile command. I haven't used the command line to compile Java code for a very long time, and I rarely use packages which are not part of the Java standard library, so I'm honestly not sure how that works anymore.

The class definitely got interesting fast when we started discussing the project. I had heard of the Collatz Conjecture before because of a Relevant XKCD, but I hadn't really thought about the problem too much since then.

The fact that an input number will cause the sequence to terminate at 1 means that the sequence eventually reaches a power of 2, seems like a very powerful result. Interestingly, before Prof. Downing made that point, I was thinking about that fact in a binary RegEx (numbers that match /10*/). When Prof. Downing observed that the powers of two act like magnets for the inputs to the sequence, that suddenly made that result seem very powerful.

I'm definitely looking forward to working on the project, once all of the administrative stuff is out of the way.

Foot in Mouth



As a result of my embarrassing post on the class forum requesting specifics on the already well-defined requirements for the first project of the class, I realized that I've been so scatterbrained since moving into my new apartment that I have evidently forgotten how to scroll down (and/or how to read).

To be fair, I looked for those guidelines on the syllabus, and the Sphere problem description, and everywhere else I could think of... Except I never actually SCROLLED DOWN the project page. *FACEPALM*

At any rate, I admit my mistake and I know I won't neglect to read the instructions in the future.

The Project so Far



So, following that incident, I decided it was time to collect my thoughts and just dig in to the project so that I could make some headway and encounter some real problems that I might actually need to ask about.

Startup


I had absolutely no trouble upgrading my GitHub account to a GitHub Student account. It was ready immediately after I provided my school email address.

The Sphere account was also exceedingly easy to set up. I even tried the first problem (http://www.spoj.pl/problems/TEST/) to get a feel for how the system would work.

From using BlogSpot for a blog before, I know that there isn't (or at least, wasn't) a good way to put source code into blog posts here, so I searched around and found Gist (https://gist.github.com/), which lets you format code snippets complete with syntax highlighting and provides an embed link so that you can show your code on any web page, which works really nicely for putting them directly into BlogSpot posts.

So I'm now using the fact that I solved the first problem on Sphere to try pasting a code snippet here. Feel free to comment on anything about this code. I'm still struggling to find the best way to do stream I/O in C++, since there are apparently a lot of ways to read data from streams and the best method varies by the situation.

..

GitHub


My source control of choice has been Mercurial for a long time, since it was built with cross-platform in mind, and it certainly feels that way to use it. It may not be as fast or as flexible as Git, but the fact that it works so smoothly on both Windows and Unix systems, and has a really clean, unified GUI option, as well as a complete CLI, has made it a good choice for a lot of school projects so far.

I have also used Git in the past, but only when working on projects that were started by other people. I hadn't yet set it up on my new computer and I had seriously forgotten how much of a pain in the butt it was to get Git set up on Windows. And even after the setup phase is complete, it's certainly not the easiest tool to use on Windows. That's fine, since I can use it without a problem when I'm remotely logged into my Linux account, or when I'm in the lab.

Still I feel like Git is a somewhat less intuitive tool to use. All the flexibility it offers has caused some of the commands at the core of the workflow to feel a bit clunkier and less intuitive than they could be.

At the end of the day, though, I know that a working knowledge of Git will be very powerful, so I'm going to look at this as a new challenge and really dive into Git this semester. Don't have much of a choice, either, since it's required!

Progress


So far I've set up the respository, edited the README (learned some simple markdown syntax for that), and created issues for all the requirements, and a few other items that came up as I was doing the above.

Issue Tracking


It bothers me that GitHub's issue tracker doesn't have a built-in concept of priority or severity, which is pretty integral to an issue-tracking system. I can see why so many open source projects on GitHub opt to use BugZilla or some other issue tracker.

I learned how to close issues via commit messages. I haven't had a chance to do so yet, but I'm looking forward to giving it a try.

Workflow


Luckily I have some experience with committing often and using an issue tracker, so this is one aspect of the required workflow for the class projects that won't feel utterly foreign to me. Unfortunately, I haven't worked the rest of it out yet so I've felt really cluttered while working on this class, so far.

Confusion


A few items have confused me about this project so far...

  • The requirements state that we're supposed to write unit tests before writing any code, but it seems that the grader's repository for the unit tests isn't up yet. I'm not sure whether I should be writing the unit test code, keeping it in my own repository, and then pushing it to the unit test repository later, especially since that would seem to make the most sense for actually running the unit tests on the code. That would also let me get started on the project sooner rather than later.
  • If we are to complete this project in C++, why are we provided with starter Java files on the project page?