Session 2

Toward Programming in Java


CS 2530
Intermediate Computing


Last time, we played with a simple memo pad application and imagined what the program might contain. Today, we look at the code itself and begin to learn a little about Java and a little about object-oriented programming.


Opening Exercise

After studying the memo pad program, each of you wrote down at least three questions you have about the code. Pair off with a classmate and share your list of questions. Assume that I will answer only one question from both lists. Pick the one you want answered today.



The Anatomy of a Java Program

Open MemoPad.java in Dr. Java. Take questions.

Some of the big questions: ...

Compiling and running a Java program.... javac and java. Dr. Java: interactions, comments.

Some design principles:

Here is a simple class diagram:

a homegrown class diagram of the memo pad app


Exercise: Changing the Memo Pad

Last time, we considered some possible changes and extensions we might make to the program, including:

Work with your partner to determine which parts of the code we would we have to change in order to implement each.

Do any of the changes require that we change multiple classes? Do any of the changes require that we change a class's interface? If yes, then we may be able to improve the design of our program.



A First Look at Vocabulary

Java and object-oriented programming.

Answer more questions about the vocabulary in the memo pad program.

We will be defining terms and looking at what they mean throughout the course. Please ask questions about any term that confuses you, or any jargon that shows up unannounced.



Meta: Success in the Course

That's one of the most important things you can do in order to succeed in this, or any, course: Ask questions.

We talked about another last time: Read.

Read. Read.

There is at least one more thing you should do: Practice. Linux. Java. OOP.



Follow Up on First-Day Submissions

The Pop Quiz. I asked you to...

Write a program that repeatedly reads in integers, until it reads the integer -1. After seeing -1, it should print the average of the integers and terminate.

The verdict:

The Survey. I haven't processed all the data yet, but I did tabulate answers to one of the questions:

What is the most interesting program you have ever written for yourself (not for a class)?

I was curious: Who among you programs for him- or herself -- for fun? (I envy you your access...)

The results were interesting and occasionally surprised me:

We have a wide range of experience in the class. That is good. Many of you will be able to learn from your classmates. The more advanced among you can appreciate the complexity of writing large programs. I hope that you learn some things this semester that help you do it better.

What about me? It's only fair that I answer as my 18-year-old self. [I was a chess player. Scoresheets. Rating system for club. Chess itself. Tournament pairings.]

I have been programming a long time. I still have a lot to learn.

Being able to program makes you powerful. Writing programs can also be fun. One of my goals for this course, and for your undergrad education, is this: You become a programmer who is competent and confident enough that, whenever you think, "I wish I had a ..." or "I bet I could ...", you can.



Wrap Up



Your Most Interesting Programs

Here is a list of the actual programs that you are your classmates listed on the survey:

You are an interesting group!



Eugene Wallingford ..... wallingf@cs.uni.edu ..... August 23, 2012