Programming in Coffeescript (Developer's Library)

  • ポイントキャンペーン

Programming in Coffeescript (Developer's Library)

  • ただいまウェブストアではご注文を受け付けておりません。 ⇒古書を探す
  • 製本 Paperback:紙装版/ペーパーバック版/ページ数 383 p.
  • 言語 ENG
  • 商品コード 9780321820105
  • DDC分類 005.2762

Full Description


Use CoffeeScript to Write Better JavaScript Code Than Ever Before!If you can do it in JavaScript, you can do it better in CoffeeScript. And, since CoffeeScript "compiles down" to JavaScript, your code will fit neatly into virtually any web environment. In Programming in CoffeeScript, Mark Bates shows web developers why CoffeeScript is so useful and how it avoids the problems that often make JavaScript code buggy and unmanageable. He guides you through every feature and technique you need to write quality CoffeeScript code and shows how to take advantage of CoffeeScript's increasingly robust toolset.Bates begins with the absolute basics of running and compiling CoffeeScript and then introduces syntax, control structures, functions, collections, and classes. Through same page code comparisons, you'll discover exactly how CoffeeScript improves on JavaScript. Next, you'll put it to work in building applications that are powerful, flexible, maintainable, concise, reliable, and secure. Bates shares valuable tips for better development, illuminating CoffeeScript's hidden gems and warning you about its remaining "rough edges." The book concludes with a start-to-finish application case study showing how to code back-ends and front-ends and integrate powerful frameworks and libraries. Coverage includesUnderstanding the right ways to compile and execute CoffeeScriptUsing CoffeeScript's clean syntax to focus on your code, not JavaScript's distractionsWorking with CoffeeScript's control structures, functions, and argumentsTaking full advantage of CoffeeScript's implementation of collections and iteratorsLeveraging CoffeeScript's full class support to create complex data modelsAutomating common application development tasks with Cake and CakefilesConfiguring Jasmine with CoffeeScript support, and using it to systematically test your codeWriting Node.js server-side applications in CoffeeScriptUsing CoffeeScript to write jQuery and Backbone.js applicationsIntegrating framework code to avoid "reinventing the wheel"Want a better way to create the JavaScript code your web applications need? CoffeeScript is the solution-and this book will help you master it!

Contents

Dedication vAcknowledgments xiiAbout the Author xivPreface xvWhat Is CoffeeScript? xviiWho Is This Book For? xixHow to Read This Book xixHow This Book Is Organized xxiPart I: Core CoffeeScript xxiiPart II: CoffeeScript in Practice xxiiInstalling CoffeeScript xxiiiHow to Run the Examples xxiiiNotes xxivPart I: Core CoffeeScript1 Getting Started 3The CoffeeScript REPL 3In-Browser Compilation 6Caveats 7Command-Line Compilation 7The compile Flag 7The CoffeeScript CLI 8The output Flag 9The bare Flag 9The print Flag 10The watch Flag 10Executing CoffeeScript Files 11Other Options 11Wrapping Up 12Notes 122 The Basics 13Syntax 13Significant Whitespace 14Function Keyword 16Parentheses 16Scope and Variables 18Variable Scope in JavaScript 18Variable Scope in CoffeeScript 19The Anonymous Wrapper Function 20Interpolation 23String Interpolation 23Interpolated Strings 23Literal Strings 25Heredocs 28Comments 29Inline Comments 29Block Comments 30Extended Regular Expressions 31Wrapping Up 31Notes 323 Control Structures 33Operators and Aliases 33Arithmetic 33Assignment 35Comparison 39String 42The Existential Operator 43Aliases 46The is and isnt Aliases 47The not Alias 48The and and or Aliases 49The Boolean Aliases 50The @ Alias 51If/Unless 52The if Statement 53The if/else Statement 54The if/else if Statement 56The unless Statement 58Inline Conditionals 60Switch/Case Statements 60Wrapping Up 63Notes 634 Functions and Arguments 65Function Basics 68Arguments 70Default Arguments 72Splats... 75Wrapping Up 79Notes 795 Collections and Iterations 81Arrays 81Testing Inclusion 83Swapping Assignment 85Multiple Assignment aka Destructing Assignment 86Ranges 90Slicing Arrays 92Replacing Array Values 94Injecting Values 95Objects/Hashes 96Getting/Setting Attributes 101Destructuring Assignment 103Loops and Iteration 105Iterating Arrays 105The by Keyword 106The when Keyword 107Iterating Objects 108The by Keyword 109The when Keyword 109The own Keyword 110while Loops 113until Loops 114Comprehensions 116The do Keyword 119Wrapping Up 120Notes 1216 Classes 123Defining Classes 123Defining Functions 125The constructor Function 126Scope in Classes 127Extending Classes 137Class-Level Functions 145Prototype Functions 150Binding (-> Versus =>) 151Wrapping Up 158Notes 158Part II: CoffeeScript in Practice7 Cake and Cakefiles 161Getting Started 161Creating Cake Tasks 162Running Cake Tasks 163Using Options 163Invoking Other Tasks 167Wrapping Up 169Notes 1708 Testing with Jasmine 171Installing Jasmine 172Setting Up Jasmine 172Introduction to Jasmine 175Unit Testing 176Before and After 181Custom Matchers 187Wrapping Up 190Notes 1919 Intro to Node.js 193What Is Node.js? 193Installing Node 194Getting Started 195Streaming Responses 197Building a CoffeeScript Server 199Trying Out the Server 214Wrapping Up 215Notes 21510 Example: Todo List Part 1 (Server-side) 217Installing and Setting Up Express 218Setting Up MongoDB Using Mongoose 222Writing the Todo API 225Querying with Mongoose 226Finding All Todos 227Creating New Todos 228Getting, Updating, and Destroying a Todo 230Cleaning Up the Controller 232Wrapping Up 236Notes 23611 Example: Todo List Part 2 (Client-side w/ jQuery) 237Priming the HTML with Twitter Bootstrap 237Interacting with jQuery 240Hooking Up the New Todo Form 242Cleaning Up the Todo List with Underscore.jsTemplates 244Listing Existing Todos 247Updating Todos 248Deleting Todos 252Wrapping Up 253Notes 25312 Example: Todo List Part 3 (Client-side w/ Backbone.js) 255What Is Backbone.js? 255Cleaning Up 256Setting Up Backbone.js 256Writing our Todo Model and Collection 260Listing Todos Using a View 263Creating New Todos 265A View per Todo 268Updating and Validating Models from Views 270Validation 272Deleting Models from Views 273Wrapping Up 275Notes 275Index 277