出版社:东南大学出版社
年代:2009
定价:48.0
《Ruby最佳实践》正是为想要像专家那样使用Ruby的程序员所准备的。本书由Ruby项目Prawn的开发者所著,简洁地向您阐释如何使用Ruby编写优美的应用程序接口和领域特定语言。此外,还包括如何应用函数式编程的思想和技术,使代码更简洁,使您更有效率。通过本书,您将会学到如何编写可读性更高,表达能力更强的代码,以及许多其他方面的内容。
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
你能够编写真正优雅的Ruby代码吗?《Ruby最佳实践》正是为想要像专家那样使用Ruby的程序员所准备的。本书由Ruby项目Prawn的开发者所著,简洁地向你阐释如何使用Ruby编写优美的应用程序接口和领域特定语言。此外,还包括如何应用函数式编程的思想和技术,使代码更简洁,使你更有效率。通过本书,你将会学到如何编写可读性更高,表达能力更强的代码,以及许多其他方面的内容。《Ruby最佳实践》将会帮助你:* 理解Ruby代码块所蕴含的神秘力量* 学习如何在不破坏原有Ruby代码的情况下进行调整,例如运行时在模块内糅合* 探究测试与调试中的细节,以及如何从易测性出发进行设计* 学习通过让事情保持简单来编写快速代码* 用于文本处理和文件管理的开发策略,包括正则表达式* 理解为什么会发生错误以及错误是如何发生的* 利用Ruby的多语言特性减少文化障碍本书还包含多个章节对测试代码、设计应用程序接口以及项目维护做了全面介绍。《Ruby最佳实践》将陪伴你学习如何将这门丰富、优美的语言发挥到极致。
书籍详细信息 | |||
书名 | Ruby最佳实践站内查询相似图书 | ||
9787564119355 如需购买下载《Ruby最佳实践》pdf扫描版电子书或查询更多相关信息,请直接复制isbn,搜索即可全网搜索该ISBN | |||
出版地 | 南京 | 出版单位 | 东南大学出版社 |
版次 | 影印本 | 印次 | 1 |
定价(元) | 48.0 | 语种 | 英文 |
尺寸 | 26 × 0 | 装帧 | 平装 |
页数 | 印数 | 2000 |
Ruby最佳实践是东南大学出版社于2009.11出版的中图分类号为 TP393.09 的主题关于 计算机网络-程序设计-英文 的书籍。
李刚, 郭秋霞, 编著
(美) 菲茨杰拉德 (Fitzgerald,M.) , 著
(美) 菲滋格尔德 (Fitzgerald,M.) , 著
(美) 琼斯 (Jones,P.J.) , 著
(日) 高桥征义, (日) 后藤裕藏, 著
(美) 弗拉纳根 (Flanagan,D.) , (美) 松本行弘 (Matsumoto,Y.) , 著
(美) 阿弗迪·格林 (Avdi Grimm) , 著
(美) 雷蒙德 (Raymond,S.) , 著
(美) 奥尔森 (Olsen,R.) , 著