Course Review – Stanford 106A Programming Methodology

I completed Stanford’s CS106A (Programming Methodology) course earlier this year and wanted to write a small review. Currently I am finishing up Princeton’s COS 126 (General Computer Science) and have already noticed quite a difference between the two courses. In a nutshell, CS106A is best for someone with no programming/computer science experience.

The course started with Stanford’s own “Karel the Robot” program in a modified version of eclipse IDE using Java 1.6 (all provided and setup by Stanford). Karel has a limited number of methods (turning, moving one step, picking/placing a beeper) and control statements (while and for loops) he is allowed to do (no storing variables). This allows the student to get a very basic understanding of computer logic and how to think in terms of methods.

After Karel, the course moves into some fun assignments including:

  • Breakout – The classic breakout game.  You build the entire game using the ACM graphics framework.  A ball is animated by moving it one frame at a time and checking for collisions with walls and bricks.
  • Hangman – Again there is some graphics package work, but this assignment focused more on string manipulation, as well as reading in a file and accepting user input.
  • Yahtzee! – This assignment supplied a graphics class and some other startup code, allowing the student to very quickly get an interactive program going.  This was the first assignment to use multiple classes. Additionally there was some advanced logic in checking the possible Yahtzee rolls.
  • Namesurfer – Using government data, the task was to build a viewer which would allow the user to enter a name and then plot a line showing the popularity of the name over the past 10 decades.  This assignment introduced databases and creating classes to store data.
  • Facepamphlet – The final assignment was a bit more involved than I expected, but I enjoyed putting all the things I learned along the way to use.  The goal was to build a database of friends and allow for interactions similar to a popular social networking site.  The database and its friend objects had to interact with one another, for example removing a friend from the database and then removing all connections to said friend.

In the end the course built a great foundation through creating objects, introducing the idea of them having their own state/behavior/identity, and covering the basics of dealing with references.  It also dove into how primitives and objects are represented in memory.  There was a very high level of searching/sorting work as well (insertion vs merge sort)

While the course was great for beginners, my biggest complaint was the amount of “hand holding” that took place.  One of the final lectures showed what writing real Java code involved, including creating GUIs and regular Java files.  While it was a very small step to go from “Stanford” Java to regular Java, it was frustrating to me that after completing an introductory course in java that I would not be able to code the typical “HelloWorld” program were it not for the single class showing normal Java code.

In closing, I found the Stanford CS106A class very helpful as an introduction to Java and Object Oriented Programming, but overall too basic for me.  I did run through the entire class in about a month including reading the book, watching the lectures, coding the assignments, and completing the exams.  If I were to do it again I would probably follow a more advanced course, but for an absolute beginner I think this is a great option.

A Simple Pythagorean Theorem Calculator

A friend asked me to create a Pythagorean Theorem Calculator that was a bit more advanced than the one I created in the Stanford 106A class. I was able to do all of this at Tutorialspoint.com during my lunch. Sadly it is quite simple, and does not handle errors well.

/*
 * This is a simple Pythagorean Theorem Calculator.  It takes in an integers or
 * doubles and finds either the hypotenuse or the missing side.  Does not handle
 * incorrect inputs (ie- numbers when y or n is expected)
 */

import java.util.*;
import java.lang.Math;

public class PythagoreanCalculator {

