{{sellerTotalView > 1 ? __("sellers", {number: sellerTotalView}) : __("seller", {number: sellerTotalView}) }}, {{numTotalView > 1 ? __("items", {number: numTotalView}) : __("item", {number: numTotalView}) }}
free FREE

Change Your Zip Code

Inventory information and delivery speeds may vary for different locations.

Location History

{{email ? __('Got it!') : __('Restock Alert')}}

We will notify you by email when the item back in stock.

Cancel
Yami

Jingdong book

Effective Ruby:改善Ruby程序的48条建议

{{buttonTypePin == 3 ? __("Scan to view more PinGo") : __("Scan to start")}}

Effective Ruby:改善Ruby程序的48条建议

{{__(":people-members", {'people': item.limit_people_count})}} {{ itemCurrency }}{{ item.valid_price }} {{ itemCurrency }}{{ item.invalid_price }} {{ itemDiscount }}
Ends in
{{ itemCurrency }}{{ item.valid_price }}
{{ itemCurrency }}{{ priceFormat(item.valid_price / item.bundle_specification) }}/{{ item.unit }}
{{ itemDiscount }}
{{ itemCurrency }}{{ item.valid_price }} {{ itemCurrency }}{{ priceFormat(item.valid_price / item.bundle_specification) }}/{{ item.unit }} {{ itemCurrency }}{{ item.invalid_price }} {{itemDiscount}}
{{ itemCurrency }}{{ item.valid_price }}
Sale ends in
Sale will starts after Sale ends in
{{ getSeckillDesc(item.seckill_data) }}
{{ __( "Pay with Gift Card to get sale price: :itemCurrency:price", { 'itemCurrency' : itemCurrency, 'price' : (item.giftcard_price ? priceFormat(item.giftcard_price) : '0.00') } ) }} ({{ itemCurrency }}{{ priceFormat(item.giftcard_price / item.bundle_specification) }}/{{ item.unit }}) Details
Best before

Currently unavailable.

We don't know when or if this item will be back in stock.

Unavailable in your area.
Sold Out

Details

Full product details
Editer Recommend

“Effective Software Development Series”系列经典著作
从模块、内存到元编程,全面总结和探讨Ruby编程中48个鲜为人知和容易被忽视的特性与陷阱
包含大量实用范例代码,为编写易于理解、便于维护、易于扩展和高效的Ruby应用提供了解决方案。
Content Description

本书介绍了改善Ruby程序的48条建议,帮助你编写出易维护且运行快速的Ruby应用程序。它是一本任何Ruby程序员都该读的书。初学者可以学习书中的zui佳实践,从而更好地认识这门语言,有经验的开发者也可以再次审读自己的程序,参考书中介绍的诸多方法进行改进。

如果你是经验丰富的Ruby程序员,本书能帮助你发挥Ruby的全部力量来编写更稳健、高效、可维护和易执行的代码。Peter J.Jones凭借其近十年的Ruby开发经验,总结出48条Ruby的实践、专家建议和捷径,并辅以可执行的代码实例。

Jones在Ruby开发的每个主要领域都给出了实用的建议,从模块、内存到元编程。他对鲜为人知的Ruby方言、怪癖、误区和强力影响代码行为与性能的复杂性的揭示贯穿全书。

每一条都包括具体的、可执行的、清晰组织的指南,还有精细的建议、详尽的技术讨论以及启发性的代码实例。如果存在多种可选方案,Jones也会讲解在特定情况下如何选择方案。

本书将帮助你系统性地改进代码,不是让你盲从准则,而是通过透彻地理解Ruby编程技术来做到这些。

本书内容包括:

● 如何避免Ruby中某些令人惊讶的特质带来的陷阱

● 如果想要无障碍使用Rails(或其他大型框架),你需了解的继承体系

● 如何通过易被误解的方法来用集合进行非常有用操作

● 使用异常来改善代码可靠性的方式

● 实用、有效的测试方案,包括MiniTest Unit和Spec Testing

● 如何可靠地管理RubyGem依赖

● 如何充分利用Ruby的内存管理器和性能分析工具

● 如何通过理解Ruby解析器的内部机制来改进代码效率

