teaching machines

CS1: Lecture 38 – Slideshow

Dear students, A primary benefit of object-oriented design is that it helps us organize our programs coherently. We can put code and the data that it regularly processes together into the same chunk. Objects allow for the separation of concerns. Class A can focus on its task, and be very good at it. It can […]

CS1: Lecture 37 – Chat Continued

Dear students, Today we extend the networked chat application that we started writing last week. Beyond getting it functional, we’ll also give the client a graphical user interface (GUI). Java is one of the few languages that ships with a builtin windowing library. Dialogs If your program only prompts the user for simple input, like […]

CS1: Lecture 36 – Chatting with Sockets and Threads

Dear students, At the end of the semester, we have an opportunity to explore some new, crazy ideas. Next week we’ll have a look at graphical user interfaces. Today we’ll look at sockets and threads as we make a chat client. Sockets Computers got especially interesting when they gained the ability to talk to each […]

CS1: Lecture 35 – Stopwatch

Dear students, As with methods, a primary benefit of object-oriented programming is code reuse. We can create a utility and use it over and over again, in many contexts. We will do just that by designing a Stopwatch class. Stopwatch We will use our stopwatch to time a few operations: the amount of time it […]

CS1: Lecture 34 – Reverse Engineering Objects

Dear students, In object-oriented programming, the programmer is really a writer of screenplays. Objects are our actors, which we orchestrate around the stage. We cue them to say certain things, have them interact with other objects, and shape them to have an identity that is all their own. Today, we’ll feel our away around the […]

CS1: Lecture 33 – A Growable Array

Dear students, Today, November 22, is National Growable Array Day. We will celebrate growable arrays everywhere by growing one of our own growable arrays, right here, in our classroom. I hope you wore your festive gear. Behind every growable array is an plain old ungrowable array. When that ungrowable array gets filled up, a new […]

CS1: Lecture 32 – More Objects

Dear students, Last time we started our discussion of objects. We continue that discussion today with more examples. Out of concrete examples we build generalized knowledge, right? It’s not the other way around. At this point in the learning process, seeing patterns is more important than feeling like you understand objects. Both need to happen […]

CS1: Lecture 31 – A First Object

Dear students, Today we move on to our last personality: the Computer as a Creator. Up till this point, code and data have been separate entities in our code. Now, we will marry them. We’ll organize code and the data that it operates on into a single being: an object. Objects are models of some […]

CS1: Lecture 30 – 2D Arrays and ArrayList

Dear students, Today we will complete a whirlwind tour through a couple of concepts that really deserve a couple of conversations each. These concepts are two-dimensional arrays and ArrayList. Two-dimensional Arrays Let’s consider a famous statistical problem. Suppose birthdays are uniformly distributed across the calendar year. What’s the probability that we in this room all […]

CS1: Lecture 29 – Bundled Data

Dear students, Last time we used arrays as a means to map integers to values. We associated our data with 0, 1, 2, 3, and so on. When we got a new piece of data in, we use its index to reach inside our array directly. Today we shine the spotlight on arrays as a […]

1 2 3 95