refactoring ruby on rails applications
DESCRIPTION
Writing good, maintainable code is hard. You need a lot of experience with the framework to know the little tricks and pit-falls. In this session we take messy code and make it beautiful. We do this by going through examples and refactor them to be more resilient, easier to read, easier to test, and easier to maintain.TRANSCRIPT
Refactoring Rails Applications
Jonathan Weiss, 26.05.2009
Peritor GmbH
2
Who am I ?
Jonathan Weiss
• Consultant for Peritor GmbH in Berlin
• Specialized in Rails, Scaling, Deployment, and Code Review
• Webistrano - Rails deployment tool
• FreeBSD Rubygems and Ruby on Rails maintainer
http://www.peritor.com
http://blog.innerewut.de
3
Refactoring
A Definition:
Refactoring is the process of changing internal structure without modifying its external functional behavior or existing functionality with the goals of readability, maintainability, performance, extensibility, and simplicity.
Wikipedia
4
From
5
To
6
(To)
7
How?
8
Live Coding Experiment
9
Principles
10
MVC
11
Model
Core business model
Domain logic
Reusable
12
View
Dumb representation to the outside
Targeted at specific use case
Displays desired information
Different views of one model
13
Controller
Conductor & connector
Brokers client requests to backend
Decide & delegate rather then labor
14
Principles D R Y
15
You Ain’t Gonna Need It
Ron Jeffries:
Always implement things when you actually need them, never when you just foresee that you need them.
16
Live Coding Experiment
17
Redmine
• A load-balancer distributes the incoming requests
• Some load-balancers will deliver static requests themselves
• Several Rails instances handle all requests
• Number of concurrent requests equals number of Rails instances
18
Redmine
• Multiple projects support
• Flexible role based access control
• Flexible issue tracking system
• Gantt chart and calendar
• News, documents & files management
• Feeds & email notifications
• Per project wiki
• Per project forums
• Time tracking
• SCM integration (SVN, CVS, Git, Mercurial, Bazaar and Darcs)
19
Q & A
20
20
Peritor GmbH
Teutonenstraße 16 14129 Berlin
Telefon: +49 (0)30 69 20 09 84 0 Telefax: +49 (0)30 69 20 09 84 9
Internet: www.peritor.com E-Mail: [email protected]
Peritor GmbH - Alle Rechte vorbehalten