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

JavaScript is not a mature, staid, starched-shirt-wearing programming language. She is young, daring, and free-spirited.

      She doesn't have the same long track record of success for large-scale software projects that languages such as C# and Java have. That's not to say that projects using C# and Java are guaranteed to succeed. If a project using one of those languages isn't successful, however, language choice probably wouldn't be included as a factor contributing to failure.

      As we mentioned in the previous section, JavaScript makes it all too easy to write disastrous code. This has given her a bit of a reputation, reducing the likelihood you'd want to bring her home to meet mom and dad.

      JavaScript's reputation should not automatically exclude her for consideration for projects that could benefit from her strengths. Node.js, a server-side JavaScript engine, is lightweight and highly scalable; perfect for real-time and data-intensive applications. JavaScript may be used to create rich user interfaces in the browser. Client-side frameworks such as Ember and AngularJS may be used to build complete browser-based applications that can help reduce the load on the web server by off-loading presentation logic to the client.

      While we can't guarantee it will succeed, the upcoming chapters will show ways to mitigate the risk of choosing JavaScript for your next project by applying the lessons we've learned while working on our own projects.

      Success will not happen by accident, especially with JavaScript. It requires a firm grasp of engineering principles, which are the subject of the first chapter.

      HOW THIS BOOK IS STRUCTURED

      We've organized the book into five parts.

      Part I, “Laying a Solid Foundation,” covers key concepts of software engineering such as the SOLID and DRY principles. It also discusses the benefits of unit-testing and test-driven development. Part I also introduces the tools and JavaScript libraries that will be used throughout the book. Finally, it discusses objects in JavaScript and their testability.

      In Part II, “Testing Pattern-Based Code,” we describe and use test-driven development to create several useful code patterns. Some of the patterns, such as the Singleton, may be familiar from other languages you're familiar with. Others, such as Promises, are associated primarily with JavaScript.

      Part III, “Testing and Writing with Advanced JavaScript Features,” describes how to leverage and test more advanced features of the JavaScript language. It also covers creation and testing of applications that use advanced program architectures, such as the Mediator and Observer Patterns.

      Part IV, “Special Subjects in Testing,” provides examples of testing DOM manipulation, and it also illustrates the use of static analysis tools to enforce coding standards.

      Finally, Part V, “Summary,” reviews the concepts of test-driven development, and also presents a collection of JavaScript idioms that you will have encountered in the book.

      WHAT YOU NEED TO USE THIS BOOK

      To run the samples in the book, you need the following:

      ● A text editor

      ● A web browser

      The source code for the samples is available for download from the Wrox website at:

      www.wrox.com/go/reliablejavascript

      Open-source software based on the book can be found on GitHub at www.github.com/reliablejavascript.

      CONVENTIONS

      To help you get the most from the text and keep track of what's happening, we've used a number of conventions throughout the book.

      NOTE Notes indicate notes, tips, hints, tricks, and asides to the current discussion.

      As for styles in the text:

      ● We italicize new terms and important words when we introduce them.

      ● We present keyboard strokes like this: Ctrl+A.

      ● We show filenames, URLs, and code within the text like so: persistence.properties.

      We present code in two different ways:

      SOURCE CODE

      As you work through the examples in this book, you may choose either to type in all the code manually, or to use the source code files that accompany the book. All the source code used in this book is available for download at www.wrox.com. Specifically for this book, the code download is on 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

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