SlideShare uma empresa Scribd logo
1 de 48
Implementing Object-oriented Programming in
Visual Basic .NET
Objectives
In this lesson, you will learn to:
 Identify the advantages of using classes and objects
 Identify the use of structures
 Identify the use of abstract classes in Visual Basic .NET
 Identify the use of interfaces
 Identify the differences between interfaces and abstract
  classes
 Identify the use of assemblies
 Identify the application hierarchy in Visual Basic .NET
 Create and instantiate a class
©NIIT          Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 1 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Objectives (Contd.)
Declare and import namespaces
Create an inherited form in Visual Basic .NET




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 2 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Object-orientation in Visual Basic .NET
 Visual Basic .NET:
     Supports the four pillars of object-oriented programming:
         ® Encapsulation

         ® Abstraction

         ® Inheritance

         ® Polymorphism

     Uses predefined classes provided by the .NET
      Framework.
     Allows you to create your own classes.
     Supports structures that enable you to create your own
      data type Data Adapter.
     Also has full support for interfaces.
 ©NIIT         Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 3 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Classes and Objects
Class
     Is a conceptual representation of all the entities that
      share common attributes and behaviors.
     Defines the attributes and behaviors of all the instances
      of the class.
Object
     Is an instance of a class.
     Has individual copy of the common attributes and share
      a common set of behaviors.



©NIIT         Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 4 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Advantages of Using Classes and Objects
 Maintenance of code by introducing modularity.
 Encapsulation of internal complexities in code from
  end-users.
 Reuse of code across applications.
 Support for a single interface to implement multiple
  methods.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 5 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Structure
 Is a generalization of a user-defined data type (UDT).
 Is created when you want a single variable to hold multiple
  types of related data.
 Is declared by using the Structure and End Structure
  statements.
 Can also include procedures as its members.
 Supports event handling.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 6 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Structure (Contd.)
 You can specify the accessibility of the data members within
  a structure by using one of the following access modifiers:
     Public
     Protected
     Friend
     Protected Friend
     Private




©NIIT           Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 7 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Structure (Contd.)
Storing and accessing data within/from a structure:
     Is done by using the .(dot) notation.
 Example
 Dim ord1 As order_details
 ord1.Inv_no = I0001“
 ord1.Ord_dt = #5/31/2001#
 If ord1.Inv_no =  Then
    MsgBox(Please enter the Invoice number)
 End If




©NIIT         Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 8 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Classes Vs. Structure
A few similarities between a class and a structure are:
     Both can have members, including constructors,
      properties, constants, and events.
     Both can implement interfaces.
     Both can have shared constructors, with or without
      parameters.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 9 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Classes Vs. Structure (Contd.)
A few dissimilarities between a class and a structure are
given in the following table:
                      Class                                       Structure


    A class is inheritable from other existing   A structure is not inheritable.
    classes.

    A class can have instance constructors       A structure can have instance
    with or without parameters.                  constructors only if they take parameters.

    A class is a reference type.                 A structure is a value type.



    The members of a class can be                The members of a structure cannot be
    initialized within the class declaration.    initialized within the structure declaration.




©NIIT             Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 10 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
 Abstract Class
Contains the skeleton of the methods that derived
 classes can implement.
  Example
  Public MustInherit Class EmployeeDetails
    Public MustOverride Sub Annual_Salary(ByVal m As
  Integer)
  End Class
  Public Class Emp_details
        Inherits EmployeeDetails
  Public Overrides Sub Annual_Salary(ByVal m As Integer)
           ' Write the implementation code here
        End Sub     End Class

©NIIT             Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 11 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Abstract Class (Contd.)
 You can create an abstract class by using the
  MustInherit keyword in the class definition.
 You can define a method in an abstract class using the
  MustOverride keyword.
 You must implement the method in derived classes using
  the Overrides keyword.
 If a derived class of an abstract class does not implement
  one of the abstract methods of the abstract base class, it
  also must be declared with MustInherit keyword as it
  also becomes an abstract class.



©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 12 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Interface
Can contain only the declaration of members such as
properties, methods, and events.
Enables you to separate the definition of objects from their
 implementation so that the objects can evolve without the
 risk of introducing incompatibility in existing applications.
Is declared by using the Interface and End Interface
 statements.
  Example
  Interface Iorderdetails
     Property CustName() As String
     Sub UpdateCustStatus()
     Event Update_Complete()
  End Interface

©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 13 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Interface (Contd.)
Statements are Public by default.
Can inherit members from an existing interface by using the
 Inherits statement.
  Example
  Interface Validate_Cust
      Sub Validate_Custname()
  End Interface
  Interface Iorderdetails Inherits
  Validate_Cust
      Property CustName() As String
      Sub UpdateCustStatus()
      Event Update_Complete()
  End Interface
