구글와이드(336x280)_상단 2개


(영문)Introduction to Object-Oriented Programming ASP, ASP.NET

Introduction to Object-Oriented Programming

Introduction

An object is a structure containing data and methods that manipulate the data. If you are new to object-oriented programming, the following terms and concepts will help you get started. While you don't have to master object-oriented programming to be a successful Visual Basic developer it is helpful because almost everything you do in Visual Basic is associated with objects.

Classes and Objects

The words "class" and "object" are used so much in object-oriented programming that it is easy to get the terms mixed up.
Generally speaking, a class is an abstract representation of something, whereas an object is a usable example of the thing the class represents. The one exception to this rule is shared class members, which are usable in both instances of a class and object variables declared as the type of the class.

Fields, Properties, Methods, and Events

Classes are made of fields, properties, methods, and events. Fields and properties represent information that an object contains. Fields are like variables in that they can be read or set directly. For example, if you have an object named "Car" you could store its color in a field named "Color."
Properties are retrieved and set like fields, but are implemented using property Get and property Set procedures, which provide more control on how values are set or returned. The layer of indirection between the value being stored and the procedures that use this value helps isolate your data and allows you to validate values before they are assigned or retrieved.
Methods represent actions that an object can perform. For example, a "Car" object could have "StartEngine," "Drive," and "Stop" methods. You define methods by adding procedures, either Sub routines or functions, to your class.
Events are notifications an object receives from, or transmits to, other objects or applications. Events allow objects to perform actions whenever a specific occurrence takes place. An example of an event for the "Car" class would be a "Check_Engine" event. Because Microsoft Windows is an event-driven operating system, events can come from other objects, applications, or user input such as mouse clicks or key presses.

Encapsulation, Inheritance, and Polymorphism

Fields, properties, methods, and events are only one half of the object-oriented programming equation. True object-orient programming requires objects to support three qualities: encapsulation, inheritance, and polymorphism.
Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object. Objects can control how properties are changed and methods are executed. For example, an object can validate values before allowing property changes. Encapsulation also makes it easier to change your implementation at a latter date by letting you hide implementation details of your objects, a practice called data hiding.
Inheritance describes the ability to create new classes based on an existing class. The new class inherits all the properties and methods and events of the base class, and can be customized with additional properties and methods. For example, you can create a new class named "Truck" based on the "Car" class. The "Truck" class inherits the "Color" property from the "Car" class and can have additional properties such as "FourWheelDrive."
Polymorphism means that you can have multiple classes that can be used interchangeably, even though each class implements the same properties or methods in different ways. Polymorphism is essential to object-oriented programming because it allows you to use items with the same names, no matter what type of object is in use at the moment. For example, given a base class of "Car," polymorphism enables the programmer to define different "StartEngine" methods for any number of derived classes. The "StartEngine" method of a derived class named "DieselCar" may be completely different from the method with the same name in the base class. Other procedures or methods can use the "StartEngine" method of the derived classes in exactly the same way, no matter what type of "Car" object is being used at the time.

Overloading, Overriding, and Shadowing

Overloading, overriding, andshadowing are similar concepts that can be easy to confuse. Although all three techniques allow you to create members with the same name, there are some important differences.
Overloaded members are used to provide different versions of a property or method that have the same name, but that accept different number of parameters, or parameters with different data types.
Overridden properties and methods are used to replace an inherited property or method that is not appropriate in a derived class. Overridden members must accept the same data type and number of arguments. Derived classes inherit overridden members.
Shadowed members are used to locally replace a member that has broader scope. Any type can shadow any other type. For example, you can declare a property that shadows an inherited method with the same name. Shadowed members cannot be inherited.
===============================================================
Visual Basic Language Concepts
Creating and Using Objects
Objects are combinations of code and data that can be treated as single units. Nearly everything you do in Visual Basic involves objects, from the controls you use to the forms on which you place them. This section discusses where objects originate and how to use them.

In This Section

Objects from Visual Basic and Other Sources
Discusses how to use objects from Microsoft Word, Microsoft Excel, and other applications.
How to: Set and Retrieve Properties
Discusses how to change and obtain property values.
How to: Perform Actions with Methods
Describes what methods are and how to use them.
How to: Treat Forms as Objects
Shows how to use forms in the same way as ordinary objects.
How to: Access a Form
Demonstrates how to access the members of a form without having to create a variable.
How to: Use the New Keyword
Shows how to create instances of forms, classes defined in class modules, and collections.
Resource Management
Discusses how to save memory and system resources by releasing references to objects.
How to: Pass Objects to Procedures
Describes how to pass objects as arguments to procedures.
Walkthrough: Persisting an Object in Visual Basic
Demonstrates how serialization can be used to persist an object's data between instances, allowing you to store values and retrieve them the next time the object is instantiated.
How to: Inherit from a Class in Visual Basic
Shows how to define a base class and declare classes that extend the base class.

Related Sections

Objects in Visual Basic
Covers object-oriented programming fundamentals.
Managing Groups of Objects
Lists techniques for working with arrays and collections of objects.
How to: Perform Multiple Actions on an Object
Covers using the With...End With statement to simplify property access.

null



바보들의 영문법 카페(클릭!!)

오늘의 메모....

시사평론-정론직필 다음 카페
http://cafe.daum.net/sisa-1

바보들의 영문법 다음 카페
http://cafe.daum.net/babo-edu/

티스토리 내 블로그
http://earthly.tistory.com/

내 블로그에 있는 모든 글들과 자료에 대한 펌과 링크는 무제한 허용됩니다.
(단, 내 블로그에 덧글쓰기가 차단된 자들에게는 펌, 트랙백, 핑백 등이 일체 허용되지 않음.)

그리고 내 블로그 최근글 목록을 제목별로 보시려면....
바로 아래에 있는 이전글 목록의 최근달을 클릭하시면 됩니다.
그러면 제목을 보고 편하게 글을 골라 보실 수 있습니다.

그리고 내 블로그내 글을 검색하시려면 아래 검색버튼을 이용하시면 됩니다.


가가챗창

flag_Visitors

free counters