CSE 131 Module 0: Welcome


Before beginning any work, do a Team...Pull in your repository.


Which computer should you use for this lab session?


Professional software developers use an Integrated Development Environment (IDE) that includes a text editor (for creating source code), a compiler (for translating source code into executable code), and a debugger (for finding errors). In this course, we'll be using eclipse, a popular IDE that supports (among many other things) programming in Java.

Professional software developers also use a versioning repository to store their code, so that they can share their code easily and keep track of the changes they make.

In CSE131 this semester, we will be using Git as our version control system.

Version control systems (VCS) are great for when you want to record who did what for which file or set of files, and it is especially useful when multiple people collaborate on projects, as you will be in this course.

Before working on any project, you must check out your repository. The instructions for this will be later on in this writeup.
The general workflow of Git, following the repository being checked out, is as follows. Don't worry if you don't understand some of the terms yet, they'll make sense as we go through this studio and the coming lab:

  1. Pull from the master/origin
  2. Do work on one/some of your files
  3. Commit and/or push your work back to the origin
  4. Repeat steps 1 through 3

These steps will have to be repeated and followed for every assignment you work on throughout the duration of this course.

Whenever you sit down to work on an assignment, you must always pull from origin/master before working. If you don't, it is possible that you'll cause a conflict.

If you have not yet installed eclipse, follow these instructions to install it on your computer.