©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 14 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Differences Between Interfaces and Abstract Classes
Interfaces represent the highest level of abstraction in
object-oriented programming because all the methods in an
       interface do not have any implementation.
In contrast, the abstract classes that are created by using
      the MustInherit keyword might contain a method
that  has a body.




 ©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 15 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Assemblies
 Consist of a single or multiple executable and resource files
  that contain information necessary for deploying and
  maintaining the versions of an application.
 Enable users to use an application even when the
  application is not registered in the System Registry, since:
     Every assembly is self-describing through metadata.
     Every reference to a type is scoped by an assembly
      reference.
     .NET can automatically locate referenced assemblies.




 ©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 16 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Assemblies (Contd.)
 The application hierarchy in Visual Basic .NET is illustrated
  in the following figure:




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 17 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Assemblies (Contd.)
 Consist of manifest, module, and type.
 Manifest is the descriptor of the assembly. It contains
  information on:
     The name and version number of the assembly.
     Its interaction with other assemblies.
     The types exposed by the assembly.
     Security permissions required by the assembly.




 ©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 18 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Assemblies (Contd.)
 Module is either a DLL or EXE. It contains:
     Compiled code in intermediate languages.
     Metadata associated with the module.
     Optionally, the manifest for the assembly.
 Type in Visual Basic .NET can be a class or a structure that
  contain data and logic affecting the data.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 19 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Just a Minute…
2. Why is a structure called a composite data type?
3. Identify the syntactical error in the following declaration of
   an interface:
  Interface Iproductdetails
        Property ProductName() As String
        Sub UpdateCustStatus()
        Label1.Text=“This is a Sub Procedure to check the status of
                        the product”
        End Sub
        Event Update_complete()
  End Interface

3. How are interfaces different from abstract classes?


©NIIT             Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 20 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Problem Statement 3.D.1
The call centers at Diaz Telecommunications need to maintain
customer information to respond to customer queries. The
details of the customers need to be accepted through a
graphical interface. The customer information also needs to be
stored in the relevant memory variables. The details of the
customers essentially include customer id, customer’s first
name, customer’s last name, address, telephone number, and
customer’s e-mail id.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 21 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task List
Identify the data that needs to be captured.
Identify the type of user interface to be used.
Identify the user interface components to accept data.
Identify the mechanism to store data in the relevant
 memory variables.
Identify the memory variables to store customer
 information.
Perform appropriate steps to create the user interface
 screen, as designed.
Add a class to the project.
Write the code to add the relevant members to a class.

©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 22 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task List (Contd.)
Write the code to instantiate the class.
Write the code to store and retrieve data from the class.
Save the application.
Run the application.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 23 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 1: Identify the data that needs to be captured.
Result:
As per the problem statement, the data that needs to be
captured is:
     Customer ID
     First Name
     Last Name
     Address
     Telephone number
     E-mail ID



©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 24 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 2: Identify the type of user interface to be used.
There are three types of user interfaces:
   Windows Forms
     Web Forms
     Console
Result:
Since the requirement stated in the problem statement is for
      a graphical user interface, you will use Windows Forms
as    the user interface.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 25 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 3: Identify the user interface components to
accept data.
Guidelines for designing a user interface:
     Identify the name and title of the form.
     Identify the controls required.
     Recommend suitable prefixes that you can use for
      various controls:
                  Object               Prefix               Example

          Form                  frm                     frmCustomerdetail
                                                        s
          Label                 lbl                     lblCustomerName

          TextBox               txt                     txtCustomerName

          Button                cmd                     cmdSave


©NIIT         Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 26 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 3: Identify the user interface components to
accept data. (Contd.)
Result:
Based on the guidelines, set the form name as
frmCustomerdetails and the text, which is the title of the
form, as Customer Details.
To make a user-friendly interface, add label controls to
display static text for the customer details: Customer ID,
First Name, Last Name, Address, Telephone number, and
Email ID. Next, add text box controls to accept information
       for each customer detail. In addition, add two buttons
to     save and retrieve the data stored for the customer.



©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 27 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 4: Identify the mechanism to store data in
relevant memory variables.
In Visual Basic .NET, you can store data in relevant
memory variables by implementing the object‑oriented
features. The object-oriented features enable you to create
       a class that has member variables to store data during
data processing.
Result:
Since the requirement stated in the problem statement is to
         store customer information in the relevant memory
variables, a class called Customer needs to be created
that will have member variables to store customer
information.


©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 28 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 5: Identify the memory variables to store
customer information.
Result:
Since the customer information is to be stored in the
member variables of the Customer class, you need to add
        variables to the Customer class. Each member
