Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Upgrading Rails? It is a good time to refactor ...
Search
Minqi Pan
April 12, 2014
Programming
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Upgrading Rails? It is a good time to refactor your code
Minqi Pan
April 12, 2014
More Decks by Minqi Pan
See All by Minqi Pan
RubyConf 2017: Packing your Ruby application into a single executable
pmq20
1
770
Node 8 and Friends
pmq20
0
310
Moving Node.js and nodec to v8 Ignition
pmq20
0
420
QCon 2017 Beijing Observations
pmq20
0
350
Node.js Compiler: compiling your Node.js application into a single executable
pmq20
5
25k
Enclose.IO: current cutting-edges and the future work
pmq20
0
330
环境变量为何能让 Ruby 快十倍
pmq20
3
830
Introductions to Node.js internals
pmq20
0
2.2k
How we scaled GitLab for a 30k-employee company
pmq20
6
1.7k
Other Decks in Programming
See All in Programming
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2k
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
410
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
1.2k
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
140
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.3k
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
490
Family mrubyの進捗
kishima
1
120
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
1
710
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
130
AIエージェント時代のコードレビューを設計する
nogu66
6
2.7k
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
400
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
3.2k
What's in a price? How to price your products and services
michaelherold
247
13k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
520
Designing Experiences People Love
moore
143
24k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
250
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
410
Darren the Foodie - Storyboard
khoart
PRO
4
3.9k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
490
Tell your own story through comics
letsgokoyo
1
1.1k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
Transcript
Upgrading�Rails?�It�is�a� good�time�to�refactor� your�code P.S.V.R Powered�by�Rabbit�2.1.2
Rails�4.1�was�released� last�week! 1/39
Why�is�it�a�good�time�to� refactor�your�code?�(1) Trust�me:�if�you�had�time�for� upgrading,�you�would�have�time�for� refactoring 2/39
Why�is�it�a�good�time�to� refactor�your�code?�(2) ���������������������������������������� ������������������������������������������� �������� ������������������������������������������������������������������� some�upgraded�behaviors�require� refactoring�after�all 3/39
Why�is�it�a�good�time�to� refactor�your�code?�(3) ����������������������������������� ��������� ������������������ ��������������������������� �������������������������������� ���������������������������������������������������������� ����������������������������������������������������� You�wan�to�implement�old�functions�via�
new�features 4/39
Roadmap Ⅰ.�Community�Guidelines Ⅱ.�Code�coverage Ⅲ.�Dependencies�updating Ⅳ.�Density�of�Comments Ⅴ.�Cyclomatic�complexity Ⅵ.�Static�code�analyzer Ⅶ.�Commit�messages 5/39
Ⅰ.�Community� Guidelines�(1) ruby-style-guide A�community-driven�Ruby�coding�style� guide https://github.com/bbatsov/ruby-style- guide 6/39
Ⅰ.�Community� Guidelines�(2) ex.�Comments�section 7/39
Ⅰ.�Community� Guidelines�(3) rails-style-guide A�community-driven�Rails�3�&�4�style� guide https://github.com/bbatsov/rails-style- guide 8/39
Ⅰ.�Community� Guidelines�(4) ex.�Routing�section 9/39
Ⅱ.�Code�coverage�(1) simplecov Code�coverage�for�Ruby�1.9+�with�a� powerful�configuration�library�and� automatic�merging�of�coverage�across� test�suites gem�install�simplecov 10/39
Ⅱ.�Code�coverage�(2) 11/39
Ⅱ.�Code�coverage�(3) coveralls.io https://coveralls.io/ gem�ʻcoverallsʼ,�require:�false 12/39
Ⅱ.�Code�coverage�(4) 13/39
Ⅲ.�Dependencies� updating�(1) gemnasium https://gemnasium.com/ 14/39
Ⅲ.�Dependencies� updating�(2) 15/39
Ⅳ.�Density�of� Comments�(1) cf.�http://staff.unak.is/andy/ StaticAnalysis0809/metrics/dc.html 16/39
Ⅳ.�Density�of� Comments�(2) inch Documentation�measurement�tool�for� Ruby,�based�on�YARD. gem�install�inch 17/39
Ⅳ.�Density�of� Comments�(3) 18/39
Ⅳ.�Density�of� Comments�(4) inch-pages https://github.com/rrrene/inch-pages 19/39
Ⅳ.�Density�of� Comments�(5) 20/39
Ⅴ.�Cyclomatic� complexity�(1) developed�by�Thomas�J.�McCabe,�Sr.�in� 1976 For�this�strongly�connected�control� flow�graph,�Cyclomatic�complexity�=�3� is�the�number�of�linearly�independent� cycles�that�exist�in�the�graph,�i.e.�those� cycles�that�do�not�contain�other�cycles� within�themselves.
21/39
Ⅴ.�Cyclomatic� complexity�(2) 22/39
Ⅴ.�Cyclomatic� complexity�(3) ������� ����������� ��� ex.�Cyclomatic�complexity�=�1 23/39
Ⅴ.�Cyclomatic� complexity�(4) ������������������ ������������������������ ��� ex.�Cyclomatic�complexity�=�2 24/39
Ⅴ.�Cyclomatic� complexity�(5) ������������������������������� ��������������������������������������� ��� ex.�Cyclomatic�complexity�=�3 25/39
Ⅴ.�Cyclomatic� complexity�(6) ������������ ���������� ������������������������������� ��������������������������������� ������������������������������������� ����������������������������������� ������������������������������� �����������������������������������
������������������������������� ����� ��� ex.�Cyclomatic�complexity�=�8 26/39
Ⅴ.�Cyclomatic� complexity�(7�-�before) ������������������������ ������������� ��������������������������������������������������������� �������������������������������������� ������������������������������������ ����������������������� ���������������������������������������������� ���������������������
����������������������������� ��������������������������������� ���������������������������������� ���������������������������������������� ��������������������������������� ���������������������������������������������������� ����������������������������������� ����������������������������������� �������������������������������������������������� ������������������������������������������������������������� ���������������������������� ����� ����� ������������� ��� 27/39
Ⅴ.�Cyclomatic� complexity�(8�-�after) ������������������������������������������������������ ������������������������ �������������������������������������������������������� �������������������� �������������������������������������������� ��� 28/39
Ⅴ.�Cyclomatic� complexity�(9�-�after) ���������������� ������������������� ��������������������������� ������������������������������������������������������������� �������������������������������� �������������������������������������� �������������������������������������������������������������������������� ���������������������������������
������������������������������������������������������������ ��� ������ ��� 29/39
Ⅵ.�Static�code�analyzer� (1) rubocop gem�install�rubocop rubocop�-R�>�rubocop.txt 30/39
Ⅵ.�Static�code�analyzer� (2) 31/39
Ⅵ.�Static�code�analyzer� (3) codeclimate https://codeclimate.com/ 32/39
Ⅵ.�Static�code�analyzer� (4) 33/39
Ⅶ.�Commit�messages� (1) good�commit�message�example 34/39
Ⅶ.�Commit�messages� (2) bad�commit�message�examples 35/39
Ⅶ.�Commit�messages� (3) bad�commit�message�examples 36/39
Ⅶ.�Commit�messages� (4) bad�commit�message�examples 37/39
How�to�write�good� commit�messages? Use�English Use�the�imperative,�present�tense:� “change”,�not�“changed”�or�“changes”;� “Fix�bug#1234”�is�better�than�“Fixed� bug�#1234” Use�50-char�title�and�Use�72-character� columns�for�word-wrapping. Read�more:�https://github.com/
torvalds/linux/ pull/17#issuecomment-5654674 38/39
Download�the�slides https://github.com/pmq20 39/39 Powered�by�Rabbit�2.1.2