OOP
OOP
Advantage of OOP ?
1- Easy maintenance 2- fast development 3- easy to read , organized code ,
modularity
Encapsulation ?
First face : group of elements have the same state (variables) and behavior package(methods) in
model (class)
Second face : data hidden
Name space : is a container to classes and allow to organize code in the shape of development
Nested name space : is container for name spaces and classes
Inheritance : ability to create new classes from existing class
Inheritance gool : reusing of code
Is a relationship : used to describe relationship between subclass and super class in inheritance case
Has a relationship : used to describe relationship between class and other class where first class
taken object from the last class
Sealed modifier : make this class can’t any class inherit from it
Diamond problem : 1-Class can inherit from only one class
2-Class can’t inherit from many classes
Access modifiers : key word added to declaration of class or class member (methods) to allow
restrict their accessibility
3- Protected : 1-access is limited to containing class or types derived from containing class
2-Is similar to private except protected method showed to class inherit from it
even if in the same assembly file or other assembly file
4- Internal : access is limited to current assembly package
it shown to any class in the same assembly file even if in other name space
5- Protected internal : 1-access is limited to current assembly or types derived from containing
class
2- Is a union between internal modifier and protected modifier
3-Any class can inherit from it even if in the same assembly file or in other
assembly file and show methods in class
Constructor : used to initialize the data members during the object initialization
Constructor Guides :
1- Constructor is special method of class used to create valid instance of class
2- Constructor doesn’t have return type not even void
3- Constructor take the shape of method and don’t have return type or keyword
4- Class can have any number of constructor (overloading )
5- Constructor name should be the same as class name
6- Constructor have access modifiers
7- To exit from constructor use return statement
Types of Constructor ?
1- User-defined Constructor 2- default constructor
User-defined Constructor : Passing value during create class inherit from class
Default constructor : initialize data members with default value corresponding to data member
types
This keyword :1- used to differentiate class member and local member
2- Refer to current object of current class
static constructor :
1- class have only one static constructor
2- static constructor has to be parameter less
3- static constructor can’t have any access modifier
4- it used to initialize static data members of class
5- for any number of object creation static constructor get executed only one
6- static constructor get executed when class get need for very first timeline application
7- static constructor can’t be invoked by programmer explicitly
3- new : 1-when used as modifier new keyword hide member inherited from base class
2-hiding inherited methods mean that derived versions of the member replace the base
class