Visual FoxPro’s implementation object-oriented programming (OOP) is one of the best OOP implementations available.
The graphical user interface (GUI) that most of us enjoy today makes using a computer easier. However, the GUI makes application development much more complex. The GUI is largely responsible for the growth of OOP.
Look at any Miscrosoft Windows screen and you see lots of objects — containers, buttons, text boxes, etc. And, as you work with a Windows screen, the objects are continually changing. Imagine trying to write a procedural program to generate a typical Windows screen.
As we all know, the best way to perform a complex task is to break it into little pieces and complete each piece one at a time. So it is with programming a GUI. If you can focus on the development of each object on a Windows screen one at a time, the development of the whole screen becomes more manageable.
With the implementation of OOP in Visual FoxPro, we have tools (the Class Designer and the Form Designer) that let us create individual graphical objects, and then assemble them into a complete GUI. This is a very “visual” benefit to application developers.
Note to Purists: Yes, we know that OOP is used for more than the creation of a GUI and that the GUI isn’t the only reason for the emergence of OOP. However, most new advances in technology are accepted not because of the theoretical benefits, but instead because of benefits that are rather mundane. For example, television didn’t become popular because it could bring the classrooms of the great universities into our homes. TV became popular because of “I Love Lucy”.
The Heart of OOP
We think that there is one underlying idea that is the heart, or foundation, of object-oriented programming. The better you understand this fundamental OOP idea, the better you will understand OOP and make it serve you. Here’s the idea:
Fundamental OOP Idea: Instead of creating objects in an application directly, one creates blueprints for the objects and then creates the objects from the blueprints when needed.
In OOP terminology, the blueprints are called “classes”. Classes are the heart of OOP. Classes define the objects that can be instantiated in an OOP-based application. The idea of a class, or blueprint, makes possible the so-called qualities of OOP: abstraction, encapsulation, inheritance, polymorphism, specialization, object communications and reuse.
It might be more appropriate to refer to OOP as COP — class-oriented programming. The idea of a blueprint, or class, is what OOP is all about. Think about it. It will make sense to you as you work more with OOP and classes.
The Visual FoxPro OOP Implementation
Although Visual FoxPro is one of the best implementations of OOP around, it’s not a complete implementation. There is a lot of Visual FoxPro that’s not OOP’d.
How can you tell what’s OOP’d and what’s not? It’s easy! Anything in Visual FoxPro that doesn’t have a class defining it isn’t OOP’d. That includes menus, reports and data.
Visual FoxPro only provides native OOP mechanisms that support:
· Visual Classes: The visual classes supported include classes for forms and form-related objects. The Form Designer is the only object-creation tool in VFP that supports the building blocks of OOP: methods and properties.
· Non-Visual Classes: Non-visual classes are blueprints for programs. The methods in a non-visual class can be thought of as subroutines or functions. The properties can be thought of as memory variables.