Todd Benson
12/18/2007 7:51:00 PM
On Dec 18, 2007 11:30 AM, Phrogz <phrogz@mac.com> wrote:
> I recently had to solve a one-off problem for work, and the solution I
> came up with was about as non-DRY as you can imagine. I couldn't
> figure out how to make it simple, however. In order to expand my
> knowledge, I'm hoping to get some ideas (or even related problem
> domains) to solve this generically.
>
> The problem was this:
>
> This website has a menu of industries, a menu of categories, and a
> menu of products.
> If a single industry is selected, highlight the categories and
> products are available for that industry.
> If a single category is selected, highlight the industries and
> products are available for that category.
> If a single product is selected, highlight the industries and
> categories available for that industry.
> If a pair of items is selected (for example, one industry and one
> product) show all the related items that match the intersection (for
> example, all the categories that apply to the intersection of those
> two choices).
I'll have a look at your code later, but this looks to me solvable
using queries to the database; that is, if you have a database. If
not, then you are trying to create one, which task I wouldn't wish on
anybody (that's a way of saying I wish you well :). The problem
domain, though, seems confined to be tackled solely in Ruby and still
be maintainable, the solution unstable. I think it would be an
awesome Ruby Quiz!
If you have a database, using SQL (fill in the blanks)...
select <columns that you want> from industries, categories, products
where <condition>
I know, db guys/gals like to use caps for key words, but I tend to be
lazy on lists.
I'm pretty certain you were well aware of this, but I thought I'd
throw the SQL info in for other newbies (like myself, not you) that
struggle with this kind of situation.
From there, it would depend on the tool a person would use to access
the db, you know, all the ones people keep bringing up on the list.
Todd