CS 371p Fall 2024: Rob Mayoff

Rob Mayoff

Blog #8

Your blog entry must explicitly answer the following questions about the class (mark the questions in bold in your post):

I finished the programming exercise (Digits) on Monday, and I was the first to finish.

I’ve written number-formatting functions many times, so I’m very familiar with the algorithm. I have a lot of C++ experience, so adapting the algorithm as an iterator was straightforward.

I helped some other students with the exercise on Monday after I finished. I also helped some other students in Game Tech export their project so they could turn it in.

Interface “segregation” is a good idea. The article is limited the C++ language as it existed in 1996. A modern design for a timer service would probably take an std::function argument and, ideally, return a cancellation token.

The ATM UI example is, in my opinion, fundamentally flawed to the point of uselessness.

I had no trouble with the exercise, because I have lots of experience formatting numbers and writing C++ in general.

I’m not sure it’s worth the implementation complexity to support user-provided backing storage.

It’s a shame we haven’t discussed how priority_queue performs comparisons between elements, because that’s a pretty important part of its design and use. It is the only container adapter that looks at its elements in any way beyond copying and assignment.

It’s also a shame that the container adapters have historically had no way to declare what requirements they place on the underlying container. A stack requires its underlying container to offer back, push_back, and pop_back methods, but the compiler doesn’t know that until it (the compiler) tries to instantiate the template. This lack of knowledge leads to confusing compile-time errors and a poor developer experience. C++20 introduced the “concepts” language feature to address this, but the container adapters have not adopted concepts, probably for backward-compatibility.

I was happy to be able to leave class early on Wednesday since I didn’t need to redo the exercise.

My tip this week comes from Charles Antony Richard “Tony” Hoare, 1980 Turing award winner and inventor of the null pointer:

I conclude that there are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.

The first method is far more difficult.

See you next week!