Topic: Design decision for adding Computer Models

Hello all,

I am developing a cost model tool for my work and I am thinking of using ruby on rails as the platform.  My primary reason is that I want to be able to use the unit testing in Rails in order to speed up the validation part of the "Computer Models".  Please note that models here refer to Computer Models that determine cost.  I am not talking about objects.

One of the design decisions that I am facing is that these Computer Models will change over time.  The tool must be able maintain the old models and be able to rerun them by the user.  We also must be able to maintain the old inputs that went into the older models.

Now their are currently around 70 computer models that I am trying to integrate.  Those 70 models use similar inputs.  Thus model A and model B will have a similar input but are not exactly the same as they also will have different inputs.

So for the same class a couple different computer models will use similar inputs. 
Like the following:

Now I am thinking of designing it as follows:

For every Computer Model I would have a Rails Model with a MySQL table.  When I need to change a Computer Model I then add a Rails Model and another MYSQL Table.  My current thinking is that this is the only way I can maintain the history.

I wanting to hear back from a few people about this choice.  I also want to know if anyone has had a similar issue and what they did to solve the problem.  Feel free to tell me I am off my head out of the clouds.

Thanks for any feedback,

Last edited by pkudrle (2007-02-27 12:30:22)

Re: Design decision for adding Computer Models

Creating a separate model/table for every Computer Model seems like a nightmare to me. That's 70 models and tables to try to manage.

You mentioned they accept different inputs, but they sound similar enough to where I think you can throw them all into one table. Each row in this table will be a separate computer model.

Then comes the question of keeping track of previous input. Take a look at acts_as_versioned. I think it's a little dated, but if nothing else you can get ideas on how to implement this. Basically you would create a "computer_model_versions" table/model which will keep track of the different input. There will be a one-to-many association between the ComputerModel and ComputerModelVersion.

Does that make sense? I can post some code if you need it.

Railscasts - Free Ruby on Rails Screencasts

Re: Design decision for adding Computer Models

Thanks for the feedback ryanb.

Your nightmare is one I am worried about as well.  One of the issues is that we not only need to keep track of previous input, but also reuse previous computer models.  Also while there are cases where some of the computer models work in such a way that I can have one table that has all of the inputs, there are enough one to many, and many to many relationships where a flat table for all models will not quite work.

I am not sure how the ActsAsVersioned will help yet I need to spend a little more time reading it.  I did notice that it requires a plugin.  If we are to stick with Rails we are thinking of only using the main framework with no plug-ins.  I have heard enough horror stories with the main framework and plug-ins breaking through new versions of the framework.

I am trying to describe the problem with UML in order to help tackle the problem.  Attempting to describe the problem is one of my challenges.