Reliable JavaScript. Lawrence Spencer

Чтение книги онлайн.

Читать онлайн книгу Reliable JavaScript - Lawrence Spencer страница 5

Reliable JavaScript - Lawrence Spencer

Скачать книгу

the Download Code tab at:

      www.wrox.com/go/reliablejavascript

      You can also search for the book at www.wrox.com by ISBN (the ISBN for this book is 978-1-119-02872-7) to find the code. A complete list of code downloads for all current Wrox books is available at www.wrox.com/dynamic/books/download.aspx.

      Most of the code on www.wrox.com is compressed in a .ZIP,RAR, or similar archive format appropriate to the platform. Once you download the code, just decompress it with an appropriate compression tool.

      NOTE Because many books have similar titles, you may find it easiest to search by ISBN; this book's ISBN is 978-1-119-02872-7.

      ERRATA

      We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata, you may save another reader hours of frustration, and at the same time, you will be helping us provide even higher quality information.

      To find the errata page for this book, go to

      www.wrox.com/go/reliablejavascript

      and click the Errata link. On this page, you can view all errata that has been submitted for this book and posted by Wrox editors.

      If you don't spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We'll check the information and, if appropriate, post a message to the book's errata page and fix the problem in subsequent editions of the book.

      P2P.WROX.COM

      For author and peer discussion, join the P2P forums at http://p2p.wrox.com. The forums are a web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

      At http://p2p.wrox.com, you will find a number of different forums that will help you, not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:

      1. Go to http://p2p.wrox.com and click the Register link.

      2. Read the terms of use and click Agree.

      3. Complete the required information to join, as well as any optional information you wish to provide, and click Submit.

      4. You will receive an e-mail with information describing how to verify your account and complete the joining process.

      NOTE You can read messages in the forums without joining P2P, but in order to post your own messages, you must join.

      Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to This Forum icon by the forum name in the forum listing.

      For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works, as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

      PART I

      Laying a Solid Foundation

      CHAPTER 1

      Practicing Skillful Software Engineering

      WHAT’S IN THIS CHAPTER?

      ● Writing code that starts correct

      ● Writing code that stays correct

      WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

      You can find the wrox.com code downloads for this chapter at www.wrox.com/go/reliablejavascript on the Download Code tab. The code is in the Chapter 1 download and organized in directories according to this chapter’s topics, with each directory holding one sample. You can run a sample by copying its directory to your hard drive and double-clicking on the index.html file.

      Few professions are more humbling than computer programming. If we did things right the first time, we could accomplish a day’s work in about 20 minutes. That’s how long it would take to type the debugged lines of code most of us pump out in a day.

      We spend the rest of our time correcting our mistakes as brought to our attention by the compiler, the QA staff, our bosses, and our customers.

      As anyone who has worked on a “mature” system knows, we also waste a lot of time refactoring (or wishing it were possible to refactor) code that has grown brittle and unmaintainable over the years, thanks to poor design decisions by our fellow programmers or even ourselves.

      Yet somehow, we continue to think we’re pretty smart, and that only makes things worse. All our lives, we’ve been the ones who can figure stuff out. We love puzzles and problems. We’re the guys (most of us are guys, and that probably also makes things worse) who don’t like to ask for directions and don’t like to read instructions.

      Plunk us down in the middle of a problem, and we’re optimistic that we can find the way out. On our own.

      This chapter brings good news. Software developers are smart, and some of them have developed techniques that will help us create a lot more than 20 minutes’ worth of code in a day, and with vastly increased aesthetic satisfaction.

      These techniques are not new. Every idea in this chapter is at least a decade old. However, as we have interviewed dozens of candidates for developer positions for our team, from both the United States and abroad, very few have heard of the principles behind the SOLID acronym (let alone the acronym itself). They may have heard of DRY code, but they do not appreciate its absolutely central role in good software development. Misconceptions about unit-testing abound, with many developers unaware of the benefits of letting tests drive the development process.

      When you have mastered these ideas, you will be among the elite. Most developers know about object-oriented programming. Only a few also know about dependency inversion and the Liskov Substitution Principle. Fewer still have mastered test-driven development.

      WRITING CODE THAT STARTS CORRECT

      What Johann Sebastian Bach said about playing a keyboard instrument applies equally to programming a computer: There’s nothing remarkable about it. All one has to do is hit the right

Скачать книгу