CS 257: Software Design

Autocomplete, Phase 1 of 3

Folder name: Autocomplete

Work with a partner on this assignment. (Groups of three are also OK.) Do all the installations and account signups individually on your own computers, but share a single git repository for your project. Put both/all of your names in the comments at the top of each source file.

What you should know after phase 1 of this 3-phase assignment:

Your practical goals for this assignment are:

You'll have lots of questions. You'll be able to answer some of them through experimentation and searching the internet, but don't hesitate to ask other people (including me) for help.

Need more detail? Here we go...

1. Find a partner

If you want me to connect you to somebody, personal-message me on Slack right away.

2. Set up an account on GitHub

You can create an account at https://github.com. Once you have a GitHub account, post your github user name on the appropriate thread on our class Slack channel.

3. [If you're working on your own computer] Install IntelliJ Community Edition on your computer

Get it at IntelliJ Community Edition.

4. Accept your repository in the @carleton-cs257-spring18 GitHub organization.

I'll send you a link once you have let me know your github user name. Follow that link to accept your git repository for doing homework this term.

A repository is essentially a folder in which you can store whatever files and subfolders you want. What makes a repository more than a folder, however, is that the version control system (git, in this case) keeps track of all the changes that get made to the files in the repository. This saving of history makes it possible for you to retrieve old work, track down the time when a bug was introduced (and who introduced it), collaborate on a project with a team of programmers, easily back up your work, etc. Version control systems are a bit of a hassle to learn for the first time, but they're indispensable programming tools and unquestionably worth the effort.

5. [If you're working on your own computer] Install git on your computer

You can get git here. It's possible that you already have git on your computer (e.g. it's available by default on most Macs).

Once you install git, you'll be able to use it from the command line. For many people, that's sufficient. However, there are some benefits to using a GUI git client, too. Since we'll be using GitHub to host our git repositories, you might find GitHub Desktop a good choice.

Because you will be coding in multiple languages this term, I recommend that you not use the git support built into IntelliJ.

For the rest of this document, whenever there's need to show a git operation, I will show you the git command-line version of that operation. If you're using GitHub Desktop or any other git client, you'll need to figure out the equivalent operations in your client.

5a. [Optional but recommended] Windows only: Install the Linux Subsystem for Windows

Install Microsoft's Linux Subsystem for Windows beta to get access to a wide range of Unix/POSIX/GNU tools. These are the tools that you'll see me using all the time in a Mac terminal, because macOS is based on a Unix core. Similarly, Linux is a variant of Unix, and thus has all the usual Unix tools. Windows has its own command-line interface and command collection that's plenty powerful, so you can definitely work to become an expert on that interface and not worry about having Unix on Windows. That said, the documentation and open source software available for Unix-like systems is a huge benefit to day-to-day programmers, and I personally never work long with a Windows machine without first making sure I have a Unix command line to work with. Since I won't be demonstrating Windows-specific tools at all this term, you might find it handy to have the tools that I do demonstrate.

6. Create a local clone of your repository

That link you got on the "You are ready to go!" page in Step 4 above? You need it now. Right now, your repository is stored only on the GitHub server. To add files to it, you'll need to clone a copy of the repository onto your working computer. You will then add files to your local copy of the repository and push your changes back up to GitHub.

You'll do your cloning via the following operation (or its GUI equivalent):

git clone https://github.com/...

where the "..." is the remainder of the link you got from the "You are ready to go!" page. You should now have a folder called "assignments-yourgithubname", which contains only a subfolder called ".git". You can move this folder wherever it's convenient for you. (Curious about the contents of the .git folder? Go ahead and poke around to see what's there. It gets more interesting, of course, after you add some files.)

IMPORTANT FOR WINDOWS USERS: When you do this, you will need to be careful about where you put your files. If you put your repository inside the Linux file tree (by, say, doing "cd" at the bash prompt to get to your Linux home directory and then doing "git clone ..." to put your git repository there), you'll run into file permissions trouble when you create your IntelliJ project in the repository. There's a simple solution. You can use bash to access files in the normal Windows file system (say, on your C drive) by doing this:

cd /mnt/c/Users/YourWindowsUserName/Desktop git clone https://github.com/...
which will put your repository on the Windows desktop. (Feel free to modify "Desktop" to put the repo somewhere more convenient if you'd like, "Documents" or "Documents/cs257/" or whatever.) By using the /mnt/c file tree, you enable bash to work effectively with the normal Windows file permissions system.

7. Add a .gitignore file to your repository

When we create an IntelliJ project in our repository, IntelliJ will create a bunch of files for us. Most of those files (like Main.java and Autocomplete.iml) are files that really define the project itself. Main.java is a Java source code file. Autocomplete.iml tells IntelliJ which source files are in the project, and in which folders they're located. And so on.

But there are a few files that are one-person-only kinds of files. Like "which source window did I have open last time?" and "what color preferences do I have for this project?" and "what editor settings am I using?" and the like. If you share those files with a collaborator, sometimes (often!) the collaborator's system will get messed up, the program might not build correctly, and everybody gets frustrated.

There are other files that we never want to add to our repository. For example, there are those ".DS_Store" files that the macOS Finder leaves lying around everywhere. And *.pyc files that you get when you import one python file into another python file. And the *.class files you get when you compile *.java files. We just don't want any of that crap saved in our repositories. So we need a way to avoid sharing those files.

Fortunately, git provides us with just such a tool, called the ".gitignore file". You'll learn more about .gitignore later, but for now:

8. Create an IntelliJ project

Here are the steps. (There's also good help at the JetBrains IntelliJ Help page.)

9. Add your IntelliJ files to your repository

(Curious again? Take a look at what your repository now looks like on GitHub. Also, you can take a look at the contents of .git on your computer to see whether anything changed.)

10. Add a little bit of code, commit, and push again

11. Add your partner as a contributor to your repository

Go to GitHub, make sure you're signed in, and go to the page of your new repository. Figure out how to make your partner a contributor. That is, give your partner read and write permissions, but not administrator permissions. Hint: go to GitHub, login, find your repository's main page, go to Settings, and then you can take it from there.

Once you are both contributors to each other's repositories, you should each try cloning each other's repos, making a small change to Main.java, adding, committing, and pushing.

Once you have pushed a changes to your partners' repositories, they should do "git pull" in their own clones of that repository, to obtain your changes. Try this back and forth until you can effectively share code with each other.

We'll do an exercise on this at the beginning of class Wednesday.