Micro Focus QTP (UFT) Forums
Use of Class Concept in QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Use of Class Concept in QTP (/Thread-Use-of-Class-Concept-in-QTP)



Use of Class Concept in QTP - sshukla12 - 12-22-2011

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


RE: Use of Class Concept in QTP - ravi.gajul - 12-22-2011

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



RE: Use of Class Concept in QTP - sshukla12 - 12-22-2011

Hi Ravi,
Thnks for the reply. But could you please elaborate the importance and usage with respect to QTP.

Regards,
Sankalp


RE: Use of Class Concept in QTP - sshukla12 - 12-22-2011

Hi Ankur/Saket,

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

Regards,
Sankalp


RE: Use of Class Concept in QTP - ravi.gajul - 12-22-2011

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.


RE: Use of Class Concept in QTP - A.Saini - 12-22-2011

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.




RE: Use of Class Concept in QTP - sshukla12 - 12-23-2011

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