variable of     the Customer class should store a particular
type of         customer detail. You must ensure that the data
type of a       member variable matches the data type of the
customer        detail stored by the variables. Six member
variables need to       be declared in the Customer class.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 29 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 6: Perform appropriate steps to create the user
interface screen, as designed.
Task 7: Add a class to the project.
Namespace
     Is a naming scheme that helps you organize the classes
      available in an application so that they can be easily
      found.
     Enables you to avoid name collisions.
     Is created using the Namespace keyword.
     Every project in Visual Basic .NET has a root
      namespace, which is set in the Property page of the
      project.
     You can use namespaces explicitly through direct
      addressing or implicitly through the Imports statement.
©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 30 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 8: Write the code to add the relevant members
to a class.
Task 9: Write the code to instantiate the class.
Object Lifetime
     The life of an object begins when an instance of a class
      is created using the New keyword.
     The life of an object ends after it goes out of scope or is
      set to Nothing and is released by the .NET
      Framework.
Constructors
     Are of two types, shared constructors and instance
      constructors.

©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 31 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Shared Constructors
 Used to initialize the variables that are declared with the
  Shared keyword.
 Have an implicit Public access.
 Will not run more than once during a single execution of a
  program.
  Example
  Public Class class1
  Shared x As Integer
  Shared Sub New()
   x = 10
  End Sub
  End Class

©NIIT         Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 32 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Instance Constructors
 Used to initialize variables that are declared with Dim,
  Public, Private, Friend, Protected, and Protected
  Friend keywords.
 Allow access to shared variables.
  Example
  Public Class class1
  Dim x As Integer
  Public Sub New()
    x = 10
  End Sub
  End Class

©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 33 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Destructors
 Are special methods that are used to release an instance of
  a class from memory. There are two types of destructors in
  Visual Basic .NET:
     Finalize( )
     Dispose( )




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 34 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Finalize ( ) Destructor
 Is called from the class to which it belongs or from the
  derived classes.
 Is called after the last reference to an object is released
  from the memory.
 Is automatically invoked by the .NET Framework to destroy
  objects in the memory.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 35 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Dispose ( ) Destructor
 Is called to release a resource, such as a database
  connection, as soon as the object using such a resource is
  no longer in use.
 Is not called automatically, and you must explicitly call it
  from a client application.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 36 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 10: Write the code to store and retrieve data
from the class.
Task 11: Save the application.
Task 12: Run the application.




©NIIT      Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 37 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Problem Statement 3.D.2
The call centers at Diaz Telecommunications need data entry
forms to store information in the Customers, Orders, Query
Handling, Products, and Employees databases. Every data
entry form should have a similar user interface with the Reset
and Exit buttons. Incorporate the interface for the Order details
form.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 38 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task List
 Identify the mechanism to provide a similar user interface.
 Identify the user interface components to accept data.
 Identify the additional user interface controls.
 Create the user interface screen, as designed.
 Add code for the controls.
 Perform the prerequisite task to implement the planned
  mechanism.
 Implement the mechanism, as planned.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 39 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task List (Contd.)
Add the additional user interface control, as planned.
Perform the tasks to display a similar user interface.
Add code for the inherited controls.
Save the application.
Run the application.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 40 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 1: Identify the mechanism to provide a similar
user interface.
In Visual Basic .NET, you can create a base form in a
project and then create a form that inherits from the base
form.
Result:
Since the requirement stated in the problem statement is to
   create a similar user interface for all the data entry forms,
   you can create a base form that has the Reset and Exit
buttons on it. You can then inherit all the data entry forms
from the base form.




©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 41 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 2: Identify the user interface components to
accept data.
Result:
Since all the data entry forms must have the Reset and Exit
      buttons, you need to design the user interface of the
base form with these two buttons. You also need to specify
the   Text and Name properties of the form and the buttons
on    the form.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 42 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 3: Identify the additional user interface
controls.
Result:
Since the data entry forms for the Customers, Orders,
Query Handling, Products, and Employees databases must
       have various controls to accept data from a user, you
need to identify additional controls that need to be included
in the derived forms. In the current scenario, you will only
create a      base form with two buttons and inherit the form
       Order_details.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 43 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 4: Create the user interface screen, as
designed.
Task 5: Add code for the controls.
Task 6: Perform the prerequisite task to implement
the planned mechanism.
Task 7: Implement the mechanism, as planned.
Task 8: Add the additional user interface control, as
planned.




©NIIT      Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 44 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Task 9: Perform the tasks to display a similar user
interface.
Task 10: Add code for the inherited controls.
Task 11: Save the application.
Task 12: Run the application.




