CS 330 Lecture 15 – Choices in C++
Dear students, C++ is a language with choices. Some call that a curse. I’d argue that asking that all doors be closed but one gives to much authority to an outside entity that can’t possibly understand our situation and can’t be trusted to know which door is best. Let’s discuss a few of these choices […]
CS 318 Lab 10 – Absolute and Relative Positioning
Dear students, There’s immense power in the position property. It is your vehicle for anchoring elements relative to another, animating them on user interactions, providing a heads-up display that is always on screen, and achieving a fluid layout that can bend and flex with the browser window. Today we will explore absolute and relative positioning. […]
CS 330 Lecture 14 – Graphing Calculator
Dear students, Let’s put subtype polymorphism to work in a Curses-based graphic calculator. Let’s start with an abstract base class for all manner of functions: class Function { public: virtual double operator()(double x) const = 0; }; Now let’s recast our linear and quadratic functions as independent subtypes of Function: class QuadraticFunction : public Function […]
CS 318 Lab 9 – Box Model, Part 2
Dear students, Today, we will continue to explore the box model. But let’s add some colorful flavor through gradients. Gradients have some nice properties: They eliminate the flatness of solid background colors. They automatically scale to fill the background of an element. Unlike images, they are generated by the browser. They require no expensive downloads. […]
CS 330 Lecture 13 – Vtables and Graphing Calculator
Dear students, We saw last time that for subtype polymorphism to work in languages like Java and C++, we need some for way for each object to carry around some information to help us figure out what method to call at runtime. What exactly is that information and how does the runtime decision—the dynamic dispatch—get […]
CS 318 Lab 8 – Box Model
Dear students, Let’s stop a moment to reflect upon what we have done so far this semester: We’ve organized information in a hierarchy and represented it in plain old text. We’ve seen how to make our text “hyper” through the use of images and links. We’ve added style to established elements of this hierarchy. We’ve […]
CS 330 Lecture 12 – Subtype Polymorphism
Dear students, We introduced four type of polymorphism last time and saw examples of the first two—coercion and ad hoc polymorphism—through the lens of C++. On to a third form: Subtype polymorphism is when a piece of code is targeted to handle an umbrella type, a supertype, but somehow it calls the overridden methods in […]
CS 330 Lecture 11 – Polymorphism: Coercion and Ad Hoc
Dear students, All my favorite talks try to classify some phenomenon in a 2×2 matrix, so let’s do the same. Let’s categorize human endeavors into four buckets based on how much effort is involved and what effect they have: Large Effect polymorphism John Henry learning Vim Small Effect sleeping voting teaching Little Effort Lots of […]
CS 330 Lecture 10 – Type Systems
Dear students, Last time, we introduced types as one of the more prominent distinguishing features of a programming language. We enumerated a bunch of types commonly supported in programming languages. This time, we look at some ways to characterize a language’s type system. To help understand the importance of a language’s type system, imagine if […]
CS 318 Lab 7 – Images
Dear students, I first offer a brief list of recommendations about things I’ve seen you doing that will cause you unnecessary headache: Avoid using spaces in file names. Spaces are not allowed in URLs, so it’s best to just avoid them. They often get translated by our browser into %20, but they will cause issues […]