1 00:00:00,000 --> 00:00:09,460 [MUSIC] 2 00:00:09,460 --> 00:00:14,842 Hi, my name is Megan, and I'm a teacher at Treehouse. 3 00:00:14,842 --> 00:00:18,445 When it comes to laying out your code, there are a lot of pitfalls 4 00:00:18,445 --> 00:00:22,134 a developer can fall into, especially when new to programming. 5 00:00:22,134 --> 00:00:25,810 Repeating code, code that is disorganized or 6 00:00:25,810 --> 00:00:30,532 hard to follow, and over complicating are a few examples. 7 00:00:30,532 --> 00:00:33,502 It's important to keep in mind how your code is structured. 8 00:00:33,502 --> 00:00:37,331 Both the overall file structure of your project, and 9 00:00:37,331 --> 00:00:39,724 the code inside of each file too. 10 00:00:39,724 --> 00:00:45,715 Keeping this in mind will make your code easier to read and easier to maintain. 11 00:00:45,715 --> 00:00:49,802 To help you avoid these pitfalls and improve your coding skills, 12 00:00:49,802 --> 00:00:53,604 I'm gonna walk you through a few of my favorite strategies. 13 00:00:53,604 --> 00:01:00,657 They are narrative flow, iterative coding, KISS, and DRY. 14 00:01:00,657 --> 00:01:05,344 Narrative flow involves writing your code as if someone were reading 15 00:01:05,344 --> 00:01:07,861 a story of how the program will work. 16 00:01:07,861 --> 00:01:12,775 Iterative coding is a process where you code a small piece of your project, 17 00:01:12,775 --> 00:01:17,776 then test it, then code the next piece and test it, and so on, and so forth. 18 00:01:17,776 --> 00:01:20,276 KISS or keep it simple silly, 19 00:01:20,276 --> 00:01:25,676 is a popular acronym to remember that simple is usually better. 20 00:01:25,676 --> 00:01:31,039 And lastly, DRY, or don't repeat yourself is another popular acronym, 21 00:01:31,039 --> 00:01:35,906 reminding you to keep your code free of repeats whenever possible. 22 00:01:35,906 --> 00:01:39,293 We're going to dive into each of these strategies in more 23 00:01:39,293 --> 00:01:41,418 detail throughout this workshop. 24 00:01:41,418 --> 00:01:45,013 All of these methods can be implemented while you're coding. 25 00:01:45,013 --> 00:01:50,102 Doing the hard work up front will save you a bunch of time in the long run. 26 00:01:50,102 --> 00:01:54,148 You can also implement these strategies on a completed project. 27 00:01:54,148 --> 00:01:56,821 This is called refactoring. 28 00:01:56,821 --> 00:02:03,396 [SOUND] Refactoring is the process by which you improve existing code. 29 00:02:03,396 --> 00:02:06,351 This is a great way to review your past work. 30 00:02:06,351 --> 00:02:10,533 Make sure it's updated to any new standards or language updates, 31 00:02:10,533 --> 00:02:14,575 add any new features, or practice new skills you've learned. 32 00:02:14,575 --> 00:02:15,610 Let's get into it.