From: Robert Klemme Date: 2006-11-27T17:25:18+09:00 Subject: Re: coding practise On 26.11.2006 21:04, sempsteen wrote: > I know there are a lot of improvement points here but they are not so > important for me right now. I can improve later after constructing the > true structure. > In above example i have a class definition of amicable numbers. When i > call its constructer method with no arguments it finds the amicable > numbers within the range of 0..1000 and stores them at @numbers > instance variable. By "has_friend?" and "friend_of" methods i'm > looking for a friend number and getting the value of the friend number > for a given number. Just let me note this: doing heavy calculations in constructors feels not right. A constructor's main purpose is to do initialization - which you can argue is exactly what you do. But since this involves quite a bit of calculation I would do this differently. (For example, create a class method that does the calculation and returns a new instance that stores the result.) Kind regards robert