This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
We developers spend more than half our time, maintaining code that in most cases we didn't even write. Let's get started in a simulation.
Pre-requisites
- Learn Java Track or a basic understanding of the Java language
- Local Development Environments or some basic experience with the Intellij IDEA IDE.
- Dependency Management with Gradle or light experience with Gradle
- GitHub Basics or a general understanding of how GitHub works.
- Spring Basics or some basic knowledge of how a Spring Application works
- Build a REST API with Spring or some light experience with Spring Boot
The Project
Learn more
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[SOUND] Hello, I'm Craig,
and I'm a developer.
0:00
Did you know that we developers, on
average, spend more than half of our time
0:06
maintaining existing products,
as opposed to writing new ones?
0:10
If we're going to take up more than 50%
of our precious work time in maintenance
0:14
mode, don't you think it's a good idea
to get some hands on practice on how
0:18
that might feel?
0:21
In addition to gaining that experience,
I'd love to have you sharpen
0:22
your debugging skills so that you can
make better usage of all that time.
0:26
So that's what we're going to do for
this workshop.
0:30
We're going to drop into
a very common scenario.
0:31
We're going to simulate a common
development pattern that happens to both
0:34
workers at agencies,
as well as self-employed contractors.
0:37
But before we get started, remember
that there are video speed controls,
0:41
should you need to speed me up or
slow me down.
0:44
Don't forget,
check the teacher's notes on each video.
0:47
I'll link to places where you can
learn even more information, and
0:50
I'll expound on things
presented in the video.
0:52
For instance, right now,
please check the prerequisites so
0:54
we can make sure that
we're on the same page.
0:57
Finally, please ask questions, your
community of fellow students is friendly,
0:59
inviting, and ready to help.
1:03
Also, if you feel like you can
answer a question, give it a spin.
1:05
Everyone wins, and
you'll learn a ton from providing answers.
1:08
Okay, so here's the typical scenario.
1:12
A client comes to you and says,
hey, I got this app developed for
1:15
me from another group of developers, and
1:18
it's pretty much working, but
it keeps doing this weird thing.
1:19
Can you fix it?
1:23
You, of course, say something cautious
like, sure, probably, let me take a look.
1:24
And sometimes you get super lucky,
and the app's well documented and
1:29
thoroughly tested.
1:32
But most of the time it's just not.
1:33
In fact, it most certainly is not
how you would have programmed it.
1:35
It's written in a totally different coding
style than you normally use on your
1:38
projects, and there's usually,
literally zero tests.
1:40
And on top of it all, it has this
monstrous, undocumented, poorly named
1:44
methods, and it's sort of confusing
branches and looping and, yuck, right?
1:49
But you got to pay the bills,
so you take it on.
1:53
Now, this is such a common story that I
thought we should play it out together.
1:57
So what do you say?
2:01
Let's imagine that we, me and
2:02
you, we're running this little
web consulting business together.
2:04
So we're out networking
at a meet-up as we do,
2:07
and we start chatting with
an owner of a little startup.
2:09
Now, their business model is to assist
people in passing certification exams.
2:12
So they have these different study tools
that help their students prepare for
2:16
those exams.
2:18
It seems like a pretty cool idea, right?
2:19
Well, they have this flashcard
web prototype that they have
2:21
some other firm built for them,
and they're pretty happy with it.
2:24
If flashcards are a new concept to you,
2:28
they're a pretty common studying
technique for terms and definitions.
2:30
Now typically,
2:33
one side of an index card, like this
one here, has a term like this, JVM.
2:34
So, what does that mean?
2:38
The idea is you look at this and
try to remember the definition.
2:39
So, what does JVM stand for?
2:43
Come on partner, you know this one.
2:45
So on the back side, here's the answer.
2:47
Java Virtual Machine.
2:49
So the owner tells us they're pretty happy
with the digital version of the flash card
2:51
concept that the firm delivered,
but the contract's up, and
2:54
the other consulting firm
had gone way over budget.
2:57
Now, since you seem so
knowledgeable and friendly, good job,
3:00
by the way, they were wondering if we were
interested in taking on the project and
3:03
making some tweaks and bug fixes.
3:07
Think we should take it?
3:08
Yeah, me too.
3:10
Let's do this.
3:11
Okay, so the code itself is
a Spring Boot application,
3:12
which we have some experience with.
3:14
And I'm sure as a team,
we can figure this stuff out.
3:16
Let's download it and
get it up and running.
3:19
All right, so to begin the simulation, I'm
going to need you to fork this repository.
3:22
Now, that way we can both kind
of make changes to the repo.
3:27
So here I am, I'm at the repository.
3:30
It's linked in the teacher's notes,
3:32
along with some more information
about GitHub in general.
3:34
So what I'm going to do
is I'm going to fork it.
3:36
So I'm going to click fork, and
I'm going to choose my personal account.
3:38
And there, now it exists in my personal
account as a Java-debugging-flashy.
3:43
Now, unfortunately, since issues
don't come across when you fork,
3:48
we're going to have to do
a few more steps later.
3:52
So, the first thing that I want to
do is I want to grab the clone URL.
3:55
I'm going to come over here, and
notice that mine says Clone with SSH.
3:58
I'm going to switch between these two,
I'm going to do that one.
4:02
Choose the git, and
I'm going to flip over to my IntelliJ.
4:05
And notice that I'm using 2016.2.
4:08
That's the current version, and my version
might look a little bit different.
4:11
So here, what I'm going to do is choose
Check out from Version Control, and
4:16
I'm going to choose GitHub.
4:18
Now if you haven't set this up before,
4:20
you might see a little bit
different of a interaction.
4:21
I have two factor
authentication installed, so
4:25
I need to put in a special code, don't
worry, it expires, so you can't copy this.
4:27
Cool, and
now I'm going to paste my repo there, and
4:34
I'm going to leave all those defaults
just as is, and click Clone.
4:36
And it says you've checked out an IDEA
project because we cloned it locally, and
4:42
yeah, we want to open it.
4:46
We want to take a look.
4:47
So we'll click Yes.
4:47
We definitely want to
import the Gradle project.
4:49
It really wants us to click that twice.
4:51
And then I wanna choose create directories
for empty content roots automatically,
4:54
just in case something's
missing that Gradle wants.
4:58
So I'm going to click OK.
5:00
Okay, so now everything's installed, and
5:04
we should have a nice slew of external
dependencies, look at all these.
5:07
All right, that's looking good, and
I'm going to open up the project here.
5:11
And one thing that I noticed is these
are going to be using a different style.
5:15
I saw it, I was looking down here
at the repo, it says contributing.
5:21
The original authors of this code
use the Google Java style guide.
5:26
So I'm going to click the link here,
and just take a look really quick.
5:29
So, Google has their own style because
they have so many projects out there,
5:32
and they publish the Style Guide, which
is awesome so that people can use it.
5:35
And they do things a little bit
differently than the defaults of what your
5:40
editor might be, so for instance,
block indentation is two spaces.
5:42
Normally, the editor's at four.
5:46
So, one main thing that you're going to
notice as soon as we open this is that
5:48
the code is all it two spaces.
5:51
So I think we should switch to
use that Google style guide.
5:53
That doesn't mean we have to go switch all
these settings because there's actually
5:57
a really nice implementation which
has very nicely been linked here
5:59
in the readme by
the creators of this repo.
6:03
So I'm going to click that and
6:05
open this up, and this is a fork from
the Google Style Guide, and like I said,
6:06
there's a new release currently of
IntelliJ, and so, there's a branch here.
6:11
That's the IntelliJ2016 branch.
6:17
I'm going to go ahead and click that.
6:19
This might be a little bit
different if you're watching this.
6:21
I'll try to update that link so
you can go to the right place.
6:23
So what you want to do here you want
to find your file, so this looks good.
6:26
This is what we want,
you want the IntelliJ Google style.
6:31
So here it is.
6:33
These are all the settings, and basically
you can import this into the editor.
6:34
So the way that you do that
is you download this file.
6:37
And to download in GitHub,
there's a little trick.
6:40
If you click this raw,
6:43
it will just show the raw page
without the GitHub stuff around it.
6:44
So if we come back.
6:47
If we right click here, and we choose
Save Link As, it will allow us to save.
6:48
And I'm just going to save it
in my downloads directory.
6:54
And I'm going to flip back
now to the project, and
6:57
I'm going to choose
IntelliJ > Preferences.
7:00
And here under Editor > Code Style,
7:04
if I choose Java,
I can choose Manage and Import.
7:06
And again, so that scheme,
we're going to manage the scheme,
7:13
and we're going to import
IntelliJ IDEA code style.
7:16
And in my downloads directory,
I'm going to find that file I downloaded.
7:20
I'm going to click OK, and I'm going
to call it Google Style, that's great.
7:24
And now and I go ahead and
click Close, and
7:28
what that does that imports
the settings for us.
7:30
So, see, here's the indents at 2,
as opposed to 4 where it normally is, so
7:32
I'm gonna click Apply, and
I'm going to click OK, awesome.
7:36
And so, because we are using Git,
it's going to ask if we want to add this.
7:41
Let's go ahead and say Yes.
7:45
All right, and
now that we've got that all set up,
7:47
I'm going to blow us up to full screen.
7:49
Let's navigate around in here and
7:51
let's see if we can't find
a common starting point.
7:53
So, in Java > App,
let's see what's in here.
7:55
Let's open this up.
7:59
And this is a Spring Boot application,
okay.
8:02
So if we click this play here,
let's do this Run > Run.
8:04
And we'll choose App.
8:10
Okay, so we are up and running,
and it started on port 8080.
8:20
So I'm going to go ahead and
open up localhost:8080 here.
8:25
Well, this is our app here.
8:32
All right, so let's click around,
so refresh your memory.
8:33
Let's say, let's get started.
8:37
So, nice, there's a card here.
8:39
I'll click this.
8:40
And it flips, cool, and
then we can choose next.
8:42
There's the next term.
8:44
And it looks like it says how
many times it's been viewed, and
8:46
you just keep on clicking next, awesome.
8:50
And then the times change there.
8:53
Cool, pretty nice application.
8:57
Let's flip back here and
let's navigate around a little bit.
8:58
Let's take a look at the tests, and
uh-oh, there aren't any at all, yikes.
9:02
So, because this project is from GitHub,
you can use open on GitHub.
9:10
If you right-click and
choose open on GitHub, and
9:15
what it will do is it will open
a window for you, and this is handy,
9:19
because this is where our
issues are going to to be at.
9:23
Which reminds me,
we need to run the Bootstrap program.
9:29
So, the Bootstrap program is, if we
go to local host, then we go to 8080,
9:34
then we and go to bootstrap/GitHub,
9:38
this is what we're going to use to copy our
issues across so that we can have them.
9:41
So, I wrote some instructions here for
you.
9:48
In order to copy issues across, you need
to create a GitHub personal access token.
9:50
So go ahead and click that.
9:54
And if you come in here, you can
click generate new token, and we'll
9:55
do something like treehouse-issue-copier
is what the token description can be.
9:59
And I just want you to click repo.
10:04
And we're going to create this, and then
we're going to delete it right away, so
10:06
don't worry.
10:09
I'm going to generate the token, and
this token is going to be a one use only.
10:10
So you can copy this token, and I'm going
to delete this token when we're done,
10:15
so you can't hack my account.
10:19
So I'm going to click over to Flashy,
and so
10:23
I am going to paste it in here, and
then I'm going to click Submit.
10:26
And it's going to just make sure
that this is the right place,
10:32
make sure that this is the repo that you
want, and that this is your name here.
10:34
And I'm going to click fork it.
10:37
Cool, and it went ahead and
it added all of those issues.
10:40
So if we come back over here and
we refresh, now, see,
10:43
that there's issues in there,
there's six issues in here.
10:46
I'm gonna flip back to my personal access
tokens, and I'm going to click Delete.
10:49
And I understand, delete this token.
10:53
Awesome.
10:55
And with that,
I think we're ready to get started.
10:57
Okay, so the app looks pretty great,
and it seems pretty functional.
11:00
It is a little alarming that
there aren't any tests, but
11:04
it's not the end of the world.
11:06
It just means we'll need to lean
a little bit harder on our old
11:07
friend, the debugger.
11:10
So we can pause the code and
11:11
check its state, just to get a handle
of what's going on line by line.
11:12
If you don't have too much experience
using the debugger, don't worry,
11:16
we'll walk through its
power here in just a few.
11:18
Let's take a quick break,
fill up your beverages, and
11:21
let's take a crack at our first issue.
11:23
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up