Re: [Rails] Re: model fields
On 18 December 2010 05:49, Simon Grant <lists@ruby-forum.com> wrote:
Please do not top post, it makes it difficult to follow the thread,
insert your comments into the previous post. Thanks
> Say that I want to create a web form that contains only a few fields
> from a table of 100 fields. To use a model from the table, I would have
> to read all the fields of the model (through an ActiveModel::find ) to
> populate the form. Then when I want to update the values of the form
> back to the database, will not all the 100 field values of the model be
> updated? or just the ones changed. Seems to be very inefficient. I only
> want to read and write the values of the form that I need.
You may think that that there is efficiency but do you know that it
actually matters in your case? I think you are proposing what is
commonly known as Premature Optimisation.
In my experience the bottlenecks in an app are rarely where you expect
them to be at the start. Design your app initially in the simplest
possible way, simple code means less bugs and less development time.
Use Test Driven Design so that you have automated tests that show that
all is working. Once it is running then _if_ you run into throughput
problems that is the time to work out where the bottleneck is and
refactor to improve the situation. As I said above I can virtually
guarantee that you will find that the bottleneck is not where you
initially guessed it would be. The fact that you have a full test
suite means you can happily refactor secure in the knowledge that your
app continues to work.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home