Class method vs instance method??? 
Author Message
 Class method vs instance method???

Hi

I'm new with Smalltalk (specially VisualWorks)..
Can Someone tell me the difference between class protocol and instance
protocol in order to construct new methods???  
BTW, I'm familiar with OOP (Smaltalk and his syntax), it's only that I
don't know when to apply them and why we shoiuld choose class method
instead of instance methods.

Thanks in advance!



Wed, 18 Jun 1902 08:00:00 GMT  
 Class method vs instance method???

Quote:

> Hi

> I'm new with Smalltalk (specially VisualWorks)..
> Can Someone tell me the difference between class protocol and instance
> protocol in order to construct new methods???
> BTW, I'm familiar with OOP (Smaltalk and his syntax), it's only that I
> don't know when to apply them and why we shoiuld choose class method
> instead of instance methods.

> Thanks in advance!

In Smalltalk, classes are object, you can send messages to them.
Instance protocol is the protocol of instances
of the class and class protocol is the protocol of the class itself.

...Mike



Wed, 18 Jun 1902 08:00:00 GMT  
 Class method vs instance method???

: > Hi
: >
: > I'm new with Smalltalk (specially VisualWorks)..
: > Can Someone tell me the difference between class protocol and instance
: > protocol in order to construct new methods???
: > BTW, I'm familiar with OOP (Smaltalk and his syntax), it's only that I
: > don't know when to apply them and why we shoiuld choose class method
: > instead of instance methods.
: >

        Well, the way I see it, you define a class method when you want to
send a message to the class (eg. create an object of that class). You'll
define an instance method when you want to send a message to am object ONCE
it has been created (probably you'll create it using a class method).
        Hope this helps!!

--
   ___  ____                              




Wed, 18 Jun 1902 08:00:00 GMT  
 Class method vs instance method???

Quote:

> Hi

> I'm new with Smalltalk (specially VisualWorks)..
> Can Someone tell me the difference between class protocol and instance
> protocol in order to construct new methods???
> BTW, I'm familiar with OOP (Smaltalk and his syntax), it's only that I
> don't know when to apply them and why we shoiuld choose class method
> instead of instance methods.

> Thanks in advance!

My short explanation is as follows.

If the method behavior creates a new instance, retrieves an existing
instance
or is information that is true for all of its instances, then it is a
candidate for
being a class method. Otherwise, it is probably an instance method.

One of the most important activities of Smalltalking is the assignment
of responsibilities to different objects. Think about the responsibilities

of Class objects, then reread the preceeding paragraph.

Explore, Experiment, Enjoy
John Sarkela



Wed, 18 Jun 1902 08:00:00 GMT  
 Class method vs instance method???

Quote:


>> Hi

>> I'm new with Smalltalk (specially VisualWorks)..
>> Can Someone tell me the difference between class protocol and instance
>> protocol in order to construct new methods???
>> BTW, I'm familiar with OOP (Smaltalk and his syntax), it's only that I
>> don't know when to apply them and why we shoiuld choose class method
>> instead of instance methods.

>> Thanks in advance!

My rule is:  "If the method does not need any value specific to an instance,
then it should be a class method"

Kevin



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Class methods vs Instance methods

2. Class method vs instance method???

3. accessing a instance method from a class method

4. same method as class and instance methods?

5. Class Methods (as opposed to Instance Methods)

6. Object Tcl question - Class method and Instance method

7. IncrTcl: calling static methods vs instance methods

8. Class vs Instance methods

9. Class vs Instance methods

10. Classes - instance/class, methods/members, inheritance and best p ractices

11. Classes - instance/class, methods/members, inheritance and be st practices

12. Singleton methods and instance methods with same name?

 

 
Powered by phpBB® Forum Software