Chapter12 Slides - Chapter 12: Objects and Classes MIS 304:...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style Opportunity Chapter 12: Objects and Classes MIS 304: Introduction to Problem Solving and Programming
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
You will learn how to… Define objects create controls from scratch Expose classes as needed to improve functionality Create and use class methods Create ReadOnly and WriteOnly properties in classes
Background image of page 2
Built-in Objects Object - a programming element that contains data (properties) and methods Controls in the Toolbox are reusable objects that are used for specialized tasks Classes are code that define an abstract class Developers create and define classes to complete a specific task Objects often represent real-world
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Why Use Classes? Classes are cumbersome at the start Classes make code reusable and make it easier to use Classes limit what can be see and used and who can see it and use it Classes are building blocks to bigger and better programs
Background image of page 4
Three-Tier Model Most popular implementation AKA Model-View-Controller
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Creating Classes of Your Own A developer decides what a class contains, how it works and where it’s used Developer defines the properties and methods for a class
Background image of page 6
Creating Classes of Your Own Create a class by adding a class file to a project Use Add Class. .. from the Project menu Select Class icon and name the file .vb is the extension and the name should describe the file File is created and added to the Solution Explorer Double-click to open it in the Code Window
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Add New Class Dialog
Background image of page 8
Anatomy of a Class Public Class AccountBalance 'Property Declarations 'Get/Set statements 'Methods End Class
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Creating Properties Step 1: Create a PRIVATE variable with the appropriate data type Step 2: Create a Property block with Get and Set functions Get - function of a class that allows a value to be retrieved (read) Set - function of a class that allows a value to be set (written)
Background image of page 10
Property Syntax Write this on your cheat sheet! Private decBalance as Decimal Public Property Balance() As Decimal Get Return decBalance End Get Set(ByVal value As Decimal) decBalance = value End Set End Property
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Creating Methods Methods are just subs and functions in a class Methods execute code and calculate and return values Syntax for methods is the same as for subs and functions Programming in Visual
Background image of page 12
Sample Method Accepts a value passed to it – decAmount Adds that value to decBalance Stores the result in decBalance Changes the Balance property Programming in Visual Public Sub CalcBalance(ByVal decAmount As Decimal) decBalance = decBalance + decAmount End Sub
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/29/2010 for the course MIS 304 taught by Professor Mote during the Fall '08 term at University of Texas at Austin.

Page1 / 43

Chapter12 Slides - Chapter 12: Objects and Classes MIS 304:...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online