From: Derek Cannon Date: 2010-04-15T09:46:28+09:00 Subject: Is this good OOP structuring? 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 class CourseController attr_reader :courses_all, :courses_MW, :courses_TR def initialize(html_file) # gets the HTML course data # creates array where each element is a instance of Course # creates arrays using original array's select to get all courses on MW # and TR, so they can be manipulated separately if desired. end end class Main def initialize courses = CourseController.new("www.schoolcourselisting.com") courses.courses_MW each { |i| puts i } # Shows MW courses end end What do you think? Any improvements I should make? CourseController is doing a lot more work than I show. For example, it parses the HTML for data, and returns that data. -- Derek -- Posted via http://www.ruby-forum.com/.