From: Robert Dober Date: 2010-04-16T07:25:19+09:00 Subject: Re: Is this good OOP structuring? On Thu, Apr 15, 2010 at 8:00 AM, Robert Klemme wrote: > On 15.04.2010 02:46, Derek Cannon wrote: >> >> Hello everyone. I'm trying to get a hang of object-oriented programming >> and I have a question about the best practices for my program. >> >> I'm making a program to recommend courses to me for my school. To >> simplify things, let's just say every course has 3 variables (they >> actually have a lot more): a name, a day, and a time. >> >> I've made the following, let me know if I can improve on it or am making >> any conventional errors (note, again I've simplified the classes by >> omitting irrelevant methods): >> >> class Course >>   attr_reader :title, :days, :time >>   def initialize(title, days, time) >>     @title = title >>     @days = days >>     @time = time >>   end >> end > > That's perfectly OK although you can shorten that by using Struct's power: > > Course = Struct.new :title, :day, :time > But please be aware that the Struct based implementation is a super implementation of OP's as it exposes the attributes write-ably too. Cheers R. -- The best way to predict the future is to invent it. -- Alan Kay