Maintainable JavaScript - Helion
ISBN: 978-14-493-2812-2
stron: 242, Format: ebook
Data wydania: 2012-05-10
Księgarnia: Helion
Cena książki: 126,65 zł (poprzednio: 147,27 zł)
Oszczędzasz: 14% (-20,62 zł)
You may have definite ideas about writing code when working alone, but team development requires that everyone use the same approach. With the JavaScript practices in this book—including code style, programming tips, and automation—you will learn how to write maintainable code that other team members can easily understand, adapt, and extend.
Author Nicholas Zakas assembled this collection of best practices as a front-end tech leader at Yahoo!, after completing his own journey from solo hacker to team player. He also includes rules recommended by other industry authorities. Use these tips and techniques to help your team set aside individual preferences and function at a higher level.
- Establish specific code conventions for your team
- Use tools such as JSLint and JSHint to keep your team on track
- Adopt style guidelines, such as basic formatting, to help your team produce uniform code
- Apply several programming practices to solve problems and improve code quality
- Create an automated JavaScript build system using a variety of utilities
- Integrate browser-based JavaScript testing with tools such as the YUI Test Selenium Driver
Osoby które kupowały "Maintainable JavaScript", wybierały także:
- D3.js w akcji 67,42 zł, (20,90 zł -69%)
- Tablice informatyczne. Node.js 16,86 zł, (5,90 zł -65%)
- Testowanie aplikacji w React.js. Kurs video. Praca z biblioteką Jest.js 69,00 zł, (27,60 zł -60%)
- JavaScript. Kurs video. Programowanie funkcyjne i reaktywne 98,98 zł, (39,59 zł -60%)
- AngularJS. Kurs video. Poziom pierwszy. Tworzenie aplikacji 119,00 zł, (47,60 zł -60%)
Spis treści
Maintainable JavaScript. Writing Readable Code eBook -- spis treści
- Maintainable JavaScript
- SPECIAL OFFER: Upgrade this ebook with OReilly
- Introduction
- Preface
- Conventions Used in This Book
- Using Code Examples
- Safari Books Online
- How to Contact Us
- I. Style Guidelines
- 1. Basic Formatting
- Indentation Levels
- Statement Termination
- Line Length
- Line Breaking
- Blank Lines
- Naming
- Variables and Functions
- Constants
- Constructors
- Literal Values
- Strings
- Numbers
- Null
- Undefined
- Object Literals
- Array Literals
- 2. Comments
- Single-Line Comments
- Multiline Comments
- Using Comments
- Difficult-to-Understand Code
- Potential Author Errors
- Browser-Specific Hacks
- Documentation Comments
- 3. Statements and Expressions
- Brace Alignment
- Block Statement Spacing
- The switch Statement
- Indentation
- Falling Through
- default
- The with Statement
- The for Loop
- The for-in Loop
- 4. Variables, Functions, and Operators
- Variable Declarations
- Function Declarations
- Function Call Spacing
- Immediate Function Invocation
- Strict Mode
- Equality
- eval()
- Primitive Wrapper Types
- 1. Basic Formatting
- II. Programming Practices
- 5. Loose Coupling of UI Layers
- What Is Loose Coupling?
- Keep JavaScript Out of CSS
- Keep CSS Out of JavaScript
- Keep JavaScript Out of HTML
- Keep HTML Out of JavaScript
- Alternative #1: Load from the Server
- Alternative #2: Simple Client-Side Templates
- Alternative #3: Complex Client-Side Templates
- 6. Avoid Globals
- The Problems with Globals
- Naming Collisions
- Code Fragility
- Difficulty Testing
- Accidental Globals
- Avoiding Accidental Globals
- The One-Global Approach
- Namespaces
- Modules
- YUI modules
- Asynchronous Module Definition (AMD) Modules
- The Zero-Global Approach
- The Problems with Globals
- 7. Event Handling
- Classic Usage
- Rule #1: Separate Application Logic
- Rule #2: Dont Pass the Event Object Around
- 8. Avoid Null Comparisons
- Detecting Primitive Values
- Detecting Reference Values
- Detecting Functions
- Detecting Arrays
- Detecting Properties
- 9. Separate Configuration Data from Code
- What Is Configuration Data?
- Externalizing Configuration Data
- Storing Configuration Data
- 10. Throw Your Own Errors
- The Nature of Errors
- Throwing Errors in JavaScript
- Advantages of Throwing Errors
- When to Throw Errors
- The try-catch Statement
- Throw or try-catch?
- Error Types
- 11. Dont Modify Objects You Dont Own
- What Do You Own?
- The Rules
- Dont Override Methods
- Dont Add New Methods
- Dont Remove Methods
- Better Approaches
- Object-Based Inheritance
- Type-Based Inheritance
- The Facade Pattern
- A Note on Polyfills
- Preventing Modification
- 12. Browser Detection
- User-Agent Detection
- Feature Detection
- Avoid Feature Inference
- Avoid Browser Inference
- What Should You Use?
- 5. Loose Coupling of UI Layers
- III. Automation
- 13. File and Directory Structure
- Best Practices
- Basic Layout
- 14. Ant
- Installation
- The Build File
- Running the Build
- Target Dependencies
- Properties
- Buildr
- 15. Validation
- Finding Files
- The Task
- Improving the Target
- Other Improvements
- Buildr Task
- 16. Concatenation and Baking
- The Task
- Line Endings
- Headers and Footers
- Baking Files
- 17. Minification and Compression
- Minification
- Minifying with YUI Compressor
- Minifying with Closure Compiler
- Minifying with UglifyJS
- Compression
- Runtime Compression
- Build-Time Compression
- Minification
- 18. Documentation
- JSDoc Toolkit
- YUI Doc
- 19. Automated Testing
- YUI Test Selenium Driver
- Setting Up a Selenium Server
- Setting Up YUI Test Selenium Driver
- Using the YUI Test Selenium Driver
- The Ant Target
- Yeti
- PhantomJS
- Installation and Usage
- The Ant Target
- JsTestDriver
- Installation and Usage
- The Ant Target
- YUI Test Selenium Driver
- 20. Putting It Together
- Missing Pieces
- Planning the Build
- The Development Build
- The Integration Build
- The Release Build
- Using a CI System
- Jenkins
- Other CI Systems
- 13. File and Directory Structure
- A. JavaScript Style Guide
- Indentation
- Line Length
- Primitive Literals
- Operator Spacing
- Parentheses Spacing
- Object Literals
- Comments
- Single-Line Comments
- Multiline Comments
- Comment Annotations
- Variable Declarations
- Function Declarations
- Naming
- Strict Mode
- Assignments
- Equality Operators
- Ternary Operator
- Statements
- Simple Statements
- return Statement
- Compound Statements
- if Statement
- for Statement
- while Statement
- do Statement
- switch Statement
- try Statement
- White Space
- Things to Avoid
- B. JavaScript Tools
- Build Tools
- Documentation Generators
- Linting Tools
- Minification Tools
- Testing Tools
- Index
- About the Author
- Colophon
- SPECIAL OFFER: Upgrade this ebook with OReilly
- Copyright