Author Description

作者简介

Peter J. Jones

自由软件开发者,Devalot.com的编程课程资深讲师。他从2005年开始从事Ruby编程,并组织撰写、讲授数个程序开发课程,包括11周的Ruby入门课程。


译者简介

刘璐

资深软件开发工程师,现就职于Thoughtworks中国。她主要从事Ruby、Java开发,前端开发也有涉猎,参与多个项目的系统设计与开发,热爱编程,对高质量的代码有着执着的追求(这是Thoughtworks员工的公共属性)。

Catalogue


前言
第1章让自己熟悉Ruby 1
第1条:理解Ruby中的True 1
第2条:所有对象的值都可能为nil 3
第3条:避免使用Ruby中古怪的Perl风格语法 5
第4条:留神,常量是可变的 8
第5条:留意运行时警告 11
第2章类、对象和模块 15
第6条:了解Ruby如何构建继承体系 16
第7条:了解super的不同行为 21
第8条:初始化子类时调用super 25
第9条:提防Ruby最棘手的解析 28
第10条:推荐使用Struct而非Hash存储结构化数据 31
第11条:通过在模块中嵌入代码来创建命名空间 34
第12条:理解等价的不同用法 38
第13条:通过"<=>"操作符实现比较和比较模块 44
第14条:通过protected方法共享私有状态 48
第15条:优先使用实例变量而非类变量 50
第3章集合 54
第16条:在改变作为参数的集合之前复制它们 55
第17条:使用Array方法将nil及标量对象转换成数组 58
第18条:考虑使用集合高效检查元素的包含性 61
第19条:了解如何通过reduce方法折叠集合 65
第20条:考虑使用默认哈希值 69
第21条:对集合优先使用委托而非继承 73
第4章异常 79
第22条:使用定制的异常而不是抛出字符串 79
第23条:捕获可能的最具体的异常 84
第24条:通过块和ensure管理资源 87
第25条:通过临近的end退出ensure语句 90
第26条:限制retry次数,改变重试频率并记录异常信息 94
第27条:throw比raise更适合用来跳出作用域 96
第5章元编程 99
第28条:熟悉Ruby模块和类的钩子方法 99
第29条:在类的钩子方法中执行super方法 105
第30条:推荐使用def?ine_method而非method_missing 107
第31条:了解不同类型的eval间的差异 113
第32条:慎用猴子补丁 118
第33条:使用别名链执行被修改的方法 123
第34条:支持多种Proc参数数量 126
第35条:使用模块前置时请谨慎思考 130
第6章测试 133
第36条:熟悉单元测试工具MiniTest 133
第37条:熟悉MiniTest的需求测试 137
第38条:使用Mock模拟特定对象 139
第39条:力争代码被有效测试过 143
第7章工具与库 149
第40条:学会使用Ruby文档 149
第41条:认识IRB的高级特性 152
第42条:用Bundler管理Gem依赖 155
第43条:为Gem依赖设定版本上限 159
第8章内存管理与性能 163
第44条:熟悉Ruby的垃圾收集器 163
第45条:用Finalizer构建资源安全网 168
第46条:认识Ruby性能分析工具 171
第47条:避免在循环中使用对象字面量 177
第48条:考虑记忆化大开销计算 179
后记 182

Introduction

学习一门新的编程语言通常需要经过两个阶段。第一阶段是学习这门编程语言的语法和结构。如果我们具有其他编程语言的经验,这个阶段通常只需要很短的时间。以Ruby为例,接触过其他面向对象语言的程序员对Ruby的语法也会比较熟悉。有经验的程序员对于语言的结构(如何根据语法构建应用程序)是很熟悉的。
在第二阶段则需要更多的努力。这个阶段也是你深入语言、学习语言风格的时候,许多编程语言在解决常见的问题时都使用了独一无二的方法,Ruby也不例外。比如循环,Ruby没有使用显式循环体来实现,而是使用了代码块和迭代器模式。学习如何突破思维定势,用Ruby的方式解决问题是这个阶段的精髓。
本书也将致力于编程语言学习的两个阶段。但本书并不是一本编程语言的入门级书籍。如果你已经完成了第一阶段,即语法和结构的学习,通过本书你将会对Ruby的理解更加深入和全面,编写出更具可读性、可维护性的代码。在这个过程中,我也会介绍Ruby解释器的内部工作原理,并分享编写更高效程序的相关知识。
Ruby的不同实现和不同版本如你所知,Ruby有一批非常活跃的社区贡献者。他们负责各种各样的项目,其中也包括Ruby解释器的不同实现。除了大家熟知的Ruby官方实现(MRI),我们也有很多其他的选择。想把Ruby应用程序部署到已配置Java环境的机器?没问题,这就是JRuby的用武之地。那Ruby应用程序是否支持智能手机和平板电脑呢?当然,同样也有一款相应的实现。
可以选择的Ruby实现有多种,这也证明了Ruby的活跃性。虽然每种的内部实现都不一样,但对Ruby程序员来说无需太过担心,因为这些解释器的行为和官方的MRI很接近。
本书介绍的很多方法在不同Ruby实现上都是通用的,但也有一些只针对MRI版本,诸如书中提及的垃圾回收机制。本书中指定Ruby特定版本的时候,都是针对MRI版本的。
书中所有代码适用于Ruby 1.9.3及其后的版本。在本书编写时,Ruby最新版本是2.1,Ruby 2.2即将面世。若书中未提及特定的Ruby版本,则示例代码可在所有支持的版本上运行。
关于代码风格的注释在多数情况下,Ruby程序员喜欢使用单一的风格来格式化Ruby代码。当代码没有按照预定义的风格规则编写时,一些RubyGem甚至能够检测出这些不一致的代码风格并斥责你。之所以提到这件事,是因为本书中示例代码所采用的风格可能与通常情况下使用的略有不同(也可能与你之前的风格不同)。
当调用一个方法(method)并向它传参时,我使用圆括号把参数括起来,而紧跟在方法名之后,中间没有空格。在本书之外,我们很容易看到没有圆括号的方法调用,这可能是由于Ruby传参时并不需要圆括号。但是,在第1章中我们会看到,不使用圆括号传参在某些情况下,会导致代码多义性,这迫使Ruby猜测你的意图。由于存在这种多义性,我认为省略掉圆括号是一种不好的编码习惯,我们需要摒弃这种习惯。
我使用圆括号的另一个原因,是为了清晰地表明一个标识符是方法调用还是关键字。你可能会惊讶地发现,你认为的可能是关键字的东西实际上是个方法调用(例如require)。而使用圆括号有助于说明这一点。
在这里讨论代码风格时,我应该指出,当本书中提及方法时,我会使用RI 标记法。如果你不熟悉RI标记法也没有关系,因为它很容易学习并很有帮助。它的主要目的是区分类方法(class method)与实例方法(instance method)。当写类方法时,我会用双冒号(“::”)放在类名与方法名之间。例如,File::open 是File类中名为open的类方法。同样,当写实例方法时,我会用井号(“#”)放在类名与实例方法名之间(例如Array#each)。上述写法同样适用于模块方法(module method)名(例如GC::stat)与模块实例方法(module instance method)名(例如Enumerable#grep)。本书的第40条建议会涉及RI标记法与使用它查询方法文档的更多细节。不过,上述这点入门足以让你开始本书的旅途了。
下载源代码本书会深入探讨很多示例代码。为了更容易理解和消化,代码通常将会分割成小的代码片段,我们会一次一小段地进行讲解。有些不重要的细节代码,我们甚至会忽略掉。可以说,有时候一次看完所有的代码对形成宏观理解是很不错的。本书中所有的代码,可以通过本书的网站下载。



Specifications

Brand Jingdong book
Brand Origin China

Disclaimer

Product packaging, specifications and price are subject to change without notice. All information about the products on our website is provided for information purposes only. Please always read labels, warnings and directions provided with the product before use.

View Full Terms of Use
Add to favorites
{{ $isZh ? coupon.coupon_name_sub : coupon.coupon_ename_sub | formatCurrency }}
{{__("Buy Directly")}} {{ itemCurrency }}{{ item.directly_price }}
Quantity
{{ quantity }}
{{ instockMsg }}
{{ limitText }}
{{buttonTypePin == 3 ? __("Scan to view more PinGo") : __("Scan to start")}}
Sold by JD@CHINA
Ship to
{{ __("Ship to United States only") }}
Free shipping over 69
Genuine guarantee

Added to Cart

Keep Shopping

More to Consider

{{ item.brand_name }}

{{ item.item_name }}

{{ item.currency }}{{ item.market_price }}

{{ item.currency }}{{ item.unit_price }}

{{ item.currency }}{{ item.unit_price }}

Coupons

{{ coupon.coupon_name_new | formatCurrency }}
Clip Clipped Over
{{ getCouponDescStr(coupon) }}
{{ coupon.use_time_desc }}
Expires soon {{ formatTime(coupon.use_end_time) }}

Share this item with friends

Cancel

Yami Gift Card

Get this exclusive deal when paying with gift card

Terms and Conditions

Gift card deals are special offers for selected products;

The gift card deals will automatically be activated if a customer uses gift card balance at check out and the balance is sufficient to pay for the total price of the shopping cart products with gift card deals;

You will not be able to activate the gift card deals if you choose other payment methods besides gift card. The products will be purchased at their normal prices;

If your account balance is not enough to pay for the products with gift card deals, you can choose to reload your gift card balance by clicking on the Reload button at either shopping cart page or check out page;

Products that have gift card deals can be recognized by a special symbol showing 'GC Deal';

For any additional questions or concerns, please contact our customer service;

Yamibuy reserves the right of final interpretation.

Sold by Yami

Service Guarantee

Yami Free Shipping over $49
Yami Easy Returns
Yami Ships from United States

Shipping

  • United States

    Standard Shipping is $5.99 (Excluding Alaska & Hawaii). Free on orders of $49 or more.

    Local Express is $5.99 (Available in Parts of CA, NJ, MA & PA). Free on orders of $49 or more.

    2-Day Express (Includes Alaska & Hawaii) starts at $19.99.

Return Policy

Yami is committed to provide our customers with a peace of mind when purchasing from us. Most items shipped from Yamibuy.com can be returned within 30 days of receipt of shipment (For Food, Beverages, Snacks, Dry Goods, Health supplements, Fresh Grocery and Perishables Goods, within 7 days of receipt of shipment due to damages or quality issues; To ensure that every customer receives safe and high-quality products, we do not provide refunds or returns for beauty products once they have been opened or used, except in the case of quality issues; Some products may have different policies or requirements associated with them, please see below for products under special categories, or contact Yami Customer Service for further assistance).
Thank you for your understanding and support.

Learn More

Sold by Yami

Terms and Conditions of Yami E-Gift Card

If you choose “Redeem automatically” as your delivery method, your gift card balance will be reload automatically after your order has been processed successfully;

If you choose “Send to Email”as your delivery method, the card number and CVV will be sent to the email address automatically;

Any user can use the card number and CVV to redeem the gift card, please keep your gift card information safely. If you have any trouble receiving email, please contact Yami customer service;

Yami gift card can be used to purchase both Yami owned or Marketplace products;

Yami gift card will never expire;

Yami gift card balance does not have to be used up at once;

All rights reserved by Yami.

Return Policy

Gift card that has already been consumed is non-refundable.

Sold by JD@CHINA

Service Guarantee

Yami Free Shipping over $49
Yami Easy Returns
Yami Ships from United States

Shipping

  • United States

    Standard Shipping is $5.99 (Excluding Alaska & Hawaii). Free on orders of $49 or more.

    Local Express is $5.99 (Available in Parts of CA, NJ, MA & PA). Free on orders of $49 or more.

    2-Day Express (Includes Alaska & Hawaii) starts at $19.99.

Return Policy

You may return product within 30 days upon receiving the product. Items returned must be new in it's original packing, including the original invoice for the purchase. Customer return product at their own expense.

Sold by JD@CHINA

Service Guarantee

Yami Cross-store Free Shipping over $69
Yami 30-days Return

Yami-China FC

Yami has a consolidation warehouse in China which collects multiple sellers’ packages and combines to one order. Our Yami consolidation warehouse will directly ship the packages to your door. Cross-store free shipping over $69.

Return Policy

You may return products within 30 days upon receiving the products. Sellers take responsibilities for any wrong shipment or missing items. Packing needs to be unopened for any other than quality issues return. We promise to pack carefully, but because goods are taking long journey to destinations, simple damages to packaging may occur. Any damages not causing internal goods quality problems are not allowed to return. If you open the package and any quality problem is found, please contact customer service within three days after receipt of goods.

Shipping Information

Yami Consolidation Service Shipping Fee $9.99(Free shipping over $69)

Sellers in China will ship their orders within 1-2 business days once the order is placed. Packages are sent to our consolidation warehouse in China and combined there. Our Yami consolidation warehouse will directly ship the packages to you via UPS. The average time for UPS to ship from China to the United States is about 10 working days and it can be traced using the tracking number. Due to the pandemic, the delivery time may be delayed by about 5 days. The package needs to be signed by the guest. If the receipt is not signed, the customer shall bear the risk of loss of the package.

Sold by JD@CHINA

Service Guarantee

Free shipping over 69
Genuine guarantee

Shipping

Yami Consolidated Shipping $9.99(Free shipping over $69)


Seller will ship the orders within 1-2 business days. The logistics time limit is expected to be 7-15 working days. In case of customs clearance, the delivery time will be extended by 3-7 days. The final receipt date is subject to the information of the postal company.

Yami Points information

All items are excluding from any promotion or points events on Yamibuy.com

Return Policy

You may return product within 30 days upon receiving the product. Items returned must be new in it's original packing, including the original invoice for the purchase. Customer return product at their own expense.

Yami

Download the Yami App

Back Top

Recommended for You

About the brand

Jingdong book

为您推荐

Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折

Reviews{{'('+ commentList.posts_count + ')'}}

Have your say. Be the first to help other guests.

Write a review
{{ totalRating }} Write a review
  • {{i}} star

    {{i}} stars

    {{ parseInt(commentRatingList[i]) }}%

Yami Yami
{{ comment.user_name }}

{{ showTranslate(comment) }}Show Less

{{ strLimit(comment,800) }}Show more

Show Original

{{ comment.content }}

Yami
Show All

{{ formatTime(comment.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ comment.likes_count }} {{ comment.likes_count }} {{ comment.reply_count }} {{comment.in_user==uid ? __('Delete') : __('Report')}}
Yami Yami
{{ comment.user_name }}

{{ showTranslate(comment) }}Show Less

{{ strLimit(comment,800) }}Show more

Show Original

{{ comment.content }}

Yami
Show All

{{ formatTime(comment.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ comment.likes_count }} {{ comment.likes_count }} {{ comment.reply_count }} {{comment.in_user==uid ? __('Delete') : __('Report')}}

No related comment~

Review

Yami Yami

{{ showTranslate(commentDetails) }}Show Less

{{ strLimit(commentDetails,800) }}Show more

Show Original

{{ commentDetails.content }}

Yami
Show All

{{ formatTime(commentDetails.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ commentDetails.likes_count }} {{ commentDetails.likes_count }} {{ commentDetails.reply_count }} {{commentDetails.in_user==uid ? __('Delete') : __('Report')}}

Please write at least one word

Comments{{'(' + replyList.length + ')'}}

Yami Yami

{{ showTranslate(reply) }}Show Less

{{ strLimit(reply,800) }}Show more

Show Original

{{ reply.reply_content }}

{{ formatTime(reply.reply_in_dtm) }}

{{ reply.reply_likes_count }} {{ reply.reply_likes_count }} {{ reply.reply_reply_count }} {{reply.reply_in_user==uid ? __('Delete') : __('Report')}}

Please write at least one word

Cancel

That’s all the comments so far!

Write a review
How would you rate this item?

Please add your comment.

  • A nice nickname will make your comments more popular!
  • The nickname in your account will be changed to the same as here.
Thanks for your review
Our community rely on great reviews like yours to find the best of Asia.

Report

If you find this content inappropriate and think it should be removed from the Yami.com site, let us know please.

Cancel

Are you sure to delete your review?

Cancel

You’ve Recently Viewed

About the brand

Jingdong book