©NIIT      Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 45 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Problem Statement 3.P.1
The call centers of Diaz Telecommunications need to have
data entry forms to store information in the Customers,
Orders, Query Handling, Product, and Employees databases.
Every data entry form should have a similar user interface with
the Add, Modify, Delete, Reset and Exit buttons. Incorporate
the interface for the Query Handling data entry form.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 46 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Summary
In this lesson, you learned that:
 Visual Basic .NET is an object-oriented programming
  language.
 A structure is used to create user-defined data types.
 Data can be stored in and retrieved from a structure.
 Abstract classes are used to define the skeleton of the
  methods that the derived class can implement.
 Interfaces are inheritable in Visual Basic .NET.
 Classes can be added to a Visual Basic .NET project.



©NIIT        Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 47 of 48
Implementing Object-oriented Programming in
Visual Basic .NET
Summary (Contd.)
An assembly contains information necessary for deploying
 and maintaining the versions of an application.
An assembly consists of manifest, module, and type.
An important advantage of using a namespace is the
 prevention of a name collision.
Classes can be inherited in a Visual Basic .NET project.




©NIIT       Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 48 of 48

Mais conteúdo relacionado

Mais procurados

GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with javaRajiv Gupta
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1Shahzad
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsJason Townsend, MBA
 
Object-Oriented Application Frameworks
Object-Oriented Application FrameworksObject-Oriented Application Frameworks
Object-Oriented Application Frameworkskim.mens
 
Fragility in evolving software
Fragility in evolving softwareFragility in evolving software
Fragility in evolving softwarekim.mens
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design PatternSanae BEKKAR
 
11 ooad uml-14
11 ooad uml-1411 ooad uml-14
11 ooad uml-14Niit Care
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsRahul Malhotra
 
Software Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented ProgrammingSoftware Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented Programmingkim.mens
 
Prophecy Of Design Patterns
Prophecy Of Design PatternsProphecy Of Design Patterns
Prophecy Of Design Patternspradeepkothiyal
 
Gof design pattern
Gof design patternGof design pattern
Gof design patternnaveen kumar
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsMichael Heron
 
Crosscutting Specification Interference Detection at Aspect Oriented UML-Base...
Crosscutting Specification Interference Detection at Aspect Oriented UML-Base...Crosscutting Specification Interference Detection at Aspect Oriented UML-Base...
Crosscutting Specification Interference Detection at Aspect Oriented UML-Base...IJERA Editor
 

Mais procurados (20)

Topic 1 PBO
Topic 1 PBOTopic 1 PBO
Topic 1 PBO
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with java
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design Patterns
 
Object-Oriented Application Frameworks
Object-Oriented Application FrameworksObject-Oriented Application Frameworks
Object-Oriented Application Frameworks
 
Fragility in evolving software
Fragility in evolving softwareFragility in evolving software
Fragility in evolving software
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
11 ooad uml-14
11 ooad uml-1411 ooad uml-14
11 ooad uml-14
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
 
Software Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented ProgrammingSoftware Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented Programming
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Prophecy Of Design Patterns
Prophecy Of Design PatternsProphecy Of Design Patterns
Prophecy Of Design Patterns
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Crosscutting Specification Interference Detection at Aspect Oriented UML-Base...
Crosscutting Specification Interference Detection at Aspect Oriented UML-Base...Crosscutting Specification Interference Detection at Aspect Oriented UML-Base...
Crosscutting Specification Interference Detection at Aspect Oriented UML-Base...
 

Destaque

FIT 1000 Final Project
FIT 1000 Final ProjectFIT 1000 Final Project
FIT 1000 Final Projectatitaliana
 
Anroid development part.1
Anroid development part.1Anroid development part.1
Anroid development part.1RANK LIU
 
Learn VB.NET at ASIT
Learn VB.NET at ASITLearn VB.NET at ASIT
Learn VB.NET at ASITASIT
 
project on software industry
project on software industryproject on software industry
project on software industryAamir chouhan
 
Best Final Year Projects
Best Final Year ProjectsBest Final Year Projects
Best Final Year Projectsncct
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

Destaque (8)

FIT 1000 Final Project
FIT 1000 Final ProjectFIT 1000 Final Project
FIT 1000 Final Project
 
Anroid development part.1
Anroid development part.1Anroid development part.1
Anroid development part.1
 
Learn VB.NET at ASIT
Learn VB.NET at ASITLearn VB.NET at ASIT
Learn VB.NET at ASIT
 
project on software industry
project on software industryproject on software industry
project on software industry
 
Application project titles
Application project titlesApplication project titles
Application project titles
 
