|
![]() ![]() |
Prestwood eMagazineSubscribe now! It's Free!
|
|
KB Article | ||||
![]() Mike Prestwood |
1. Delphi Prism Member Property (property..read..write)
Like Delphi, Delphi Prism 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 and Delphi Prism to start member fields with "F" ("FName" in our example) and drop the "F" with properties that manage member fields ("Name" in our example). Posted to KB Topic: OOP
11 years ago, and updated 9 years ago
(2 Comments
, last by mprestwood )
|
![]() Code ![]() ![]() 10698
Hits |
||
![]() Mike Prestwood |
2. Delphi Prism Member Events (event)
Like all .Net languages, Prism events are a separate type of class member. You define a member event by using the event keyword. Events depend on Delegates to define the signature (the type) of the event they represent and they maintain a list of multiple subscribers - unlike in Delphi for Win32, where each event can only have one handler Posted to KB Topic: Delphi Prism
10 years ago
|
![]() Code ![]() ![]() 8179
Hits |
||
![]() Mike Prestwood |
3. Delphi Prism Event Handler
The Delphi Prism Most notable for Delphi developers is the fact that Prism does not offer initialization nor finalization sections. Posted to KB Topic: Delphi Prism
10 years ago
|
![]() Code ![]() ![]() 11223
Hits |
||
![]() Mike Prestwood |
4. Delphi Prism Empty String Check (length)
In Prism, a string can be nil (unassigned), assigned an empty string (""), or assigned a value. Therefore, to check if a string is empty, you have to check against both nil and (""). Alternatively, you can check the length of the string or use String.IsNullOrEmpty. Posted to KB Topic: Delphi Prism
10 years ago
|
![]() ![]() 15285
Hits |
||
![]() Mike Prestwood |
5. Delphi Prism String Concatenation (+)
Unlike Delphi, Prism performs implicit casting. To concatenate two strings, a string to an integer, or a string to a floating point number, use the + operator. For example, to convert a floating point number to a string just concatenate an empty string to the number as in "" + 3.2. Posted to KB Topic: Language Basics
10 years ago, and updated 10 years ago
(3 Comments
, last by mtiede )
|
![]() ![]() 14273
Hits |
||
![]() Mike Prestwood |
6. Delphi Prism Finalizer (finalize())
Unlike Delphi, Delphi Prism uses the .Net garbage collector to free managed object instances. Prism does not have nor need a true destructor. In .Net, a finalizer is used to free non-managed objects such as a file or network resource. Because you don't know when the garbage collector will call your finalizer, Microsoft recommends you implement the IDisposable interface for non-managed resources and call it's Dispose() method at the appropriate time. Posted to KB Topic: OOP
10 years ago, and updated 10 years ago
|
![]() ![]() ![]() 19957
Hits |
||
![]() Mike Prestwood |
7. Delphi Prism Member Field
In Prism you can set the visibility of a member field to any visibility: private, protected, public, assembly and protected or assembly or protected. Prism supports the readonly modifier for member fields which is handy for constant like data. In this case, I chose not to preface my read-only member field with "F" so it's usage is just like a read-only property. Prism also support the class modifier (static data) for member fields. Delphi developers should notice the use of := to initialize a member field (in Delphi you use an =). Posted to KB Topic: OOP
11 years ago, and updated 10 years ago
(1 Comments
, last by mtiede )
|
![]() ![]() 12418
Hits |
||
![]() Mike Prestwood |
8. Delphi Prism Code Blocks (begin..end)
Same as in Delphi for Win32 but Prism also supports inline variable declaration. Posted to KB Topic: Language Basics
11 years ago, and updated 10 years ago
(2 Comments
, last by mprestwood )
|
![]() ![]() 12722
Hits |
||
![]() Mike Prestwood |
9. Delphi Prism Class Member Visibility Levels
In Prism, you specify each class and each class member's visibility with a Class Member Visibility Level preceding the return type. Like Delphi, you group member declarations as part of defining the interface for a class in the Interface section of a unit. Unlike Delphi, Prism supports a traditional OO approach to member visibility with additional .Net type assembly visibility. For example, private members are truly private to the class they are declared in. In Delphi for Win32, you use strict private for true traditional private visibility. Prism also supports assembly and protected and assembly or protected which modify the visibility of protected members to include only descendants in the same assembly (and) or publicly accessible from assembly and descendant only outside (or). OO purist might object to assembly and protected and assembly or protected and I suggest you choose the traditional private, protected, and public as your first chose at least until you both fully understand them and have a specific need for them. Posted to KB Topic: OOP
11 years ago, and updated 10 years ago
(4 Comments
, last by mprestwood )
|
![]() Code ![]() ![]() ![]() 16975
Hits |
||
![]() Mike Prestwood |
10. Delphi Prism Polymorphism
Prism supports the following types of polymorphism:
Posted to KB Topic: OOP
10 years ago, and updated 10 years ago
(1 Comments
, last by mtiede )
|
![]() Code ![]() ![]() 9486
Hits |
QUICK LINKS:
|
ABOUT US:
|
©1995-2019 PrestwoodBoards [Security & Privacy]
A Prestwood IT Solutions website.
|