Sign in

CS371p Spring 2021, 1 Mar–7 Mar

OOP Blog Post #6

What did you do this past week?

Took an exam, finished up some homework (including the Voting project), and pondered queues, locks, and queued locks.

What’s in your way?

I have to work on another exam and some grading this weekend.

What will you do next week?

Much of the same. I’m looking forward to the next project.

If you read it, what did you think of the Open-Closed Principle?

The Open-Closed Principle seems very useful —it protects against changes that could break an entire system by disallowing those changes. While this seems a bit severe, you get a lot of safety out of simply forbidding potentially dangerous behavior (which is why static typing is much nicer than dynamic typing in my opinion). However, changes to code are motivated by a need for a change in behavior — which the Open-Closed Principle allows by providing extensible abstractions, which can be implemented differently for different behavior. This doesn’t require changing the closed module, and so keeps existing code intact and working.

What was your experience of arrays, iterators, and algorithms?

Arrays are always great; I prefer using them over vectors since there’s less overhead. The fact that the stl container guarantees identical performance to the raw array is very nice.

It’s interesting to me how C++ defines what an iterator is (as well as many other things) by its behavior — certain operators or functions it must support. Contrast this to Java, where there are interfaces and classes that define and provide the functions an Iterator should have. This can be seen in the implementation of generic algorithms, which are template functions in C++ that expect their types to support certain operators.

What made you happy this week?

Working on the Voting project with my partner!

What’s your pick-of-the-week or tip-of-the-week?

Read documentation. The first place I go to when I want to know more about anything C++ related is cppreference, and it’s been a tremendous help for finding useful classes and functions for the projects. This isn’t limited to C++; for operating systems, osdev was super useful, and I make use of hoogle and hackage when working with Haskell.