Micro Focus QTP (UFT) Forums

Full Version: Use of Class Concept in QTP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I want to implement the class concept in my framework/Script. Anyone of you have any idea how to use it and what is the importance of using this concept in scripting language like VB.

Regards,
Sankalp
It is similar to the usage as in Java.
Define methods in a class and then call the methods using the objects created for that class.
Example
Code:
set classObj=new ExampleClass
classObj.fnExample
Class ExampleClass
Function  fnExample()
       msgbox "This is fn in class"
End Function
End Class
Hi Ravi,
Thnks for the reply. But could you please elaborate the importance and usage with respect to QTP.

Regards,
Sankalp
Hi Ankur/Saket,

Could you please help me over this as this is bit urgent and quite important/interesting for me.

Regards,
Sankalp
It is basically used for achieving
1.Encapsulation(or information hiding)
2.Inheritance
3.Polymorphism

Encapsulation
--The encapsulation is the inclusion within a program object of all the resources need for the object to function - basically, the methods and the data. In OOP the encapsulation is mainly achieved by creating classes, the classes expose public methods and properties. The class is kind of a container or capsule or a cell, which encapsulate the set of methods, attribute and properties to provide its indented functionalities to other classes.

Inheritance
--Ability of a new class to be created, from an existing class by extending it, is called inheritance.

Polymorphism
--Polymorphisms is a generic term that means 'many forms'. More precisely Polymorphisms means the ability of a same function exibhiting different forms based on context.The function only differes in the arguments and has the same name in all the classes where it is used.
Hi,

The concept of Class comes under Object Oriented Programming. OOPS contains some very good features like
  • Object
  • Class
  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism


It is very useful for developers to write a smart code. A code which is short, secure, reusable and much more manageable.

We can apply the same things for QTP as well.

Hi,
Thnks for the reply. I think we can use encapsulation is QTP but inheritance and Polymorphism is not supported by QTP.
But the thing I am looking for is some real kind of example using OOPs concept in QTP which can enhance the modularity and resuability of my scripts.

Regards,
Sankalp