Class versus Object

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
m (Added c)
m (Reverted edits by Ebybymic (Talk); changed back to last version by AlexGee)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
'''Object'''
 
'''Object'''
Real world objects shares 2 main characteristics, state and behaviour. Humans have state (name, age) and behaviour (running, sleeping). Cars have state (current speed, current gear) and behaviour (applying brake, changing gear). Software objects are conceptually similar to real-world objects: they too consist of state and related behaviour. An object stores its state in fields and exposes its behaviour through methods.
+
Real world objects shares 2 main characteristics, state and behaviour. Humans have state (name, age) and behaviour (running, sleeping). Cars have state (current speed, current gear) and behaviour (applying brake, changing gear). Software objects are conceptually similar to real-world objects: they too consist of state and related behaviour. An object stores its state in fields and exposes its behaviour through [[Method|methods]].
 +
 
 +
'''Singleton Object'''
 +
By defining a class as a [[Singleton]] you are changing a class into an object. Defining a class as a singleton removes the ability of the class to generate many instances of itself.
  
 
'''Class'''
 
'''Class'''
Class is a “template” / “blueprint” that is used to create objects. Basically, a class will consists of fields, static fields, methods, static methods and constructors. Fields are used to hold the state of the class (e.g. the name of Student object). Methods are used to represent the behaviour of the class (e.g. how a Student object is going to stand-up). Constructors is used to create a new Object as an instance of the Class.
+
Class is a “template” / “blueprint” that is used to create objects. Basically, a class will consists of fields, static fields, methods, static methods and constructors. Fields are used to hold the state of the class (e.g. the name of Student object). [[Method|Methods]] are used to represent the behaviour of the class (e.g. how a Student object is going to stand-up). Constructors is used to create a new Object as an [[Instance]] of the Class.
 +
 
 +
== See Also ==
 +
* [[Instance]]
 +
* [[Subclass]]
 +
* [[Superclass]]
  
 
{{Nomenclature}}
 
{{Nomenclature}}
  
 
[[Category: Nomenclature]]
 
[[Category: Nomenclature]]

Latest revision as of 03:10, 25 November 2010

Object Real world objects shares 2 main characteristics, state and behaviour. Humans have state (name, age) and behaviour (running, sleeping). Cars have state (current speed, current gear) and behaviour (applying brake, changing gear). Software objects are conceptually similar to real-world objects: they too consist of state and related behaviour. An object stores its state in fields and exposes its behaviour through methods.

Singleton Object By defining a class as a Singleton you are changing a class into an object. Defining a class as a singleton removes the ability of the class to generate many instances of itself.

Class Class is a “template” / “blueprint” that is used to create objects. Basically, a class will consists of fields, static fields, methods, static methods and constructors. Fields are used to hold the state of the class (e.g. the name of Student object). Methods are used to represent the behaviour of the class (e.g. how a Student object is going to stand-up). Constructors is used to create a new Object as an Instance of the Class.

See Also


Personal tools