Mistakes I have made

730 views
672 views

Published on

Antipatterns I've been guilty of in Ruby. Why they've happened, and what you can do to prevent them.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
730
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mistakes I have made

  1. 1. Mistakes? I've had a few Andrew Grimm @andrewjgrimm
  2. 2. Excessively large classes <ul><li>Causes </li><ul><li>Adding new features
  3. 3. Fear of passing around data </li></ul><li>Not a problem until modifying existing code was required </li></ul>
  4. 4. Excessively large classes <ul><li>Break into smaller classes
  5. 5. Or modules if you must
  6. 6. def_delegator :@sub_object, :method_foo </li></ul>
  7. 7. Side effects <ul><li>Does your method really need to produce output? Can't it produce a string instead?
  8. 8. You can manipulate strings. You can't manipulate output. </li></ul>
  9. 9. Side effects <ul><li>When testing, how often are you interested in writing to file or writing to a DB?
  10. 10. Aren't you interested in the contents instead? </li></ul>
  11. 11. Side effects <ul><li>Side-effect-free code is easier to test, faster to test, and safer to test </li></ul>
  12. 12. Schlemiel the painter <ul><li>Doing something a million times you only need to do a few times (literally!)
  13. 13. Often the result of mixing separate tasks together </li></ul>
  14. 14. Why maintainability matters <ul><li>Additional functionality
  15. 15. Modifying functionality
  16. 16. Improving performance </li></ul>
  17. 17. Testing <ul><li>If you can't write tests, it may not mean you're bad at testing </li><ul><li>It may mean the production code is bad </li></ul></ul>
  18. 18. Version control <ul><li>Best form of documentation I had
  19. 19. What was I thinking when I wrote that code?
  20. 20. Large commits are a code smell </li></ul>

×