Intro to Objects & Classes II
Class Specifier
Access Modifier
Method Calls
Constructor
Instantiation
Finalizer
Summary
Example


Details of Object-Oriented Implementation

 

Specifying the Class

 

Access modifier



Calling Methods

 

Constructor (Sub New)

Public Sub New ( <optional parameter list> )
      ' initialization of instance variables or other instantiation tasks
End Sub

 

Instantiation

Finalizer (Sub Finalize)

Overrides Protected Sub Finalize ( ) 
      MyBase.Finalize( )     
      ' statements to return system resources
End Sub

Public Sub Dispose( ) Implements IDisposable.Dispose
   myWidget.Dispose
   myWidget = Nothing
   ' Insert additional code
End Sub

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vaconFinalizeDestructors.asp


 

Summary

 

One benefit of the object-oriented approach is the close correspondence between the real-world things being modeled by the program and the objects in the program.

 

This makes it easy to conceptualize a programming problem. You figure out what parts of the problem can be most usefully represented as objects, and then put all the data and methods connected with that object into the class specification.

 

In some situations it may not be obvious what parts of a real-life situation should be made into objects because there are no hard and fast rules. Often you proceed by trial and error. You break the problem into objects in one way and write trial class specifiers for these objects. If the classes seem to match reality in a useful way, you continue. If they don't, you start over, selecting different entities to be classes. The more experience you have with OOP, the easier it will be to break a programming problem into classes.

 

Some of the benefits of object-oriented programming are probably not apparent at this point because OOP was devised to cope with the complexity of large programs. Smaller programs have less need for the organizational power that OOP provides. The larger the program, the greater the benefit.

 


For an example, click here.


 

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmClass.asp

 

 

Please Report Errors in Notes Here