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
An introduction to popular code structure strategies.
Terms:
- Narrative flow involves writing your code as if someone were reading a story of how the program will work.
- Iterative coding is a process where you code a small piece of your project and then test it, then code the next piece and test it, so on and so forth.
- KISS, or keep it simple silly, is a popular acronym to remember that simple is usually better.
- DRY, or donβt repeat yourself, is another popular acronym reminding you to keep your code free of repeats whenever possible.
- Refactoring is the process by which you improve existing code.
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
[MUSIC]
0:00
Hi, my name is Megan, and
I'm a teacher at Treehouse.
0:09
When it comes to laying out your code,
there are a lot of pitfalls
0:14
a developer can fall into,
especially when new to programming.
0:18
Repeating code,
code that is disorganized or
0:22
hard to follow, and
over complicating are a few examples.
0:25
It's important to keep in mind
how your code is structured.
0:30
Both the overall file
structure of your project, and
0:33
the code inside of each file too.
0:37
Keeping this in mind will make your code
easier to read and easier to maintain.
0:39
To help you avoid these pitfalls and
improve your coding skills,
0:45
I'm gonna walk you through a few
of my favorite strategies.
0:49
They are narrative flow,
iterative coding, KISS, and DRY.
0:53
Narrative flow involves writing your
code as if someone were reading
1:00
a story of how the program will work.
1:05
Iterative coding is a process where you
code a small piece of your project,
1:07
then test it, then code the next piece and
test it, and so on, and so forth.
1:12
KISS or keep it simple silly,
1:17
is a popular acronym to remember
that simple is usually better.
1:20
And lastly, DRY, or don't repeat
yourself is another popular acronym,
1:25
reminding you to keep your code
free of repeats whenever possible.
1:31
We're going to dive into each
of these strategies in more
1:35
detail throughout this workshop.
1:39
All of these methods can be
implemented while you're coding.
1:41
Doing the hard work up front will save
you a bunch of time in the long run.
1:45
You can also implement these
strategies on a completed project.
1:50
This is called refactoring.
1:54
[SOUND] Refactoring is the process
by which you improve existing code.
1:56
This is a great way to
review your past work,
2:03
make sure it's updated to any new
standards or language updates,
2:06
add any new features, or
practice new skills you've learned.
2:10
Let's get into it.
2:14
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