The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Class what?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Class what? Posted: Nov 25, 2003 8:41 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Class what?
Feed Title: David Buck - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/buck-rss.xml
Feed Description: Smalltalk can do that
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From David Buck - Blog

Advertisement
The terms "class variables" and "class methods" seem to be widely mis-understood and, hence, misused. You can see this even in professional educational materials. Much of this material seems to use the term "class method" to mean "a method defined within a class" and "class variable" to mean "a variable defined within a class".

The problem is that these terms come from the Smalltalk world and are features found in Smalltalk but don't have equivalents in most other object oriented languages. In Smalltalk, a class method is a method that applies to a class. For example, an instance of Point responds to x, y, dot: and so forth. These are instance methods. The Class Point responds to x:y: to create an instance. This is a class method. The distinction between class methods and instance methods is only made for the sake of the browser - the underlying object oriented mechanisms don't distinguish.

In Smalltalk, a class variable is a single variable whose value is directly visible to all instance methods and class methods of that class as well as from all instance methods and class methods of all subclasses.

The closest thing that C++, Java, and C# have is class static variables and static methods. These aren't quite the same thing as in Smalltalk, but they're very similar. I've seen cases, however, where the term "class variables" was used instead of "instance variables" and the term "class methods" was used instead of "instance methods". It sure gets confusing.

Read: Class what?

Topic: Insert stoppy place? Previous Topic   Next Topic Topic: A bad time to call

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use