You are on page 1of 7

-------------------------------------------------------------------------

Attribute / Property
-------------------------------------------------------------------------

C++
member variable / data member

Java
(instance) field

Smalltalk, Objective C, Ruby
instance variable

Self, Dylan, Magik, Io
slot

... (informal; usually applied to getter-setter pair)
attribute / property

JavaScript: property / field
Simula, Perl 6: attribute

-------------------------------------------------------------------------
Class attribute
-------------------------------------------------------------------------

C++
static member variable / static data member

Java
static field / class field

Smalltalk, Objective C, Ruby
class variable

-------------------------------------------------------------------------
Method
-------------------------------------------------------------------------

C++
member function

Java, Simula
method

Smalltalk, Objective C, Ruby
instance method

-------------------------------------------------------------------------
Class method
-------------------------------------------------------------------------

C++
static member function

Java
static method / class method

Smalltalk, Objective C, Ruby
class method (/ singleton method in Ruby)





-------------------------------------------------------------------------
Null
-------------------------------------------------------------------------

C++, Forth, Fortran 90
0 (null pointer) (nullptr in C++0x)

SQL, C (macro)
NULL

Ada, Mathematica
Null

Java, JavaScript, C#, Scala
null

Lisp, Modula-2, Oberon
NIL

Algol, Pascal
nil (case-insensitive)

Smalltalk, Objective C, Ruby, Lua, Io, Clu
nil

Python, Simula
None

Haskell, Visual Basic (case-insensitive)
Nothing

Eiffel
Void

Perl
undef

Magik
_unset

RPL
NOVAL

===============================================================================

JavaScript: null, undefined

Visual Basic: Null, Nothing, Empty, Missing

C/C++: 0 NULL, void

Haskell: Nil, Nothing, Maybe

===============================================================================

Java: Class contains members (fields and methods)








===============================================================================


From: rmartin@oma.com (Robert C. Martin)

There are two distinct vocabularies in OOT. I call them the C++ and

Smalltalk vocabularies because they is a correlation between

the vocabulary that programmers use, and the language that they use.

C++ Smalltalk

------------------------- ------------------------------

Class Class

Object Object

Base Class Super Class

Derived Class Sub Class

Member Function Method, or Instance Method.

Call a Member Function Send a message

Static Member Function Class Method

Member Variable Instance Variable

Static Member Variable Class Variable

Pure Virtual Function Subclass Responsibility

--

Robert Martin | Design Consulting | Training courses offered:

Object Mentor Assoc.| rmartin@oma.com | OOA/D, C++, Advanced OO

14619 N. Somerset Cr| Tel: (708) 918-1004 | Mgt. Overview of OOT

Green Oaks IL 60048 | Fax: (708) 918-1023 | Development Contracts.




















===============================================================================
this, self, super

C++
this : implicit pointer to object instance

Java, Scala, Groovy
this : implicit object reference (current instance)
super : implicit object reference of parent class type

C#
this : implicit object reference (current instance)
base : implicit object reference of parent class type

Ruby
self : current object
super : invokes method with the same name in superclass

Smalltalk
self : receiver of message
super : superclass of the class that defines the message

Magik
_self : receiver of message
_super : receiver as an instance of the superclass

JavaScript
this : object that a function is a method of

Io
self : slot implicitely set to message target or creation context
super : ...

===============================================================================
Access specifiers

C++, Java, C#
public
protected : class & derived classes
private : same class
internal : same assembly (C#)

Ruby
public
protected : same or derived class (any instance)
private : same or derived class and implicit receiver (self)

Python -- access determined by name form
__xxx : private
if the name of a Python function, class method or attribute starts with but does not end with two underscores
it is private (accessible from the module --functions-- or the class --methods and attributes)

everything else is public (including __xxx__ names which is used for special methods)
there's no protected access


===============================================================================
subroutine procedure function routine method






==============================================================================
Associative Arrays

Denomination:
Associative array: awk, PHP, Perl, Tcl
Map: C++, Java, Go
Dictionary: PostScript, Forth, SmallTalk, Objective-C, C#, Python, RealBasic
Hash: Perl, Ruby, (Perl originally used associative array)
Hash table: Common Lisp, Windows PowerShell, (C#)
Table: Lua, Snobol4
Collection: Visual FoxPro
Object/Array: JavaScript
List with named components: R

Awk: core; associative array; h[key]=value
C#: libs; Hashtable / Dictionary<key_type, value_type>
C++: libs; std:map<key_type, value_type>
Erlang: core; keylist [{key, value},...] / dict
Visual FoxPro: Collection
Go: core; map[key_type]value_type {key:value,...}
Haskell: core; list of pairs [(key,value),...]
Java: libs; Map<key_type, value_type>
Javascript: core; object; {key:value,...}
Lisp: core; ((key.value)...)
Lua: core; table {key=value, ...}
Objective-C: libs; NSMutableDictionary
Perl: core; %h = (key=>value,...)
PHP: core; array(key=>value,...)
PostScript: core dict << /key (value)...>>
Python: core dictionary {key:value,...}
REXX: core; Stern variables/Compound variables;
Ruby: core; Hash; {key=>value,...} Ruby 1.9 {symbol_key:value,...}
Scala: libs; Map; Map(key->value, ...)
Smalltak: core; Dictionary;
SNOBOL: core; Table.
Tcl: core; array.
Windows PowerShell: core; hash table; @{key=value;...}
R: core; List; list(key=value,...)

==============================================================================
Constructors

C++
class Cls {
public:
Cls(...) :... {
...
}
}
v = new Cls(...);

Java
public class Cls {
public Cls(...) {
}
}
v = new Cls(...);

CoffeeScript
class Cls
constructor: (...) ->
...
v = new Cls(...)

Python
class Cls:
def __init__(self, ...):
...
v = Cls(...)

Ruby
class Cls
def initialize(...)
...
end
end
v = Cls.new(...)

C#
public class Cls {
public Cls(...) {
...
}
}
v = new Cls(...);

Scala
class Cls(...) {
}
v = new Cls(...)

Groovy
class Cls {
public Cls(...) {
...
}
}
v = new Cls(...)

Magik
def_slotted_exemplar(:Cls, ...)
_method Cls.new(...)
_return _clone.init(...)
_endmethod
_private _method Cls.init(...)
...
_return _self
_endmethod
v << Cls.new(...)

Objective C
@implementation Cls
-(id)init
{
self = [super init];
if (self) {
...
}
return self;
}
v = new Cls(...);

==============================================================================
Symbols
Common Lisp, Clojure, Scheme (symbol): symbol |...|
Common Lisp, Clojure (keyword): :keyword
Erlang (atom): symbol
Prolog (atom, symbol): symbol
Scala (symbol): `symbol
Smalltalk (symbol): #symbol #...

Magik (...): :symbol :|...|
Ruby (symbol): :symbol :... :...

Objective C (SEL): @selector(symbol)
Java: string.intern()

You might also like