     public static void main(String []args) {
        
        double val1;
        String val1HypCheck;
        
        double val2;
        String val2HypCheck;
        
        double Answer;
         
        // Setup scanner
        Scanner reader = new Scanner(System.in);
        
        // Print Welcome
        System.out.println("Welcome to the Pythagorean Theorem Calculator! ");
        
        // Get the first dimension
        System.out.println("\nEnter a number: ");
        val1 = reader.nextDouble();
        System.out.println("You entered " + val1);
        reader.nextLine();
        
        // Check if its a hypotenuse
        System.out.println("\nIs this the hypotenuse[y/n]?");
        val1HypCheck = reader.nextLine();
        System.out.println("You entered " + val1HypCheck);

        // Get the second dimension
        System.out.println("\nEnter a number: ");
        val2 = reader.nextDouble();
        System.out.println("You entered " + val2);
        reader.nextLine();
        
        // Don't check for hypotenuse if you already have it
        if (!val1HypCheck.equals("y")) {
            System.out.println("\nIs this the hypotenuse[y/n]?");
            val2HypCheck = reader.nextLine();
            System.out.println("You entered " + val2HypCheck);
        } else {
            val2HypCheck = "n";
        }
        
        // First value is hypotenuse case
        if  (val1HypCheck.equals("y")) {
            Answer = Math.sqrt(val1 * val1 - val2 * val2);
            System.out.println("\nThe other side is " + Answer);
        }
        
        // Second value is hypotenuse case
        if  (val2HypCheck.equals("y")) {
            Answer = Math.sqrt(val2 * val2 - val1 * val1);
            System.out.println("\nThe other side is " + Answer);
        }        
        
        // Third value is hypotenuse case
        if  (!val1HypCheck.equals("y") && !val2HypCheck.equals("y")) {
            Answer = Math.sqrt(val2 * val2 + val1 * val1);
            System.out.println("\nThe hypotenuse is " + Answer);
        }

        System.out.println("\nThanks!\n");

     }
     
}

And here is some sample output, showing how it does not ask for the hypotenuse if it already got it:
PythOutput

Approach to Learning Programming

To learn programming and computer science, I looked through online courses from universities (MIT, Stanford, UC Berkeley, Carnegie Mellon, Harvard) and Massively Open Online Course (MOOC) offerings (CourseraUdacity, Udemy).  Initially I focused on going through MOOCs, mainly specializations in Coursera and some courses/projects through Udacity.  But the more courses I found online through top level universities, the more surprised I was with just how much was available.  Stanford offers their entire introductory Comp Sci track on its own site, Berkeley offers lectures from multiple courses on YouTube, and MIT offers multiple complete courses (some with video lectures) on its OpenCourseWare site.  While I would lose the ability to get feedback from instructors through forums available on sites such as Coursera, I like the idea of taking courses directly from universities as they are delivered to students.  The other downside in the non-Coursera approach is I lose the option to get a certificate proving that I actually completed the course.  To overcome this, I will need to track my progress through this site by posting my graded work.

With that, I began trying to develop my own curriculum based on courses I could find online.  Online Learning: An Intensive Bachelor’s Level Computer Science Program Curriculum, Part II – aGuipeWare gave me a great initial list of course topics, but I also found curriculums from top universities to make sure I was covering all my bases.  Initially I started MIT’s Introduction to Computer Science, which is based on Python and was quite enjoyable.  The lectures were fairly easy to follow using my iPad or on the computer, and I was able to do the homework problems and check my work after.  I then signed up for the same course on edx in order to earn a certificate of completion.

One third of the way into the MIT course, I found Stanford’s 106A – Programming Methodology, 106B – Programming Abstractions, and 107 Programming Paradigms.  All three Stanford courses take 1 year on campus and introduce Java, C++, and C.  This means I would have an introduction to programming languages necessary to create Android applications as well as being able to do projects with arduino.  More importantly, the future courses I would like to take use Java or C, so taking the Stanford courses would mean I would be prepared to take them.

Additionally, aside from the typical undergrad math and liberal arts courses I have already taken, all computer science curriculums involve at least one “Mathematics for Computer Science” type course.  Initially I found MIT’s course, but upon further research became interested in UC Berkeley’s CS70: Discrete Mathematics and Probability Theory.  It seems to cover at least the same amount of information, but also includes solved problem sets and discussions (solutions are not included for MIT homeworks).