Introduction to VB.NET - UP SITF
Introduction to VB.NET - UP SITFIntroduction to VB.NET - UP SITF
Introduction to VB.NET - UP SITF
 
Best Final Year Projects
Best Final Year ProjectsBest Final Year Projects
Best Final Year Projects
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Semelhante a Vb net xp_03

Vb.net session 03
Vb.net session 03Vb.net session 03
Vb.net session 03Niit Care
 
Vb net xp_01
Vb net xp_01Vb net xp_01
Vb net xp_01Niit Care
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 
C#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentC#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentSVRTechnologies
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxdanhaley45372
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.netJaya Kumari
 
.Net framework
.Net framework.Net framework
.Net frameworkRaghu nath
 
Aspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETAspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETWaqas Tariq
 
Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net FundamentalsLiquidHub
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesDurgesh Singh
 
Vb net xp_13
Vb net xp_13Vb net xp_13
Vb net xp_13Niit Care
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Steven Smith
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Luis Valencia
 
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Steven Smith
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)stanbridge
 

Semelhante a Vb net xp_03 (20)

Vb.net session 03
Vb.net session 03Vb.net session 03
Vb.net session 03
 
Vb net xp_01
Vb net xp_01Vb net xp_01
Vb net xp_01
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
C#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentC#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course Content
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
.Net framework
.Net framework.Net framework
.Net framework
 
Aspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETAspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NET
 
Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net Fundamentals
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
C# Unit 1 notes
C# Unit 1 notesC# Unit 1 notes
C# Unit 1 notes
 
Vb net xp_13
Vb net xp_13Vb net xp_13
Vb net xp_13
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013
 
About .net
About .net About .net
About .net
 
Csharp
CsharpCsharp
Csharp
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 

