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

Advanced
-Collapse +Expand Prism To/From
To/FromCODEGuides
-Collapse +Expand Prism Study Test
PRESTWOODCERTIFIED
-Collapse +Expand Prism Store
PRESTWOODSTORE
   ► KBProgrammingDelphi PrismOOP   Print This     

Prism KB: OOP Topic



18 Articles Found in the OOP Topic 

  KB Article    

Mike Prestwood
1. Delphi Prism Abstraction (abstract, override)

Prism supports abstract class members and abstract classes using the abstract keyword. An abstract class is a class with one or more abstract members and you cannot instantiate an abstract class. However, you can have additional implemented methods and properties. An abstract member is either a method (method, procedure, or function), a property, or an event in an abstract class. You can add abstract members ONLY to abstract classes using the abstract keyword. Alternatively, you can use the empty keyword in place of abstract if you wish to instantiate the abstract class.

11 years ago, and updated 10 years ago

Code

Article
Nothing New Since Your Last Visit
12751
Hits

Delphi Prism

Mike Prestwood
2. Delphi Prism Base Class (System.Object)

In Prism, the Object keyword is an alias for the base System.Object class and is the single base class all classes ultimately inherit from.

11 years ago, and updated 10 years ago

Code
Nothing New Since Your Last Visit  
7083
Hits

Delphi Prism

Mike Prestwood
3. Delphi Prism Class Contracts (require, ensure)

Prism supports class contracts with its require and ensure keywords. The require keyword is a pre condition that must be true when the method is called. The ensure keyword is a post condition that much be true when a method exits. With either, if the condition evaluates to false, then an assertion is generated.

They can be used to check for the validity of input parameters, results, or for the state of the object required by the method.

The require and ensure keywords will expand the method body to list the preconditions; both sections can contain a list of Boolean statements, separated by semicolons.

10 years ago

Code
Nothing New Since Your Last Visit
7811
Hits

Delphi Prism

Mike Prestwood
4. 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.

11 years ago, and updated 10 years ago
(4 Comments , last by mprestwood )

Code
Nothing New Since Your Last Visit  
16893
Hits

Delphi Prism

Mike Prestwood
5. Delphi Prism Class Members (static)

The Strict keyword was introduced from the beginning (Delphi.Net preview that shipped with D7).

11 years ago, and updated 10 years ago

Code
Nothing New Since Your Last Visit
10440
Hits

Delphi Prism

Mike Prestwood
6. Delphi Prism Class..Object (class..end..new)

Declare your class in the Interface section. Then implement the class in the Implementation section. To create an object instance, use the New keyword. Optionally, you can use Create for backword compatibility with Delphi if you turn it on in the compatibility options. Since Prism does have a garbage collector, you do not have to free the object. If you need to free either unmanaged resources or resources where "timing" is important, implement IDisposable and take control of freeing the object yourself using Dispose.

11 years ago, and updated 10 years ago
(1 Comments , last by mtiede )

Code

Article
Nothing New Since Your Last Visit
14069
Hits

Delphi Prism

Mike Prestwood
7. Delphi Prism Constructors (constructor + class name)

Prism uses unnamed constructor methods for constructors. Prism also supports a Create constructor method for backward compatibility with Delphi for Win32.

10 years ago, and updated 10 years ago

Code

Article
Nothing New Since Your Last Visit  
15866
Hits

Delphi Prism

Mike Prestwood
8. 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.

10 years ago, and updated 10 years ago

Code

Article
Nothing New Since Your Last Visit  
19871
Hits

Delphi Prism

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

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

11 years ago, and updated 10 years ago

Code
Nothing New Since Your Last Visit  
8836
Hits

Delphi Prism

Mike Prestwood
10. Delphi Prism Interfaces

With Prism, you use the Interface keyword to define an interface and then you include one or more interfaces where you specify the single class inheritance (separated by commas).

11 years ago, and updated 10 years ago
(1 Comments , last by mtiede )

Code

Article
Nothing New Since Your Last Visit
15026
Hits

Delphi Prism

Mike Prestwood
11. 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 =).

11 years ago, and updated 10 years ago
(1 Comments , last by mtiede )

Code

Article
Nothing New Since Your Last Visit
12327
Hits

Delphi Prism

Mike Prestwood
12. Delphi Prism Member Method (method, procedure, function)

Prism uses the keyword method for member methods. Alternatively, you can use procedure or function if you want the compiler to make sure all functions return a value and all procedures do not.

11 years ago, and updated 10 years ago

Code
Nothing New Since Your Last Visit
7743
Hits

Delphi Prism

Mike Prestwood
13. Delphi Prism Member Modifiers

Prism supports a full suite of member modifiers. Prism virtuality modifiers are virtual, override, final, and reintroduce. Prism general modifiers are abstract, empty, async, external, locked, unsafe, implements, and iterator. Not all member types support all member modifiers. For example, member fields support only readonly and implements.

11 years ago, and updated 10 years ago

Code

Article
Nothing New Since Your Last Visit  
10168
Hits

Delphi Prism

Mike Prestwood
14. 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).

11 years ago, and updated 9 years ago
(2 Comments , last by mprestwood )

Code
Nothing New Since Your Last Visit
10625
Hits

Delphi Prism

Mike Prestwood
15. Delphi Prism Overriding (virtual, override)

Same as Delphi. In Prism, 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.

10 years ago

Code

Article
Nothing New Since Your Last Visit
14006
Hits

Delphi Prism

Mike Prestwood
16. Delphi Prism Partial Classes (partial)

Prism supports both partial classes and partial methods using the keyword partial. A partial method is an empty method defined in a partial class.

10 years ago, and updated 10 years ago

Code

Article
Nothing New Since Your Last Visit
13003
Hits

Delphi Prism

Mike Prestwood
17. Delphi Prism Polymorphism

Prism supports the following types of polymorphism:

10 years ago, and updated 10 years ago
(1 Comments , last by mtiede )

Code
Nothing New Since Your Last Visit
9425
Hits

Delphi Prism

Mike Prestwood
18. Delphi Prism Prevent Derivation (sealed, final)

Same keywords as Delphi (sealed uses slightly different syntax). With Prism, use the sealed keyword before the class keyword to prevent a class from being inherited from and use the final keyword to prevent a method from being overridden.

10 years ago

Code
Nothing New Since Your Last Visit  
8176
Hits

Delphi Prism

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 Delphi Prism 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...
  Delphi Prism Message Board

Follow PrestwoodBoards on: 


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