Ruby 最佳實踐

Ruby 最佳實踐

Ruby 最佳實踐是東南大學出版社的書

基本介紹

  • 中文名:Ruby 最佳實踐
  • 外文名: Ruby Best Practices
  • 平裝: 309頁
  • 正文語種::英語
  • 類別:寫作類
圖書信息,作者簡介,內容簡介,媒體評論,目錄,

圖書信息

出版社: 東南大學出版社; 第1版 (2010年1月1日)
外文書名: Ruby Best Practices
平裝: 309頁
正文語種: 英語
開本: 16
ISBN: 9787564119355, 7564119357
條形碼: 9787564119355
尺寸: 23 x 17.8 x 1.6 cm
重量: 522 g

作者簡介

Gregory T. Brown是康乃狄克州紐哈芬市的一位Ruby愛好者,他的大多數時間都花在了與Ruby語言相關的自由軟體項目上。他是Ruport的原作者,並且是Prawn的作者,該Ruby庫被用來生成PDF文檔。

內容簡介

你能夠編寫真正優雅的Ruby代碼嗎?《Ruby最佳實踐》正是為想要像專家那樣使用Ruby的程式設計師所準備的。《Ruby 最佳實踐(影印版)》由Ruby項目Prawn的開發者所著,簡潔地向你闡釋如何使用Ruby編寫優美的應用程式接口和領域特定語言。此外,還包括如何套用函式式編程的思想和技術,使代碼更簡潔,使你更有效率。通過《Ruby 最佳實踐(影印版)》,你將會學到如何編寫可讀性更高,表達能力更強的代碼,以及許多其他方面的內容。
《Ruby最佳實踐》將會幫助你:
* 理解Ruby代碼塊所蘊含的神秘力量
* 學習如何在不破壞原有Ruby代碼的情況下進行調整,例如運行時在模組內糅合
* 探究測試與調試中的細節,以及如何從易測性出發進行設計
* 學習通過讓事情保持簡單來編寫快速代碼
* 用於文本處理和檔案管理的開發策略,包括正則表達式
* 理解為什麼會發生錯誤以及錯誤是如何發生的
* 利用Ruby的多語言特性減少文化障礙
《Ruby 最佳實踐(影印版)》還包含多個章節對測試代碼、設計應用程式接口以及項目維護做了全面介紹。《Ruby最佳實踐》將陪伴你學習如何將這門豐富、優美的語言發揮到極致。

媒體評論

“這是一本極為務實的著作,各層次的開發人員都能從中借鑑。”
——Brad Ediger,Madriska Media Group的領袖開發者,同時也是《Advanced Rails》(O'Reilly)的作者
“終於有這樣一本書問世了,它不僅教我如何使用Ruby,更教會我如何正確地使用它。每位Ruby愛好者的書架上都該擺上一本《Ruby最佳實踐》。”
——Jeremy McAnally,ENTP開發者,同時還是《Ruby in Practice》(Manning)一書的作者
“我敢打賭,通過閱讀這本書,你一定學到了可以提高Ruby編程能力的新技巧。”
——James Edward Gray II,代碼忍者及Ruby 1.9 的CSV標準庫的作者

目錄

Foreword
Preface
1. Driving Code Through Tests
A Quick Note on Testing Frameworks
Designing for Testability
Testing Fundamentals
Well-Focused Examples
Testing Exceptions
Run the Whole Suite at Once
Advanced Testing Techniques
Using Mocks and Stubs
Testing Complex Output
Keeping Things Organized
Embedding Tests in Library Files
Test Helpers
Custom Assertions
Conclusions
2. Designing Beautiful APIs
Designing for Convenience: Ruport’s Table( ) feature
Ruby’s Secret Power: Flexible Argument Processing
Standard Ordinal Arguments
Ordinal Arguments with Optional Parameters
Pseudo-Keyword Arguments
Treating Arguments As an Array
Ruby’s Other Secret Power: Code Blocks
Working with Enumerable
Using Blocks to Abstract Pre- and Postprocessing
Blocks As Dynamic Callbacks
Blocks for Interface Simplification
Avoiding Surprises
Use attr_reader, attr_writer, and attr_accessor
Understand What method? and method! Mean
Make Use of Custom Operators
Conclusions
3. Mastering the Dynamic Toolkit
BlankSlate: A BasicObject on Steroids
Building Flexible Interfaces
Making instance_eval( ) Optional
Handling Messages with method_missing( ) and send( )
Dual-Purpose Accessors
Implementing Per-Object Behavior
Extending and Modifying Preexisting Code
Adding New Functionality
Modification via Aliasing
Per-Object Modification
Building Classes and Modules Programmatically
Registering Hooks and Callbacks
Detecting Newly Added Functionality
Tracking Inheritance
Tracking Mixins
Conclusions
4. Text Processing and File Management
Line-Based File Processing with State Tracking
Regular Expressions
Don’t Work Too Hard
Anchors Are Your Friends
Use Caution When Working with Quantifiers
Working with Files
Using Pathname and FileUtils
The tempfile Standard Library
Automatic Temporary Directory Handling
Collision Avoidance
Same Old I/O Operations
Automatic Unlinking
Text-Processing Strategies
Advanced Line Processing
Atomic Saves
Conclusions
5. Functional Programming Techniques
Laziness Can Be a Virtue (A Look at lazy.rb)
Minimizing Mutable State and Reducing Side Effects
Modular Code Organization
Memoization
Infinite Lists
Higher-Order Procedures
Conclusions
6. When Things Go Wrong
A Process for Debugging Ruby Code
Capturing the Essence of a Defect
Scrutinizing Your Code
Utilizing Reflection
Improving inspect Output
Finding Needles in a Haystack
Working with Logger
Conclusions
7. Reducing Cultural Barriers
m17n by Example: A Look at Ruby’s CSV Standard Library
Portable m17n Through UTF-8 Transcoding
Source Encodings
Working with Files
Transcoding User Input in an Organized Fashion
m17n in Standalone Scripts
Inferring Encodings from Locale
Customizing Encoding Defaults
m17n-Safe Low-Level Text Processing
Localizing Your Code
Conclusions
8. Skillful Project Maintenance
Exploring a Well-Organized Ruby Project (Haml)
Conventions to Know About
What Goes in a README
Laying Out Your Library
Executables
Tests
Examples
API Documentation via RDoc
Basic Documentation Techniques and Guidelines
Controlling Output with RDoc Directives
The RubyGems Package Manager
Writing a Gem::Specification
Working with Dependencies
Rake: Ruby’s Built-in Build Utility
Conclusions
A. Writing Backward-Compatible Code
B. Leveraging Ruby’s Standard Library
C. Ruby Worst Practices
Index

相關詞條

熱門詞條

聯絡我們