One thing Ruby-lovers pride themselves on is "do as little as possible an get as much for free as possible." Take the following active record example:
class Person < ActiveRecord::Base
belongs_to :company
end
class Company < ActiveRecord::Base
has_many :people
end
Gavin King, the creator of Hibernate ORM has an interesting comment about this :
I completely agree. Ruby plays some magic and when a record is pulled from the database ruby inspects it and adds the needed fields to these "active record" ruby classes. While this is neat and keeps developers from having to plan out their ORM entities I can't help but see the possible problems with doing this on a very complex schema AND entity model.At this point, most developers are thinking
um, ok, so how the hell am I supposed to know what attributes a Company has by looking at my code? And how can my IDE auto-complete them?Of course, the Rails folks have a quick answer to this questionOh, just fire up your database client and look in the database!. Then, assuming that you know ActiveRecord's automagic capitalization and pluralization rules perfectly, you will be able to guess the names of the attributes of your own Company class, and type them in manually.Somehow, excitement about the Ruby language has warped their perceptions to such an extent that these people actually believe that this is a good thing!
No comments:
Post a Comment