Part I: Getting Started with Java in eclipse with Git

  1. Start eclipse: After eclipse starts up, click the 'X' on the "Welcome" tab at the top to close the welcome screen.

  2. Loading your repository:
    If you are a visual person, use this video and follow along to accomplish the steps below.

  3. Look at your project: You should see a project in the Package Explorer at the left side of the eclipse window. The name of the project is the hyphenation of your last name and your student ID number.

  4. Look at the source code:
    1. In the Package Explorer, expand the project by clicking on the '+' sign or little triangle to the left of the project name. You will see that it contains an entry for labs, which is a folder that contains packages of code.
      Throughout the semester, this is where you should look for the files you need to complete your assignments.

      Supporting software is placed in other source folders, such as labsupport. You are welcome to look at any code, but to keep the number of files managable, we'll place lab code in your labs source folder in your repository.

    2. Expand the labs folder (click on its '+' sign or triangle).
    3. Each lab you complete is given to you in a separate package. For this lab, expand the lab0 package.
    4. Double-click the file named RobotController.java to open it. Look at the source code in the middle window. You'll see instance variables, methods, and a main method.
      If what you see makes sense to you already, you may not need to take this class.
      For now, you don't need to understand what you see. We just want the computer to run this program.

  5. Run the program: Right click on RobotController.java and select Run as -> Java application. In the bottom right corner, you will see a GO button. Click the Go . The program should create a robot, and you should see the robot start to move.

  6. Modifying programs: In general, before you can execute a Java program, it must first be compiled (translated) into byte code that can be executed by the Java interpreter. A program that performs this translation is called a compiler. Eclipse checks your files to see if they will compile, and it marks errors so you can correct them. If you position the mouse cursor over an error icon or a red underline, a description of the error will be displayed.

    Try typing some random text into the RobotController.java file to introduce an error. You should see an error icon appear at the left. Note that sometimes the error message appears on the line after the error. At the bottom of the window, you'll see console and problems. The console window shows any printed output of the program. If you click on problems you'll see a list of the errors, and clicking on an item in the list will take you to the location of that error in the Java file so you can correct it.

    Undo your typing, or close (without saving) and re-open the file.

  7. Make the robot do your bidding: So your real assignment here is to provide some instructions so that the robot navigates from from CEC to your instructor's office.
    1. Open up the RobotInstructions file, which is also in your lab0 package. This is where the commands to move the robot are written.
      You now have two files open in eclipse:
      • RobotController.java is the main file. You always run the application using the instructions given above for this file.
      • RobotInstructions.java is the file that contains code directing the robot to move. This is the file you will modify to change the robot's behavior.
    2. Modify the instructions as shown in the window below by adding
      You do not need to type in the comments (things beginning //).
    3. Rerun the program and watch the robot charge ahead.
      • See the red box in the image above? A quick way to rerun your program is to find that green button in your eclipse window and click on that.
      • Or you can repeat the instructions from before, right-clicking on the RobotController in the package explorer and choosing Run AsJava Application.
    4. Now we are going to do something that you should do frequently as you work on code in this course. We are going to commit and push your code back to bitbucket.
      • See the purple circle in the image above? The > signs indicate that those files or folders have been changed and need to be committed and pushed.
      • Click on the main top level of your repository in the Package Explorer. In the example above, it is the line with Body-12345.
      • Right (control) click on the highlighted entry there, and choose TeamCommit.
      • The result should be similar to this:
      • Notice that the file you modified appears in the Staged Changes window, which is good.
        If ever a file shows up in the Unstaged Changes and you want to include it in the commit and push, then drag it to the Staged Changes window.
      • See the red box in the image above? Use it to find and click on the Commit and Push… button in your eclipse window. You will have to enter a commit message. Try to make it meaningful—more of a challange for this simple change than usual. Typical commit messages are
        • Working on lab 3, but I have the gzorka working.
        • Done with lab 3, glad that's over, but am super excited to try lab 4.
        You get the idea.
      • If all goes well, you get a confirmation window pop-up as shown below.
        Unfortunately, if the push is rejected, you get a similar-looking pop-up but it wil have in tiny font somewhere that the push was rejected.

        To fix that, there is this post on piazza.

    5. Why do we commit and push? The work you do won't be visible by TAs or the instructor until you commit and push.

      Tip: It is good practice to commit your code often. You can always recover any previously committed version of your software. Committing your code allows you to work on the code from a different computer, and ensures that you do not lose your work should your computer fail.

    6. Modify some of the robot instructions, and re-run the program, to gain an understanding of how the instructions in this file affect the robot's behavior.
      Really? We're asking you to program even though you probably don't much about Java yet?

      Well, yes.

      Even after you have learned much about Java, programming, and computer science, you may come across some code that you want to modify to change its behavior. This takes some courage, but see if you can figure out what the robot's instructions do, based on observing the robot and reading the code. Make some changes to the code to test your hypotheses. Soon you will have the robot doing your bidding.

    7. Commit and push again (yes, really, so you get used to doing this).
    8. Once you have the hang of it, try to have the robot make its way from CEC to the instructor's office.
      Tip: Since RobotController.java was the program most recently run, you can run it again simply by clicking the green arrow on the toolbar at the top.
      Each time it runs, you should see the results of your most recent modifications.
      If you pause with the mouse over a location on the map, the x,y coordinate of your mouse location will be shown on the screen.
    9. Commit and push again
    10. After 20 minutes of successful robot navigation, don't spend much more time trying to get the robot to go exactly the right way. Get comfortable with controlling it for a bit, and then you can have it plow through the walls, juggernaut style. That's a bit easier and a lot more fun.

    Also, feel free to walk the route yourself, and stop by the the instructor's office to say hello sometime. Visitors are usually treated to soda and candy.

  8. Commit your work: You are done with the robot, so let's commit and push one last time.

You now know the basic steps to create projects, as well as open, edit, compile, and run Java programs in eclipse. You should also have a basic understanding of sequential execution and how to call methods on ojects. Please ask if you have questions about any of this.

Part II: Anatomy of a Java File, Overview of the Course

OK so you can program a robot now to go where you want it to go. How does this fit into the rest of the course? Based on the instructor's presentation, you will next complete a simple online activity (in pairs if you like), with the goal of understanding the anatomy of a Java file.

The course will then proceed from the most simple aspects of programming in Java to the more complex parts.

Part III: Course Information

Take some time to peruse the web site. Are you clear about course policies concerning grading and attendance?

Make sure your work is committed and pushed before asking the TA to check you off

Submitting your work (read carefully)

Last modified 10:25:11 CDT 03 July 2018
When you are done with this lab, you must be cleared by the TA to receive credit.

This demo box is for lab 0
Last name WUSTL Key Propagate?
(NOT your numeric ID) Do not propagate
lower case only
e.g. Smith j.smith

Acknowledgements and assertion of integrity

You must select one of the options below
The work submitted here was performed in accordance with this course's policy on collaboration.
On your honor, you have neither given nor received any unauthorized aid on this assignment.

However, the following TAs, students, or professors were supportive in completing this assignment.
Their help was also in accordance with course policies.

Thanks to (leave blank if appropriate):

In spite of seeking help as allowable by this course's policy on collaboration, you were unable to complete this assignment. No credit will be received for this assignment.

You would like to be contacted by an instructor to facilitate staying on track in this course.

Comments about this:

You have NOT abided by this course's policy on collaboration. No credit will be received for this assignment, but by checking this box, no academic integrity violation will be filed for this assignment.

You would like to be contacted by an intructor to faciliate staying on track in this course.

Comments about this:

TAs double check!
  • This demo box is for lab 0
  • The student has committed and pushed the work, and verified that it appears at bitbucket.
TA: Password: