Artwork

内容由iteration podcast, John Jacob, and JP Sio - Web Developers提供。所有播客内容(包括剧集、图形和播客描述)均由 iteration podcast, John Jacob, and JP Sio - Web Developers 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal
Player FM -播客应用
使用Player FM应用程序离线!

Refactoring - In Practice

34:53
 
分享
 

Manage episode 229976776 series 1900125
内容由iteration podcast, John Jacob, and JP Sio - Web Developers提供。所有播客内容(包括剧集、图形和播客描述)均由 iteration podcast, John Jacob, and JP Sio - Web Developers 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal

In this episode we dive deep into some specific refactors from Refactoring 's Chapter 1. We talk about renaming things, extracting functions, functions, replacing a temp with query and some other hot tips and tricks you can put into your code today.

This episode walks through specific code examples from Chapter 1 of Martin Fowler's Refactoring...

Some of the refactors

Change Function Declaration

  • Rename things
  • Names are hard
  • A few general categories of things you can name
    • predicate? - Should only return true / false - Javascript start with is - ruby question mark - so isValidPhone(number)
    • In Ruby - ! For destructive / dangerous actions - update_recent_activity! - name destructive actions or actions with side effects really well.
    • Formatting? - use - as - number_as_phone(number) or to to_bmi(user.weight, user.height)

Extract Function

Replace temp w/ query

  • Extending this example:

Instead of:

accounts = get_accounts(user)
transactions = get_transactions(accounts)

we can just do:

transactions = get_transactions(get_accounts(user))

Replace conditional with polymorphism

Notification.deliver! example

Picks

  continue reading

78集单集

Artwork

Refactoring - In Practice

iteration

113 subscribers

published

icon分享
 
Manage episode 229976776 series 1900125
内容由iteration podcast, John Jacob, and JP Sio - Web Developers提供。所有播客内容(包括剧集、图形和播客描述)均由 iteration podcast, John Jacob, and JP Sio - Web Developers 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal

In this episode we dive deep into some specific refactors from Refactoring 's Chapter 1. We talk about renaming things, extracting functions, functions, replacing a temp with query and some other hot tips and tricks you can put into your code today.

This episode walks through specific code examples from Chapter 1 of Martin Fowler's Refactoring...

Some of the refactors

Change Function Declaration

  • Rename things
  • Names are hard
  • A few general categories of things you can name
    • predicate? - Should only return true / false - Javascript start with is - ruby question mark - so isValidPhone(number)
    • In Ruby - ! For destructive / dangerous actions - update_recent_activity! - name destructive actions or actions with side effects really well.
    • Formatting? - use - as - number_as_phone(number) or to to_bmi(user.weight, user.height)

Extract Function

Replace temp w/ query

  • Extending this example:

Instead of:

accounts = get_accounts(user)
transactions = get_transactions(accounts)

we can just do:

transactions = get_transactions(get_accounts(user))

Replace conditional with polymorphism

Notification.deliver! example

Picks

  continue reading

78集单集

所有剧集

×
 
Loading …

欢迎使用Player FM

Player FM正在网上搜索高质量的播客,以便您现在享受。它是最好的播客应用程序,适用于安卓、iPhone和网络。注册以跨设备同步订阅。

 

快速参考指南