With that, I came up with the following initial set of courses.  The naming conventions are as follows – numbers specify order, letters specify track.  Tracks A and B will need to be completed in order, but track A occurs independently of track B.  Stanford 106A must be completed first as it gives an introduction to Java and works as the introductory course required for Berkeley CS70.  From there I will finish the Stanford Computer Science track.  After finishing the first Stanford Course, I will be ready for the UC Berkeley math course, Princeton’s Algorithm courses, and MIT’s Advanced Data Structures.  From there, once completing the below course list I will move on to higher level programming (operating systems, architecture, software engineering) and elective type courses (web development, cryptography, and machine learning).

OrderInstitutionSourceCourse
1ABStanfordSEECS106A - Programming Methodology
2AStanfordSEECS106B - Programming Abstractions
3AStanfordSEECS107 - Programming Paradigms
2BBerkeleyBerkeleyCS70 Discrete Math
3BPrincetonCourseraAlgorithms, Part I
4BPrincetonCourseraAlgorithms, Part II
4AMITMIT OCW6-851 Advanced Data Structures
5BGeorgia TechUdacitySoftware Development Process

Below is a list of the descriptions of each of the courses and links to where they can be found.

Course: CS106A – Programming Methodology

Link: https://see.stanford.edu/Course/CS106A

Description: This course is the largest of the introductory programming courses and is one of the largest courses at Stanford. Topics focus on the introduction to the engineering of computer applications emphasizing modern software engineering principles: object-oriented design, decomposition, encapsulation, abstraction, and testing.

Programming Methodology teaches the widely-used Java programming language along with good software engineering principles. Emphasis is on good programming style and the built-in facilities of the Java language. The course is explicitly designed to appeal to humanists and social scientists as well as hard-core techies. In fact, most Programming Methodology graduates end up majoring outside of the School of Engineering.

 

Course: CS106B – Programming Abstractions

Link: https://see.stanford.edu/Course/CS106B

Description: This course is the natural successor to Programming Methodology and covers such advanced programming topics as recursion, algorithmic analysis, and data abstraction using the C++ programming language, which is similar to both C and Java. If you’ve taken the Computer Science AP exam and done well (scored 4 or 5) or earned a good grade in a college course, Programming Abstractions may be an appropriate course for you to start with, but often Programming Abstractions (Accelerated) is a better choice. Programming Abstractions assumes that you already have familiarity with good programming style and software engineering issues (at the level of Programming Methodology), and that you can use this understanding as a foundation on which to tackle new topics in programming and data abstraction.

Topics: Abstraction and its relation to programming. Software engineering principles of data abstraction and modularity. Object-oriented programming, fundamental data structures (such as stacks, queues, sets) and data-directed design. Recursion and recursive data structures (linked lists, trees, graphs). Introduction to time and space complexity analysis. Uses the programming language C++ covering its basic facilities.

 

Course: CS107 – Programming Paradigms

Link: https://see.stanford.edu/Course/CS107

Description: CS107 is the third course in Stanford’s introductory programming sequence. Our CS106 courses provide students with a solid foundation in programming methodology and abstractions and CS107 follows on to build up their programming maturity and expand breadth and depth of experience. The course will work from the C programming language down to the microprocessor to de-mystify the machine. With a complete understanding of how computer systems execute programs and manipulate data, you will become a more effective programmer, especially in dealing with issues of debugging, performance, portability, and robustness. Topics covered include: the C programming language, data representation, machine-level code, computer arithmetic, elements of code compilation, optimization of memory and runtime performance, and memory organization and management.

 

Course: CS70 Discrete Math

Link: https://inst.eecs.berkeley.edu/~cs70/sp15/#syllabus

Description: Discrete mathematics and probability theory provide the foundation for many algorithms, concepts, and techniques in the field of Electrical Engineering and Computer Sciences. For example, computer hardware is based on Boolean logic. Induction is closely tied to recursion and is widely used, along with other proof techniques, in theoretical arguments that are critical to understanding the foundations of many things, ranging from algorithms to control, learning, signal processing, communication, and artificial intelligence. Similarly for modular arithmetic and probability theory. CS70 will introduce you to these and other mathematical concepts. By the end of the semester, you should have a firm grasp of the theoretical basis of these concepts and their applications to general mathematical problems. In addition, you will learn how they apply to specific, important problems in the field of EECS.

 

