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