CS371p Spring 2021, 22 Mar–26 Mar

Ethan Tan
3 min readMar 28, 2021

OOP Blog Post #8

What did you do this past week?

Homework and the like. I wasn’t too busy due to knocking out some of the work over spring break.

What’s in your way?

My sleep schedule is still recovering from copious sleeping in during spring break, but otherwise there isn’t much in my way.

What will you do next week?

I have an exam on Monday, but nothing out of the ordinary otherwise.

If you read it, what did you think of the Interface Segregation Principle?

The interface segregation principle is another codification of an intuitive idea, but it can be useful to keep it in mind while working with object-oriented design. It can be tempting to group similar interfaces into one general-purpose interface, since that would simplify code and introduce no immediate downsides. But when it comes to editing and extending the code, such a design, as demonstrated by the paper, poses much more of a hassle and risk.

What was your experience of initializations and vectors?

C++ syntax for initialization is, in my opinion, a bit confusing — there’s many ways to express the same idea, and sometimes similar syntax can yield different results. However, it’s still mostly understandable, and working with initialization isn’t too difficult despite the syntax.

I haven’t really used vectors previously — my first experience with C++ was in Operating Systems, where we didn’t have access to a standard library. I’ve started using vectors more often in this class, but I still like to default to arrays when resizing isn’t a necessity. The fact that std::vector is largely as efficient (with compiler optimizations, I assume) as a dynamically allocated array does make it an attractive alternative, and of course, as a general-purpose list structure, vectors are convenient as ArrayLists are in Java.

What made you happy this week?

We finally started talking about monads in Programming Languages. It’s probably one of the most interesting design patterns; not just for functional languages like Haskell (of which monads are a central part), but also for other languages, even C++. They’re a bit hard to grasp at first, but they are so useful and elegant once you understand them and start working with them. I like them so much, I even named this blog after them.

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

There’s a very interesting blog that covers a wide range of topics which coincidentally align with a lot of what I’m interested in. As mentioned before, there’s posts about monads in C++, monadic futures, lots of category theory, lots of Haskell and C++, lots of concurrency, and every intersection of those. At first glance the world of functional programming and category theory seems to be separate from imperative, object-oriented C++, but there is a surprising amount of overlap that this blog explores.

--

--