Projects
Project instructions and specifications.
Why does 373 + 1
evaluate to 374
while "373" + "1"
evaluate to "3731"
? Underlying this question is the concept of a data type. In Java, every variable has a data type like int
or String
. Data types combine representation and functionality. An int
can only represent integer numbers within a certain range and the plus operator computes the sum of the two values. A String
, on the other hand, represents data as a sequence of characters and the plus operator appends the two strings.
Abstract data types (ADTs) are data types that do not specify a single representation of data and only include a specification for the functionality of the data type. In Java, abstract data types are often represented using interfaces like List
, Set
, or Map
. Java provides implementations or specific representations of each interface through classes like ArrayList
, TreeSet
, or HashMap
.
The projects in this course aim to highlight the relationship between abstractions, implementations, and problems. The purpose of programming in this course is to explore the capabilities and design effort that goes into writing a specification. But programming is only a small portion of the projects: a much larger emphasis is placed on comparing the qualities of different solutions. The goal of the projects is learn the how and the why hidden within the project specifications through a synthesis of programming, analysis, and communication.
To start working on the projects, follow the setup steps below.
Project Setup
If you’ve taken CSE 123 recently, you may proceed to Install Git.
Let’s install the Java Development Kit (JDK), install VS Code, and apply the CSE 123 VS Code profile.
- Download and install Adoptium’s OpenJDK.
- Download and install VS Code.
- Download the CSE 123 VS Code profile.
To apply the profile, from the Manage gear icon in the bottom of the Activity Bar, choose Profiles | Import Profile…. When prompted, select the cse123-Java.code-profile
file that you just downloaded. In the new Profiles sidebar panel, select Create Profile and name it “cse123-Java”.
If you can’t find a certain VS Code command, search for it via the Command Palette (Show All Commands), which is accessible from anywhere within VS Code using the shortcut Ctrl Shift P.
Install Git
Git is a version control system (VCS), a tool for distributing, managing, and sharing code with other people. Install Git by following the instructions for your computer’s operating system.
Generate SSH keys
Your project code will be stored on CSE GitLab, a service provided by the Allen School to securely and privately store your coursework. CSE GitLab requires SSH keys: computer-generated passwords used to securely authenticate your computer to CSE GitLab.
- From VS Code, open the Terminal with the Ctrl ` (backtick key, typically above your tab key) shortcut.
- In the terminal, generate an SSH key pair with the command
ssh-keygen -t ed25519
- At each prompt, press
Enter
to continue and accept the default settings.- When promoted to “Enter file in which to save the key”, do not enter a file name. Press enter to accept the default file name and location.
- When prompted to “Enter a passphrase”, press enter without entering a passphrase.
- Print your public SSH key with the command
cat ~/.ssh/id_ed25519.pub
and copy the contents to your clipboard. - In your browser, open the SSH Keys user settings. Sign into GitLab using your UW NetID. Then, paste the public SSH key in the Key field.
- Give it a title if it doesn’t already have one (representing your computer) and then press Add key.
Obtain and run project code
Now that we’ve installed the required software and configured our computer so that it can securely communicate with CSE GitLab, let’s get the project code! This step requires the project repositories to be setup, which will be ready for enrolled students within the first week of the course.
- Visit CSE GitLab and you’ll be greeted by a repository named after your UW NetID.
- Visit your private repository, press the blue Code button and, under the heading Open in your IDE, choose Visual Studio Code (SSH). Be sure to choose the SSH option because we are using SSH keys. If this doesn’t work, you can copy the Clone with SSH address, find the Git: Clone tool in the VS Code command palette, and paste the SSH address. You can choose where you would like to store the project.
- If you see an SSH Confirmation window pop-up, check that the fingerprint matches the CSE GitLab fingerprint. Compare the value to the table entries under the column SHA256. If it matches one of the values, then accept the connection. If it doesn’t match any of the values, do not accept the connection and write an Ed Discussion question with the fingerprint value that your computer shows.
VS Code may prompt you to install Gradle for Java. Do not install Gradle for Java as it will conflict with Language Support for Java. If you accidentally installed it, you can uninstall or disable the extension in VS Code.
The first time you open the project, answer the prompt Yes, I trust the authors so that VS Code has your permission to run code. At the bottom of VS Code, you will see a status bar showing the current state of the Java environment setup process. After a minute or so, the status bar should report “Java: Ready”, so let’s try running a Java class:
- In the Explorer, navigate to the src | main | java folder. This folder contains all the Java program logic for this project.
- Open the BrowserHistory.java file and, in the top right, press the ▷ play button. Alternatively, right click the file and choose Run Java.
If all the software was installed correctly, you should be able to see some text indicating that the class is being run. If you can find the following main
method output somewhere, you’re all set!
[uw.edu, my.uw.edu, cs.uw.edu, canvas.uw.edu]
[cs.uw.edu, notify.uw.edu]
Now that you’re able to run the simple BrowserHistory
class, let’s try running the more complicated MapServer
class. If everything is successful, you’ll see this flurry of messages appear indicating that the app has launched.
[main] INFO io.javalin.Javalin - Starting Javalin ...
[main] INFO org.eclipse.jetty.server.Server - jetty-11.0.24; built: 2024-08-26T18:11:22.448Z; git: 5dfc59a691b748796f922208956bd1f2794bcd16; jvm 17.0.14+7-Debian-1deb12u1
[main] INFO org.eclipse.jetty.server.session.DefaultSessionIdManager - Session workerName=node0
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@587e5365{/,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@3745e5c6{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
[main] INFO org.eclipse.jetty.server.Server - Started Server@29176cc1{STARTING}[11.0.24,sto=0] @2785ms
[main] INFO io.javalin.Javalin -
__ ___ _____
/ /___ __ ______ _/ (_)___ / ___/
__ / / __ `/ | / / __ `/ / / __ \ / __ \
/ /_/ / /_/ /| |/ / /_/ / / / / / / / /_/ /
\____/\__,_/ |___/\__,_/_/_/_/ /_/ \____/
https://javalin.io/documentation
[main] INFO io.javalin.Javalin - Javalin started in 302ms \o/
[main] INFO io.javalin.Javalin - Listening on http://localhost:8080/
[main] INFO io.javalin.Javalin - You are running Javalin 6.5.0 (released March 9, 2025).
You’re done! You can now visit localhost:8080 to try the web app for yourself, but the map images won’t load without the optional steps below.
How do I enable map images in Husky Maps?
To see the map images, sign up for a free MapBox account to get an access token. This access token is used to track your usage and (if you exceed free limits) bill you for their service. Husky Maps primarily uses the Static Images API which, at the time of writing, has a free limit of up to 50,000 requests per month.
Once you have your access token, in VS Code, create a new workspace configuration through the Run | Add Configuration… menu. In the configurations
section, find the entry for MapServer
and add the following JSON:
"env": {
"TOKEN": <YOUR TOKEN HERE>
}
Remember to include double quotes around your token, and add a comma to the end of the preceding line so that the JSON syntax is valid. Finally, re-run the MapServer
class to launch the web app and enjoy the “Ice Cream” map style by Maya Gao.
All the app features work because we’ve provided reference implementations for each interface that we’ll learn in this class. The goal of this approach is to enable you to compare different ways to implement the same functionality, each with their own trade-offs.
Explore Projects
- Deques - Designing and analyzing double-ended queues.
- Autocomplete - Designing and analyzing autocomplete.
- Priority Queues - Designing and analyzing priority queues.
- Shortest Paths - Designing and analyzing shortest paths.