Mais de Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Último

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Último (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

Vb net xp_03

  • 1. Implementing Object-oriented Programming in Visual Basic .NET Objectives In this lesson, you will learn to: Identify the advantages of using classes and objects Identify the use of structures Identify the use of abstract classes in Visual Basic .NET Identify the use of interfaces Identify the differences between interfaces and abstract classes Identify the use of assemblies Identify the application hierarchy in Visual Basic .NET Create and instantiate a class ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 1 of 48
  • 2. Implementing Object-oriented Programming in Visual Basic .NET Objectives (Contd.) Declare and import namespaces Create an inherited form in Visual Basic .NET ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 2 of 48
  • 3. Implementing Object-oriented Programming in Visual Basic .NET Object-orientation in Visual Basic .NET Visual Basic .NET: Supports the four pillars of object-oriented programming: ® Encapsulation ® Abstraction ® Inheritance ® Polymorphism Uses predefined classes provided by the .NET Framework. Allows you to create your own classes. Supports structures that enable you to create your own data type Data Adapter. Also has full support for interfaces. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 3 of 48
  • 4. Implementing Object-oriented Programming in Visual Basic .NET Classes and Objects Class Is a conceptual representation of all the entities that share common attributes and behaviors. Defines the attributes and behaviors of all the instances of the class. Object Is an instance of a class. Has individual copy of the common attributes and share a common set of behaviors. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 4 of 48
  • 5. Implementing Object-oriented Programming in Visual Basic .NET Advantages of Using Classes and Objects Maintenance of code by introducing modularity. Encapsulation of internal complexities in code from end-users. Reuse of code across applications. Support for a single interface to implement multiple methods. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 5 of 48
  • 6. Implementing Object-oriented Programming in Visual Basic .NET Structure Is a generalization of a user-defined data type (UDT). Is created when you want a single variable to hold multiple types of related data. Is declared by using the Structure and End Structure statements. Can also include procedures as its members. Supports event handling. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 6 of 48
  • 7. Implementing Object-oriented Programming in Visual Basic .NET Structure (Contd.) You can specify the accessibility of the data members within a structure by using one of the following access modifiers: Public Protected Friend Protected Friend Private ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 7 of 48
  • 8. Implementing Object-oriented Programming in Visual Basic .NET Structure (Contd.) Storing and accessing data within/from a structure: Is done by using the .(dot) notation. Example Dim ord1 As order_details ord1.Inv_no = I0001“ ord1.Ord_dt = #5/31/2001# If ord1.Inv_no = Then MsgBox(Please enter the Invoice number) End If ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 8 of 48
  • 9. Implementing Object-oriented Programming in Visual Basic .NET Classes Vs. Structure A few similarities between a class and a structure are: Both can have members, including constructors, properties, constants, and events. Both can implement interfaces. Both can have shared constructors, with or without parameters. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 9 of 48
  • 10. Implementing Object-oriented Programming in Visual Basic .NET Classes Vs. Structure (Contd.) A few dissimilarities between a class and a structure are given in the following table: Class Structure A class is inheritable from other existing A structure is not inheritable. classes. A class can have instance constructors A structure can have instance with or without parameters. constructors only if they take parameters. A class is a reference type. A structure is a value type. The members of a class can be The members of a structure cannot be initialized within the class declaration. initialized within the structure declaration. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 10 of 48
  • 11. Implementing Object-oriented Programming in Visual Basic .NET Abstract Class Contains the skeleton of the methods that derived classes can implement. Example Public MustInherit Class EmployeeDetails Public MustOverride Sub Annual_Salary(ByVal m As Integer) End Class Public Class Emp_details Inherits EmployeeDetails Public Overrides Sub Annual_Salary(ByVal m As Integer) ' Write the implementation code here End Sub End Class ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 11 of 48
  • 12. Implementing Object-oriented Programming in Visual Basic .NET Abstract Class (Contd.) You can create an abstract class by using the MustInherit keyword in the class definition. You can define a method in an abstract class using the MustOverride keyword. You must implement the method in derived classes using the Overrides keyword. If a derived class of an abstract class does not implement one of the abstract methods of the abstract base class, it also must be declared with MustInherit keyword as it also becomes an abstract class. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 12 of 48
  • 13. Implementing Object-oriented Programming in Visual Basic .NET Interface Can contain only the declaration of members such as properties, methods, and events. Enables you to separate the definition of objects from their implementation so that the objects can evolve without the risk of introducing incompatibility in existing applications. Is declared by using the Interface and End Interface statements. Example Interface Iorderdetails Property CustName() As String Sub UpdateCustStatus() Event Update_Complete() End Interface ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 13 of 48
  • 14. Implementing Object-oriented Programming in Visual Basic .NET Interface (Contd.) Statements are Public by default. Can inherit members from an existing interface by using the Inherits statement. Example Interface Validate_Cust Sub Validate_Custname() End Interface Interface Iorderdetails Inherits Validate_Cust Property CustName() As String Sub UpdateCustStatus() Event Update_Complete() End Interface ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 14 of 48
  • 15. Implementing Object-oriented Programming in Visual Basic .NET Differences Between Interfaces and Abstract Classes Interfaces represent the highest level of abstraction in object-oriented programming because all the methods in an interface do not have any implementation. In contrast, the abstract classes that are created by using the MustInherit keyword might contain a method that has a body. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 15 of 48
  • 16. Implementing Object-oriented Programming in Visual Basic .NET Assemblies Consist of a single or multiple executable and resource files that contain information necessary for deploying and maintaining the versions of an application. Enable users to use an application even when the application is not registered in the System Registry, since: Every assembly is self-describing through metadata. Every reference to a type is scoped by an assembly reference. .NET can automatically locate referenced assemblies. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 16 of 48
  • 17. Implementing Object-oriented Programming in Visual Basic .NET Assemblies (Contd.) The application hierarchy in Visual Basic .NET is illustrated in the following figure: ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 17 of 48
  • 18. Implementing Object-oriented Programming in Visual Basic .NET Assemblies (Contd.) Consist of manifest, module, and type. Manifest is the descriptor of the assembly. It contains information on: The name and version number of the assembly. Its interaction with other assemblies. The types exposed by the assembly. Security permissions required by the assembly. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 18 of 48
  • 19. Implementing Object-oriented Programming in Visual Basic .NET Assemblies (Contd.) Module is either a DLL or EXE. It contains: Compiled code in intermediate languages. Metadata associated with the module. Optionally, the manifest for the assembly. Type in Visual Basic .NET can be a class or a structure that contain data and logic affecting the data. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 19 of 48
  • 20. Implementing Object-oriented Programming in Visual Basic .NET Just a Minute… 2. Why is a structure called a composite data type? 3. Identify the syntactical error in the following declaration of an interface: Interface Iproductdetails Property ProductName() As String Sub UpdateCustStatus() Label1.Text=“This is a Sub Procedure to check the status of the product” End Sub Event Update_complete() End Interface 3. How are interfaces different from abstract classes? ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 20 of 48
  • 21. Implementing Object-oriented Programming in Visual Basic .NET Problem Statement 3.D.1 The call centers at Diaz Telecommunications need to maintain customer information to respond to customer queries. The details of the customers need to be accepted through a graphical interface. The customer information also needs to be stored in the relevant memory variables. The details of the customers essentially include customer id, customer’s first name, customer’s last name, address, telephone number, and customer’s e-mail id. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 21 of 48
  • 22. Implementing Object-oriented Programming in Visual Basic .NET Task List Identify the data that needs to be captured. Identify the type of user interface to be used. Identify the user interface components to accept data. Identify the mechanism to store data in the relevant memory variables. Identify the memory variables to store customer information. Perform appropriate steps to create the user interface screen, as designed. Add a class to the project. Write the code to add the relevant members to a class. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 22 of 48
  • 23. Implementing Object-oriented Programming in Visual Basic .NET Task List (Contd.) Write the code to instantiate the class. Write the code to store and retrieve data from the class. Save the application. Run the application. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 23 of 48
  • 24. Implementing Object-oriented Programming in Visual Basic .NET Task 1: Identify the data that needs to be captured. Result: As per the problem statement, the data that needs to be captured is: Customer ID First Name Last Name Address Telephone number E-mail ID ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 24 of 48
  • 25. Implementing Object-oriented Programming in Visual Basic .NET Task 2: Identify the type of user interface to be used. There are three types of user interfaces: Windows Forms Web Forms Console Result: Since the requirement stated in the problem statement is for a graphical user interface, you will use Windows Forms as the user interface. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 25 of 48
  • 26. Implementing Object-oriented Programming in Visual Basic .NET Task 3: Identify the user interface components to accept data. Guidelines for designing a user interface: Identify the name and title of the form. Identify the controls required. Recommend suitable prefixes that you can use for various controls: Object Prefix Example Form frm frmCustomerdetail s Label lbl lblCustomerName TextBox txt txtCustomerName Button cmd cmdSave ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 26 of 48
  • 27. Implementing Object-oriented Programming in Visual Basic .NET Task 3: Identify the user interface components to accept data. (Contd.) Result: Based on the guidelines, set the form name as frmCustomerdetails and the text, which is the title of the form, as Customer Details. To make a user-friendly interface, add label controls to display static text for the customer details: Customer ID, First Name, Last Name, Address, Telephone number, and Email ID. Next, add text box controls to accept information for each customer detail. In addition, add two buttons to save and retrieve the data stored for the customer. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 27 of 48
  • 28. Implementing Object-oriented Programming in Visual Basic .NET Task 4: Identify the mechanism to store data in relevant memory variables. In Visual Basic .NET, you can store data in relevant memory variables by implementing the object‑oriented features. The object-oriented features enable you to create a class that has member variables to store data during data processing. Result: Since the requirement stated in the problem statement is to store customer information in the relevant memory variables, a class called Customer needs to be created that will have member variables to store customer information. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 28 of 48
  • 29. Implementing Object-oriented Programming in Visual Basic .NET Task 5: Identify the memory variables to store customer information. Result: Since the customer information is to be stored in the member variables of the Customer class, you need to add variables to the Customer class. Each member variable of the Customer class should store a particular type of customer detail. You must ensure that the data type of a member variable matches the data type of the customer detail stored by the variables. Six member variables need to be declared in the Customer class. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 29 of 48
  • 30. Implementing Object-oriented Programming in Visual Basic .NET Task 6: Perform appropriate steps to create the user interface screen, as designed. Task 7: Add a class to the project. Namespace Is a naming scheme that helps you organize the classes available in an application so that they can be easily found. Enables you to avoid name collisions. Is created using the Namespace keyword. Every project in Visual Basic .NET has a root namespace, which is set in the Property page of the project. You can use namespaces explicitly through direct addressing or implicitly through the Imports statement. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 30 of 48
  • 31. Implementing Object-oriented Programming in Visual Basic .NET Task 8: Write the code to add the relevant members to a class. Task 9: Write the code to instantiate the class. Object Lifetime The life of an object begins when an instance of a class is created using the New keyword. The life of an object ends after it goes out of scope or is set to Nothing and is released by the .NET Framework. Constructors Are of two types, shared constructors and instance constructors. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 31 of 48
  • 32. Implementing Object-oriented Programming in Visual Basic .NET Shared Constructors Used to initialize the variables that are declared with the Shared keyword. Have an implicit Public access. Will not run more than once during a single execution of a program. Example Public Class class1 Shared x As Integer Shared Sub New() x = 10 End Sub End Class ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 32 of 48
  • 33. Implementing Object-oriented Programming in Visual Basic .NET Instance Constructors Used to initialize variables that are declared with Dim, Public, Private, Friend, Protected, and Protected Friend keywords. Allow access to shared variables. Example Public Class class1 Dim x As Integer Public Sub New() x = 10 End Sub End Class ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 33 of 48
  • 34. Implementing Object-oriented Programming in Visual Basic .NET Destructors Are special methods that are used to release an instance of a class from memory. There are two types of destructors in Visual Basic .NET: Finalize( ) Dispose( ) ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 34 of 48
  • 35. Implementing Object-oriented Programming in Visual Basic .NET Finalize ( ) Destructor Is called from the class to which it belongs or from the derived classes. Is called after the last reference to an object is released from the memory. Is automatically invoked by the .NET Framework to destroy objects in the memory. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 35 of 48
  • 36. Implementing Object-oriented Programming in Visual Basic .NET Dispose ( ) Destructor Is called to release a resource, such as a database connection, as soon as the object using such a resource is no longer in use. Is not called automatically, and you must explicitly call it from a client application. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 36 of 48
  • 37. Implementing Object-oriented Programming in Visual Basic .NET Task 10: Write the code to store and retrieve data from the class. Task 11: Save the application. Task 12: Run the application. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 37 of 48
  • 38. Implementing Object-oriented Programming in Visual Basic .NET Problem Statement 3.D.2 The call centers at Diaz Telecommunications need data entry forms to store information in the Customers, Orders, Query Handling, Products, and Employees databases. Every data entry form should have a similar user interface with the Reset and Exit buttons. Incorporate the interface for the Order details form. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 38 of 48
  • 39. Implementing Object-oriented Programming in Visual Basic .NET Task List Identify the mechanism to provide a similar user interface. Identify the user interface components to accept data. Identify the additional user interface controls. Create the user interface screen, as designed. Add code for the controls. Perform the prerequisite task to implement the planned mechanism. Implement the mechanism, as planned. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 39 of 48
  • 40. Implementing Object-oriented Programming in Visual Basic .NET Task List (Contd.) Add the additional user interface control, as planned. Perform the tasks to display a similar user interface. Add code for the inherited controls. Save the application. Run the application. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 40 of 48
  • 41. Implementing Object-oriented Programming in Visual Basic .NET Task 1: Identify the mechanism to provide a similar user interface. In Visual Basic .NET, you can create a base form in a project and then create a form that inherits from the base form. Result: Since the requirement stated in the problem statement is to create a similar user interface for all the data entry forms, you can create a base form that has the Reset and Exit buttons on it. You can then inherit all the data entry forms from the base form. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 41 of 48
  • 42. Implementing Object-oriented Programming in Visual Basic .NET Task 2: Identify the user interface components to accept data. Result: Since all the data entry forms must have the Reset and Exit buttons, you need to design the user interface of the base form with these two buttons. You also need to specify the Text and Name properties of the form and the buttons on the form. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 42 of 48
  • 43. Implementing Object-oriented Programming in Visual Basic .NET Task 3: Identify the additional user interface controls. Result: Since the data entry forms for the Customers, Orders, Query Handling, Products, and Employees databases must have various controls to accept data from a user, you need to identify additional controls that need to be included in the derived forms. In the current scenario, you will only create a base form with two buttons and inherit the form Order_details. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 43 of 48
  • 44. Implementing Object-oriented Programming in Visual Basic .NET Task 4: Create the user interface screen, as designed. Task 5: Add code for the controls. Task 6: Perform the prerequisite task to implement the planned mechanism. Task 7: Implement the mechanism, as planned. Task 8: Add the additional user interface control, as planned. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 44 of 48
  • 45. Implementing Object-oriented Programming in Visual Basic .NET Task 9: Perform the tasks to display a similar user interface. Task 10: Add code for the inherited controls. Task 11: Save the application. Task 12: Run the application. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 45 of 48
  • 46. Implementing Object-oriented Programming in Visual Basic .NET Problem Statement 3.P.1 The call centers of Diaz Telecommunications need to have data entry forms to store information in the Customers, Orders, Query Handling, Product, and Employees databases. Every data entry form should have a similar user interface with the Add, Modify, Delete, Reset and Exit buttons. Incorporate the interface for the Query Handling data entry form. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 46 of 48
  • 47. Implementing Object-oriented Programming in Visual Basic .NET Summary In this lesson, you learned that: Visual Basic .NET is an object-oriented programming language. A structure is used to create user-defined data types. Data can be stored in and retrieved from a structure. Abstract classes are used to define the skeleton of the methods that the derived class can implement. Interfaces are inheritable in Visual Basic .NET. Classes can be added to a Visual Basic .NET project. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 47 of 48
  • 48. Implementing Object-oriented Programming in Visual Basic .NET Summary (Contd.) An assembly contains information necessary for deploying and maintaining the versions of an application. An assembly consists of manifest, module, and type. An important advantage of using a namespace is the prevention of a name collision. Classes can be inherited in a Visual Basic .NET project. ©NIIT Implementing Object-oriented Programming in VB .NET/Lesson 3/Slide 48 of 48