Topic: Programming Best Practices Don't Repeat Yourself I'm sure
most of you have heard of the DRY principle. It is something
Rails has taken to heart, and I'm very glad it has. By not
repeating yourself you can freely change something in one area
of the program without worrying if you need to make the same
change in another area. Not only that, but keeping the code DRY
usually leads to better design. Sometimes it is difficult to
find duplication in your code. If you find yourself making a
similar change in multiple places, you should first remove this
duplication so you only need to make the change in one place.
This principle should not only be followed in code, but in your
database and other areas as well. If you are repeating logic or
data in the database, consider changing the design so it is not
repeated. That said, there are times when repeated data is good.
For example, if you are building a cart system, the price for
the items in the cart should be stored in a separate field than
the price for the pr