![]() |
![]() |
![]() |
![]() |
![]() |
Object Orinented Programming:- Class :- is a blueprint of an object.(Car) Object :- Instance of a class with distinct characteristic.( A specific car) Identity :- Must be indistictguishable from the object of the same class. Behavior :- It provides specific behavior ( Transportation) State :- Attribute, information or data that object stores.(How many miles it travels) Encapsulation :- is a process of hiding the details about how the object perform its duty. (e,g, Driving a car, pushing gas it will run faster. you need not know the mechanism.) Abstraction:- Means ignorance. Ignore and do not depend on what is unimportant. A good abstraction provides aas many operations and attributes as are required to get the job done. If a client is too dependent on the way an opertaion is performed by an object, any modification toi th einternal aspects on that operation may impact the client, requiring additional work to be completed. Inheritance:-Reusing common attributes and operation from base to derived class. If the base does not contain the implementation it is known as abstract class. Base class alse called as superclass. If superclass is not an abstract class(means has some implementation) the subclass can inherit code from superclass or override it by providing its own code. Interfaces:- Interfaces are similar to abstract classes. They difined the method signatures use by other classes but do not implement any code themselves. Since OOp does not allow multiple inheritance you cam implement interfaces. Polymorphism:- is ability to call the same method on multiple objects that have been instattiated from different subclasses and generated different behavior. This is acheived by interface interitance. one interface many interitance. Procedure for defining class:- Add Class to the project with appropriate file name. Create constructor as needed. Create destructor if appropriate. Declare properties. Declare methods and events. Access verifier:- You can set access modifier to specific variable or procedure in the class. .NET added two mre access verifier Protected and Protected friends. public :- Accessible anywhere. private :- Accessible within type itself. Friend :- Accessible within type and all the namespaces and code within the sam assembly. Protected :- Accessible within class and other classes inherting from the class. Protected Friend :- Union of protected and Friend. Declaring Method:- public Class TestClass public sub TestIt(By Val x as Integer) End sub public Function GetIt() as Integer End function End class Declaring Properties:- In VB6 declaring properties by two seperate procedures Get and Let or Set. In .Net you declare properties by using two code blocks in single procedure. [Default | Readonly | Writeonly] property varname [(Parameter list)] [As type name] Get [block] End Get Set(By Val value as typename) [block] End Set End Property Private intMyData as Integer Get Return intMyData End Get Set(By Val Value as Integer) intMyDatae = value End Set End Property Public ReadOnly Property MyData() As Integer 'Readonly has only Get Get Return intMyData End Get Public WriteOnly Property MyData() As Integer 'WriteOnly has only set Set(Byval value as Integer) intMyData = value End Set End Property |
||||
Next Page |