Course: Algorithms, Part I

Link: https://www.coursera.org/course/algs4partI

Description: An introduction to fundamental data types, algorithms, and data structures, with emphasis on applications and scientific performance analysis of Java implementations. Specific topics covered include: union-find algorithms; basic iterable data types (stack, queues, and bags); sorting algorithms (quicksort, mergesort, heapsort) and applications; priority queues; binary search trees; red-black trees; hash tables; and symbol-table applications.

 

Course: Algorithms, Part II

Link: https://www.coursera.org/course/algs4partII

Description: Part II covers graph-processing algorithms, including minimum spanning tree and shortest paths algorithms, and string processing algorithms, including string sorts, tries, substring search, regular expressions, and data compression, and concludes with an overview placing the contents of the course in a larger context.

 

Course: 6-851 Advanced Data Structures

Link: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-851-advanced-data-structures-spring-2012/

Description: Data structures play a central role in modern computer science. You interact with data structures even more often than with algorithms (think Google, your mail server, and even your network routers). In addition, data structures are essential building blocks in obtaining efficient algorithms. This course covers major results and current directions of research in data structure.

 

Course: Software Development Process

Link: https://www.udacity.com/course/software-development-process–ud805

Description: In SDP, you will learn how to select and implement the ideal software process for your development project. Through Professor Orso’s engaging examples and interviews with industry insiders, you will learn both conceptual and practical aspects of software engineering. The course covers requirements engineering, architecture and design, testing and maintenance, and software quality in general. The goal of this class is to equip you with the skills necessary to define requirements, set up an integrated development environment (IDE), learn Git (and Github!) and use Unified Modeling Language (UML) to design and build an Android application. We will also examine several testing practices and refactoring techniques that are helpful before the launch of your software project.

Finally, here are some links that helped me work to develop the above:

Goal: Learn Programming

I have always been interested in developing my programming skills. Other than some limited VBA and Python programming over the past few years, I have not done any considerable programming since using MATLAB at college and a previous job. Programming is something I have always enjoyed and have found myself trying to inject into my work more and more.  With that I made the decision to set a goal to get a solid understanding of programming and computer science. Doing so would allow me to better automate my current work, as well as dive into some more interesting personal projects.

So based off of the site Set your goals and make them happen – Action for Happiness, setting goals goes like this:

  1. Decide
  2. Write it down
  3. Tell someone
  4. Plan
  5. Keep going
  6. Celebrate

Following their framework, I have made the decision to follow through with this over the next year.  This blog will serve as a record of my progress in going through online courses, as well as posting any projects I may do.  Given that this blog is posted publicly, I am checking off telling someone.  The planning for this goal will be touched on in this post but will be covered fully in another.  I will leave the rest of the above points for later.

My plan to learn programming and computer science relies on online courses through universities (MIT, Stanford, UC Berkeley, Carnegie Mellon, Harvard) and Massively Open Online Course (MOOC) offerings (CourseraUdacity, Udemy).  Initially I focused on going through MOOCs, mainly specializations in Coursera and some courses/projects through Udacity.  But the more full courses I saw available for free through top level universities, the more surprised I was with how much college level programming coursework was available.  Stanford offers their entire introductory Comp Sci track on its own site, Berkeley offers lectures from multiple courses on YouTube, and MIT offers multiple complete courses on its OpenCourseWare site.  While I would lose the ability to get feedback from instructors through forums available on sites such as Coursera, I like the idea of taking courses directly from universities as they are delivered to students.  The other downside in the non-Coursera approach is I lose the option to get a certificate proving that I actually completed the course.  To overcome this, I will need to track my progress through this site by posting reviews of courses I have completed as well as any individual work of my own.

Additionally, this site will serve as motivation for me to continue my study of programming and showcase my achievements in pursuing my goal.