Posted by: savagerider | August 23, 2007

OOP.1

Encapsulation

We wrap methods and attributes together in a class

Constructor does not return any value and it must be public. It is possible to overload the constructor to have different input arguments

With OOP, we could reduce the number of parameters to be passed into the method, instead we initialize the object value and execute the object method.

Composition
A class member that reference objects of other classes. Meaning, a class uses properties or method of another object class.

this keyword is to indicate the current object. For example, this.methodName() or this.variableName.

static keyword allows all objects to share only one copy of variable value. Static method cannot accesss non static variable, so no this keyword is found in static method.

const keyword defines the constant variable in a class. It implies static keyword in the variable. const variable must be initialized when it is created.

readonly keyword defines the variable that can be modified once in an object. The value of it can be varied from one object to another.

Indexer allows us to access variables value in an array manner. This is achievable with the aid of this keyword and property structure of a variable


Leave a response

Your response:

Categories