[Rails] Re: subclassing vs mixins, which one should be used?

2008-12-10 Thread Frederick Cheung
On Dec 10, 3:02 am, Philip Hallstrom [EMAIL PROTECTED] wrote: I don't know anything about your app, but if you don't use STI (ie.   you leave abstract_class = true) you'll never be able to tell the   difference b/n the two classes. That is... you could.. create a BlockSchedule with ID=1

[Rails] Re: subclassing vs mixins, which one should be used?

2008-12-10 Thread Philip Hallstrom
On Dec 10, 3:02 am, Philip Hallstrom [EMAIL PROTECTED] wrote: I don't know anything about your app, but if you don't use STI (ie. you leave abstract_class = true) you'll never be able to tell the difference b/n the two classes. That is... you could.. create a BlockSchedule with ID=1

[Rails] Re: subclassing vs mixins, which one should be used?

2008-12-10 Thread pepe
Head First Design Patterns is an excellent book IMHO for OO application design. It's geared towards Java but it has excellent points. One of them being 'favor composition over inheritance'. The use of modules in Rails gives so much flexibility that I think going that route would be the

[Rails] Re: subclassing vs mixins, which one should be used?

2008-12-09 Thread Frederick Cheung
On Dec 9, 11:58 pm, BushyMark [EMAIL PROTECTED] wrote: Hey all, I have two models in my rails project that share a lot of traits. They each have the same 4 properties, and now I need to add 2-3 methods to each one that will be the same. In the spirit of DRY I am looking for a solution to

[Rails] Re: subclassing vs mixins, which one should be used?

2008-12-09 Thread BushyMark
Fred, thanks for the info! I like the idea of creating a super class, if only for the naming convention I have setup. I just wanted to check my syntax though. The two models are called BlockSchedule and DaySchedule. Lets say I wanted them both to inherit the properties of a class called

[Rails] Re: subclassing vs mixins, which one should be used?

2008-12-09 Thread Frederick Cheung
On 10 Dec 2008, at 00:13, BushyMark wrote: Fred, thanks for the info! I like the idea of creating a super class, if only for the naming convention I have setup. I just wanted to check my syntax though. The two models are called BlockSchedule and DaySchedule. Lets say I wanted them both

[Rails] Re: subclassing vs mixins, which one should be used?

2008-12-09 Thread Philip Hallstrom
I don't know anything about your app, but if you don't use STI (ie. you leave abstract_class = true) you'll never be able to tell the difference b/n the two classes. That is... you could.. create a BlockSchedule with ID=1 create a DaySchedule with ID=2 BlockSchedule.all = returns both