.NET
  Home arrow .NET arrow Page 5 - The Delphi Language, Part 2
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

The Delphi Language, Part 2
By: Xavier Pacheco
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 15
    2004-07-13

    Table of Contents:
  • The Delphi Language, Part 2
  • Out Parameters, Constant Parameters, and Open Array Parameters
  • Scope and Units and Namespaces
  • The uses Clause and Circular Unit References
  • Object-Oriented Programming
  • Using Delphi Objects
  • Methods
  • Class References and Properties
  • Events
  • Visibility Specifiers, Friend Classes and Class Helpers
  • Nested Types, Operator Overloading and Attributes
  • Interfaces
  • Using Interfaces, SEH
  • Exception Classes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The Delphi Language, Part 2 - Object-Oriented Programming


    (Page 5 of 14 )

    Volumes have been written on the subject of object-oriented programming (OOP). Often, OOP seems more like a religion than a programming methodology, spawning arguments about its merits (or lack thereof) that are passionate and spirited enough to make the Crusades look like a slight disagreement. We're not orthodox OOPists, and we're not going to get involved in the relative merits of OOP; we just want to give you the lowdown on a fundamental principle on which Delphi's language is based.

    OOP is a programming paradigm that uses discrete objects—containing both data and code—as application building blocks. Although the OOP paradigm doesn't necessarily lend itself to easier-to-write code, the result of using OOP traditionally has been easy-to-maintain code. Having objects' data and code together simplifies the process of hunting down bugs, fixing them with minimal effect on other objects, and improving your program one part at a time. Traditionally, an OOP language contains implementations of at least three OOP concepts:

    • Encapsulation—Deals with combining related data fields and hiding the implementation details. The advantages of encapsulation include modularity and isolation of code from other code.

    • Inheritance—The capability to create new objects that maintain the properties and behavior of ancestor objects. This concept enables you to create object hierarchies such as VCL—first creating generic objects and then creating more specific descendants of those objects that have more narrow functionality.

      The advantage of inheritance is the sharing of common code. Figure 5.1 presents an example of inheritance—how one root object, fruit, is the ancestor object of all fruits, including the melon. The melon is ancestor of all melons, including the watermelon. You get the picture.


    Figure 5.1
    An illustration of inheritance.

    • Polymorphism—Literally, polymorphism means "many shapes." Calls to virtual methods of an object variable will call code appropriate to whatever instance is actually in the variable at runtime.

    Note that the .NET CLR does not support the concept of C++-style multiple inheritance, and neither does the Delphi language.

    You should understand the following three terms before you continue to explore the concept of objects:

    • Field—Also called field definitions or instance variables, fields are data variables contained within objects. A field in an object is just like a field in a Delphi record. In C#, fields sometimes are referred to as data members.

    • Method—The name for procedures and functions belonging to an object. Methods are called member functions in C#.

    • Property—An entity that acts as an accessor to the data and code contained within an object. Properties work similar to fields with attached logic to insulate the end user from the implementation details of an object.


    Note - It's generally considered bad OOP style to access an object's fields directly because the implementation details of the object might change. Instead, use accessor properties, which allow a standard object interface without becoming embroiled in the details of how the objects are implemented. Properties are explained in the "Properties" section later in this chapter.


    This chapter is from Delphi for .NET Developer's Guide, by Xavier Pacheco (Sams, 2004, ISBN: 0-672-32443-1). Check it out at your favorite bookstore today.

    Buy this book now.

    More .NET Articles
    More By Xavier Pacheco


     

    .NET ARTICLES

    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC
    - The Windows Ribbon Framework
    - Markup Language for the Ribbon Framework
    - Visually Upgrade Your MFC Project
    - New Features for the Statusbar in MFC
    - Working with the Statusbar in MFC
    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek