From: Marc Heiler Date: 2007-07-01T18:38:02+09:00 Subject: Re: newby non/programmer trying to understand classes Hi, welcome! "I want to improve my skills and try to leverage the language instead of just brute forcing my way through problems. " When i started on ruby, i was mostly doing php-style. I had 0 classes, i used a lot of functions (in php), and i used a lot of global vars as well. However over the time I started to use classes everywhere. It makes the code cleaner in my experience. You will surely find your personal style. As a rule of thumb, these things helped me in ruby: - Only because a certain feature exists, you do not really have to use it if you arent sure about a use case. For me it was with lambda ;) and one more were class variables (which I personally do not use. Less complexity is easier for me to manager, and i am not sure why to use a class var anyway) - Use namespaces! Many wrap their classes inside a module, but I find even a standalone module without a class totally neat. - Consistent code layout :) tabs or spaces doesnt matter ( i use 2 spaces..) as long as you stick to it - Back to your first post, and I see a user wrote that classes are not needed. I think it depends on your mind-set. For me, I write classes almost everywhere these days. It may be a little extrawork but I felt that wrapping methods to classes (or modules) is really nicer on the long run. I keep reusing my own code stuff in other apps i write - About attr_accessor :first, :last etc... i recommend to write all attr_'s in one place... at best on "top" of your class ie class Foobar attr_reader :matz I even do this: attr_reader :matz attr_writer :really attr_accessor :rocks just because I like visual code formatting, but i think most others write multiple :foo, :bar on one line... ;) PS: No matter how you end up writing code, I believe its very important to provide docu which EXPLAINS to others what you were doing. Especially sometimes I end up seeing code of other people which is really hard to understand, not so much because I dont understand everything (i still learn a lot of new things) but more so because they do it IMHO in a complex manner ... this is hard to understand sometimes. PSS: Just my 1 cc to it, hope you have FUN with ruby! There are many ways but one way is always the best in a given situation :-) -- Posted via http://www.ruby-forum.com/.