I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE
   ► KBProgrammingDelphi for W...OOP   Print This     

Delphi KB: OOP Topic



24 Articles Found in the OOP Topic 

  KB Article    

Mike Prestwood
1. A 10 Minute Your First Delphi Class Quick Start

Beginners example of creating and using a class. Early versions of Delphi use the standard OO private, protected, and public visibility specifiers plus add published for RTTI info. Later versions of Delphi add strict private and strict protected for a true OO implementation.

10 years ago
(2 Comments , last by laquqob.m )

Article
Nothing New Since Your Last Visit  
18600
Hits

Pascal and Delphi Coding

Mike Prestwood
2. Delphi Abstraction (abstract, override)

Delphi for Win32 supports abstract class members using the abstract keyword. You can even instantiate instances of a class that contains abstract members. Then you override each abstract member in a descendant class with Override. Delphi does not support setting an entire class as abstract. You can create an abstract class (a class with one or more abstract methods), but there is no way to tell the compiler to not allow the instantiation of the abstract class. Delphi does not support abstract member properties directly. To implement an abstract properity, make use of abstract methods. That is, you can read a GetPropertyX abstract function and write to a SetPropertyX abstract procedure. In effect, creating  an abstract property.

10 years ago, and updated 7 years ago
(4 Comments , last by Uwais.Q )

Code

Article
Nothing New Since Your Last Visit
23341
Hits

Pascal and Delphi Coding

Mike Prestwood
3. Delphi Base Class (TObject)

In Delphi programming language (Object Pascal), all classes ultimately inherit from the base class TObject.

10 years ago, and updated 9 years ago

Code

Article
Nothing New Since Your Last Visit  
22502
Hits

Pascal and Delphi Coding

Mike Prestwood
4. Delphi Class Helpers (class helper for)

Delphi allows you to extend an existing class without using inheritance. Buggy in 2005 and not officially supported but stable and usable in 2006 and above. You declare a class helper similiar to how you declare a class but use the keywords class helper for.

  • You can name a helper anything.
  • Helpers have access only to public members of the class.
  • You cannot create an object instance directly from a class helper.
  • self refers to the class being helped.
9 years ago, and updated 8 years ago

Code

Article
Nothing New Since Your Last Visit  
24830
Hits

Pascal and Delphi Coding

Mike Prestwood
5. Delphi Class Members (Class)

