Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 :)Advanced:) Visual Basic laura leventhal and julie barnes.

Similar presentations


Presentation on theme: "1 :)Advanced:) Visual Basic laura leventhal and julie barnes."— Presentation transcript:

1 1 :)Advanced:) Visual Basic laura leventhal and julie barnes

2 2 Main Points VB classes and OOP Timer object

3 3 Why Think About OO with Event-Driven Programming Recall that the idea of event driven programming is that the program is ready and waiting to respond to an “event” The event will happen in real-time. –Examples are real-time controllers –User interface events So what do event responses have to do with OO?

4 4 Event Driven and OO OO software engineering is a way of thinking about projects that promotes good design principles, like encapsulation of function and code reuse. Encapsulation and reuse are useful in all programming situations including event driven.

5 5 OO and UI programming User interfaces are particularly appropriate to OO notions because we can visualize a user interface as a collection of communicating objects.

6 6 VB, OO and UI Visual Basic was not designed as an OO language, but does support OO notions. –Inheritance, polymorphism and encapsulation. –Note that C did not initially support OO either.

7 7 Using OO in VB for UI From a UI developer perspective, we use OO in the following ways –Whenever we use VB controls, we are relying on an OO way of thinking. The individual buttons and so on that you use inherit properties and methods from a generic button definition. –You can also use OO to retain state information about your control objects. In this way you can encapsulate and isolate this state information. Also, by using classes, you do not have to rewrite code when a particular interface control is used more than once. –VB classes can be used to support conventional, non-UI programming as well.

8 8 VB Classes Remember OOP from CS 215? VB also supports OOP VB class modules contain: –Data (called properties in VB0 –Commands for manipulating the data (called methods in VB) –File extension.cls

9 9 Typical Class Module Consists of –Variable Declarations –Property Declarations –Methods: Event-driven vs. linear

10 1010 Demos? VB classes timers

11 1


Download ppt "1 :)Advanced:) Visual Basic laura leventhal and julie barnes."

Similar presentations


Ads by Google