teaching machines

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 […]

Pixelated Sphere

I don’t know exactly what magic is made of, but I’m pretty sure it’s spheres. No matter where you stand on a sphere’s surface, you see change. Yet the same change happens everywhere. No point is better than other—until you shine a light on it. But the sphere won’t let the light play favorites. It […]

Pixelated Crate

My 8- and 6-year-old sons and I have been playing EvoLand 2. The game cutely blends action RPGs with platformers with shmups with infinite runners with tactical RPGs with fighting games with menu-based RPGs. Somehow they even squeezed in Snake, Pong, and Pac-Man. Apart from the varied gameplay, EvoLand 2 has inspired us to make […]

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 […]

1 2 3