Object Pascal supports static methods, but not static member fields. For static member fields, use traditional Pascal-like global variables. Since Object Pascal is a hybrid language, you can use global functions and data so the need for class methods is diminished but still useful. Delphi 1-7: All classes in a unit are friendly (see eachother's private members), some developers like to put each class in it's own unit and reserve putting multiple classes in the same unit until they wish to implement friendly classes. Delphi 2005+: New strict keyword allows you to indicate friendly.

10 years ago, and updated 9 years ago

Code
Nothing New Since Your Last Visit
12365
Hits

Pascal and Delphi Coding

Mike Prestwood
6. Delphi Class..Object (class..end..Create)

Declare your class in the Interface section. Then implement the class in the Implementation section.

10 years ago, and updated 9 years ago
(4 Comments , last by John_V._Townsen)

Code

KB Post
Nothing New Since Your Last Visit
16608
Hits

Pascal and Delphi Coding

Mike Prestwood
7. Delphi Constructors (constructor)

In Delphi, use the constructor keyword to signify which method or methods are constructors for a class. It is traditional but not required to use a procedure called Create.

In addition to having multiple named constructors, you can overload constructors.

10 years ago, and updated 9 years ago
(3 Comments , last by LatonyaH.D.L )

Code

KB Post
Nothing New Since Your Last Visit  
16678
Hits

Pascal and Delphi Coding

Mike Prestwood
8. Delphi Destructor (Free or FreeAndNil)

Object Pascal uses a standard virtual destructor named Destroy which is called by the standard Free method. All objects are dynamic, so you need to call MyObject.Free method or the FreeAndNil(MyObject) routine for each object you create.

10 years ago, and updated 9 years ago
(5 Comments , last by Garland.K )

Code
Nothing New Since Your Last Visit  
21765
Hits

Pascal and Delphi Coding

Mike Prestwood
9. Delphi Inheritance (=class(ParentClass))

In Delphi, you use the class keyword followed by the parent class in parens. If you leave out the parent class, your class inherits from TObject.

10 years ago, and updated 9 years ago

Code

KB Post
Nothing New Since Your Last Visit  
25593
Hits

Pascal and Delphi Coding

Mike Prestwood
10. Delphi Inheritance-Multiple (Not Supported)

Delphi does not support multiple implementation inheritance. Each class can have only one parent class (a single inheritance path). In Delphi, you can use multiple interface usage to design in a multiple class way horizontally in a class hierarchy.

10 years ago, and updated 9 years ago

Code
Nothing New Since Your Last Visit
5678
Hits

Pascal and Delphi Coding

Mike Prestwood
11. Delphi Interfaces (IInterface, TInterfacedObject)

You specify an interface in the type block just like you do for a class but you use the interface keywoard instead of the class keyword and in the interfaces section only. Since interfaces, by definition, do not have any implementation details, all you do is specifiy it in the type block.

10 years ago, and updated 9 years ago

Code

Article
Nothing New Since Your Last Visit
23040
Hits

Pascal and Delphi Coding

Mike Prestwood
12. Delphi Member Field

In Delphi, it is common to start all member fields with "F" as in FName and FAge. You can initialize the value of member fields. Delphi member fields do not support static data. The workaround is to use the hybrid nature of Delphi and use a unit variable (a variable declared in the implementation section of a unit).

10 years ago, and updated 9 years ago

Code
Nothing New Since Your Last Visit
7466
Hits

Pascal and Delphi Coding

Mike Prestwood
13. Delphi Member Method (procedure, function)

Delphi uses the keywords procedure and function. A procedure does not return a value and a function does.

10 years ago, and updated 9 years ago

Code
Nothing New Since Your Last Visit
7314
Hits

Pascal and Delphi Coding

Mike Prestwood
14. Delphi Member Modifiers

Specify Delphi member modifiers as follows:

reintroduce; overload; [binding modifier]; [calling convention]; abstract; [warning]

The binding modifiers are virtual, dynamic, or override. The calling conventions are register, pascal, cdecl, stdcall, or safecall. The warnings are platform, deprecated, or library. Additional directives include reintroduce, abstract, class, static, overload, and message.

10 years ago, and updated 9 years ago

Code

Article
Nothing New Since Your Last Visit  
10158
Hits

Pascal and Delphi Coding

Mike Prestwood
15. Delphi Member Property (property..read..write)

Delphi uses a special property keyword to both get and set the values of properties. The read and write keywords are used to get and set the value of the property directly or through an accessor method. For a read-only property, leave out the write portion of the declaration.

You can give properties any visibility you wish (private, protected, etc). It is common in Delphi to start member fields with "F" ("FName" in our example) and drop the "F" with properties that manage member fields ("Name" in our example).

10 years ago, and updated 8 years ago
(5 Comments , last by Chatlie12.m )

Code
Nothing New Since Your Last Visit
12957
Hits

Pascal and Delphi Coding

Mike Prestwood
16. Delphi Member Visibility

Up until D2005, private and protected were not implemented strictly. Starting with D2005, a traditional strict versions of OOP are supported using the strict keyword. OO purist will want you to use strict private over private and strict protected over protected. I suggest you follow that advice until you both fully understand the differences and have a specific need. Delphi offers a special published specifier which is the same as public members but runtime type information (RTTI) is generated.

10 years ago, and updated 9 years ago

Code

Article
Nothing New Since Your Last Visit  
34661
Hits

Pascal and Delphi Coding

Mike Prestwood
17. Delphi Overriding (virtual, override)

In Delphi, you specify a virtual method with the virtual keyword in a parent class and replace it in a descendant class using the override keyword. Call Inherited in the descendant method to execute the code in the parent method.

9 years ago, and updated 8 years ago
(2 Comments , last by Anonymous )

Code

Article
Nothing New Since Your Last Visit
22008
Hits

Pascal and Delphi Coding

Mike Prestwood
18. Delphi Polymorphism

Delphi supports the following types of polymorphism:

9 years ago
(1 Comments , last by Uwais.Q )

Code
Nothing New Since Your Last Visit
12401
Hits

Pascal and Delphi Coding

Mike Prestwood
19. Delphi Sealed class (sealed, final)

With Delphi, use the sealed keyword to prevent a class from being inherited from and use the final keyword to prevent a method from being overridden.

10 years ago, and updated 9 years ago
(1 Comments , last by Uwais.Q )

Code
Nothing New Since Your Last Visit  
15463
Hits

Pascal and Delphi Coding

Mike Prestwood
20. Private versus Strict Private What is the difference between private and strict private?
10 years ago
(2 Comments , last by Martha.B )

FAQ
Nothing New Since Your Last Visit
12748
Hits

Pascal and Delphi Coding

Mike Prestwood
21. Protected versus Strict Protected What is the difference between Protected and Strict Protected visibility?
10 years ago
(1 Comments , last by Uwais.Q )

FAQ
Nothing New Since Your Last Visit
11401
Hits

Pascal and Delphi Coding

Mike Prestwood
22. Sealed Classes

What is a sealed class?

10 years ago

FAQ
Nothing New Since Your Last Visit
7253
Hits

Pascal and Delphi Coding

Mike Prestwood
23. Strict Visibility The Strict specifier tightens up the scope for private and protected. With Strict Private, members within a class are visible ONLY within the class declared and Strict Protected are visible only within the class declared and descendent classes. Without strict, private and protected members can also be seen by all classes declared in the same unit (friendly classes). The Strict specifier was introduced with Delphi for .Net preview in Delphi 7 in an update to the .Net compiler preview and with Win32 in Delphi 2005 to fully comply with the .NET CLS. Delphi's traditional private specifier maps to the CLR's assembly visibility and the protected specifier maps to the CLR's assembly or family visibility.
10 years ago

Definition
Nothing New Since Your Last Visit
14603
Hits

Pascal and Delphi Coding

Mike Prestwood
24. Virtual Abstract versus Dynamic Abstract Why do I have to specify virtual when creating an abstract method? Why not just abstract?
10 years ago, and updated 10 years ago
(2 Comments , last by mprestwood )

FAQ
Nothing New Since Your Last Visit
14826
Hits

Pascal and Delphi Coding

Icon Legend:
Recent or not:
- Recent activity (within last two weeks).
- No activity last two weeks.
 Since your last logged visit:
- New to you or updated since your last visit (sign in now to activate).
- NOT new to you since your last visit (sign in now to activate).

New Pascal and Delphi Coding Knowledge Base Post...

Share your knowledge with the WORLD! In addition to adding comments to existing posts, you can post knowledge you've acquired. We welcome full articles (intro with screen shots), general posts (shorter), and tidbits (tips, FAQs, definitions, etc.).

Post New...

Tidbit Post: Short Flashcard FAQ Definition Quick Tip Code Snippet
Longer Post: Full Article General Post File Link Error News
Other: Blog Topic
Or, if YOU have a question...
  Pascal and Delphi Coding Message Board
-
   Contact Us!
 
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

3,410 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...


©1995-2018 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech