Archive

Archive for May, 2007

Defining Satisfaction

May 23rd, 2007

Do you actually know what is the definition for satisfaction for You ? Whenever i talk with my friends to earn huge and huge… a lots of time i usually get the comments that its not the money which can always satisfies you! More prior thing is the kind of work you are doing! Are you happy in what u r doing, or u r just doing it for the huge earning…

I thought upon the level of satisfaction which i get by time to time…. there were really diversified views started coming to my mind.. related to various aspects of the satisfaction… What Satisfaction is ? Actually its not just one thing which can feel you happy, satisfied all the time… you need good money, good work, good position! do you ? … i think everybody does!

I categorized the reasons for the satisfaction for the happiness in three categories…

Personal Satisfaction

If you are satisfied in The kind of work you are doing … today… a lots of lucky guys are satisfied in this road of satisfaction destination. And me too fall in that … I am a rubyist, i do rails, i am happy :)

Potential Satisfaction

How much money you are getting(or making too, if u have investor bent of mind)… The level of this is totally created by individual perception and the level upto which you wanna reach… Is it million, millions, billion, billions or more or less for you.. thats always in your mind. That nobody can tell better than yourself… How much you are happy in ?

Professional Satisfaction

Here comes an entirely different aspect of satisfaction. The Position. Whats yours ? A Software Engg, a Senior Software Engg, a Team Lead, a PM or more or less… Where you are happy in ? …. which shoes and hat you wanna wear… Or you are more biased in the clothes you wanna wear…
Whether you are happy with a huge money and a low/middle position or no matter about money but the Position matters you.. Or you wanna have both? Or nothing?

If you want nothing … think more deeply what you actually want… Rethink about the first category of satisfaction! Are you happy in what you are doing?
Think on the other side of the coin…This might be the right time for you to become an Entrepreneur.

sur private, satisfaction

Plugin: Validate Attributes - validate one or more specific attributes

May 20th, 2007

Hi all,
I found an answer(a tweak) to the question which was pinging my mind while working on my current project that How to validate one or more specific attribute of the model(field of the table i mean)?, as the requirement was to save a record after validating the model’s object through 4 steps ie. 4 different forms. Although i found something in the Rails API to put some step constraints on the validations in the model, but i didn’t find it that much flexible so i wrote a snippet which validates one or more specific attributes and can also save the record on the basis of validating specific attributes. Then i thought to pluginize it, as it might be useful

Check out the plugin Validate Attributes
It provides a simple way to validate specific attribute(s) unlike the function valid? which collectively validates all the attributes.

For more information about the plugin regarding SVN repository, usage, example please visit here

If you like/dislike the plugin or if you have some issue/conflict, please do not forget to post a comment.

sur plugin, rails, ror, ruby, rubyonrails, validate_attributes

Ruby is DuckTyped

May 16th, 2007

NOTE : This post may contains repeated and boring stuff for those who already have the programming practice of DuckTyping.

What is Duck Typing ?
Duck Typing is Dynamic Typing
In ruby we do not declare the type of the variable. It automatically becomes the object of the related class. For example, if we assign str = “hello string” then the variable str will automatically becomes the object of class String, that we can confirm by issuing str.class. But according to Duck Typing philosophy even Classes are not Types.
That is the basic rule of Duck Typing is that THE TYPE OF OBJECT IS DETERMINED BY WHAT IT CAN DO, NOT BY ITS CLASS. Lets exemplify the statement…
[source:ruby]
obj = nil

[/source]
now here the object obj is a NilClass object but (in ruby) it will be wrong to say that obj is a NilClass type object. The statement is confining the tasks that can be performed by it. Coz we can have the object obj as a NilClass object and still performing singleton functionalities declared over it. Like …
[source:ruby]
obj = (def wish; puts “good morning, lets code like a Duck :)”; end)
obj # => nil
obj.class # => NilClass
obj.wish # => good morning, lets code like a Duck :) [/source]

So, even a nil object can wish you good morning! Here a method wish has been added to a nil object. But it will not be available for all nil objects, or will that be ? Well, thats a homewok for you!!
Check this out, in this case the wish method will be available for all the nil objects… and the reason is that all the nil objects actually points to a same preserved nil object in the ObjectSpace but not creates a new object everytime like in most cases. Well, i will discuss more deeply regarding the ObjectSpace very soon.

Moreover, extending the modules over an object both at run time and compile time is itself a functionality supporting the statement that Classes are not types and this is what Duck Typing is.

Why known as Duck Typing ?

Alex Martelli, a member of the Python Software Foundation , have given the name DuckTyping to this approach in reference with Duck Test … which says that When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck.
So, if an object is behaving like string the it is string type object but not if only it have the class as String.

sur duck typing, ruby