7. “Sometimes I want to do Ruby
because it means that I’m more likely
to be able to do TDD.”
-- Greg Malcolm
8. “I feel like the shackles have been
taken off.”
-- Leon Gersing
9. public interface IGetObjectService<T> where T : EntityBase
{
public T Get(int id);
public IList<T> GetAll();
}
public class GetObjectService<T> : IGetObjectService<T>
{
public GetObjectService(IRepository<T> repository) { }
public T Get(int id) { ... }
public IList<T> GetAll() { ... }
}
24. Patterns and “best practices” are
different between static and dynamic
languages
25. public class Employee
{
public static Employee Load(int id) { ... }
public bool Save() { ... }
public bool Delete() { ... }
}
How do I stub out the Load method in a test?
How can I implement cross-cutting concerns (e.g.
caching when saving) without duplicating code?
26. In Ruby, I can stub out class methods (i.e. static
methods)
27. class Employee < ActiveRecord::Base
include Cacheable
end
module Cacheable
def save
Cache.save(self)
super
end
end
In Ruby, I can mix in modules that will modify the
class
31. Rails for .NET Developers
by Jeff Cohen and Brian Eng
Agile Web Development With Rails
by Sam Ruby, Dave Thomas, David Heinemeier Hansson
Programming Ruby 1.9 (aka the “Pickaxe” book)
by Dave Thomas, with Chad Fowler and Andy Hunt
All found at http://pragprog.com
Losing bids – software development takes too long. Why is it so hard?Wanting to go fasterWanted to write code that does what it says and says what it does
I want my framework to help me fall into the pit of successWould someone new to the framework be more likely to succeed or fail?
Started a new projectLower estimatesConventions (FNH, grid button clicks)Company framework
How many of you do TDD?
Ever been annoyed by:Not being able to override a method unless it’s marked as virtualNot being able to inherit from a sealed classGetting generic constraint errorsNot being able to add methods to an existing classNot having mixinsHaving to use dependency injection in order to testHaving to compile your code every time you change anything
Stories of people going fasterRuby-based consulting companies are doing it that way for a reason
Code and coffeeRails for .NET Developers (next slide)Practice problems
UNIX is very command line driven (install apps through the command line, shell scripting)Closer to the metalUsing Vim as my IDE
Less code means less work, fewer chances to write bugs, easier to maintain
I haven’t written any methods! I’m writing code that writes code for me!
There are gems for everythingIt’s really easily to write little DSLs, so you do the hard things once
Gems for everything, people always trying to improve
-Rails can be the "company framework" that everyone is trying to build -things are done the same way in most Rails projects, so you can join a Rails team and you don't have to learn someone else's homegrown framework -homegrown frameworks often are a big detriment to getting things done (maintenance is hard, keeps you from upgrading your codebase, etc.)Rails works in the enterprise - cleanest 4 yr old codebase I've ever worked on, wouldn't gain much if I could rewrite itLots of big companies using Rails……. (next slide)
Lots of big companies using Rails (Twitter, Github, Hulu, Groupon)-not "switching to Ruby", not "leaving .NET"- don't be afraid of leaving your comfort zone (framework, language, syntax, etc.)- you will learn things that will help you on other platforms/languages-Ruby on Rails is just another tool in my toolbox (that happens to be really good at building web applications)-If Ruby on Rails can help your team develop things better and faster, isn’t it even worth considering?-Do a cost-benefit analysis – will the long term benefit of using Ruby outweigh the time needed to adopt a new technology?