IT SOLUTIONS
Your full service technology partner! 
-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

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi PrismOOP   Print This     
  From the February 2016 Issue of Prestwood eMag
 
Prism OOP:
Delphi Prism Class Member Visibility Levels
 
Posted 17 years ago on 12/19/2008 and updated 5/6/2009
Prism Code Snippet:
 A flashcard from our Prism Flashcards Library
 A code snippet from our Prism Code Snippets Page

KB101734

General Info: Class Visibility Specifiers

In OOP languages, members of a class have a specific scope that indicates visibility. Standard visibility includes private, protected, and public. Private members are usable by the defining class only (fully encapsulated). They are invisible outside of the class except by friendly classes. Protected members are usable by the defining class and descendant classes only (plus friendly classes). Public members are usable wherever its class can be referenced.

Languages Focus: Member Visibility

Traditional member visibility specifiers for fully OOP languages are private, protected, and public. Many modern OOP languages implement additional member visibilities.

Additional member modifiers are documented under the Member Modifiers topic.

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.

Syntax Example:
Cyborg = public class(System.Object)
private
  //private properties, methods, etc. here.
  FName: String;
protected 
  //protected properties, methods, etc. here.
assembly and protected
  //properties, methods, etc. here.
assembly or protected
  //properties, methods, etc. here.
public
  //properties, methods, etc. here.
end;

More Info

Definition:  Class Visibility Specifiers

Comments

1 Comments.
Share a thought or comment...
First Comment
Comment 1 of 4

FWIW, several paragraphs are repeated in the post.

Posted 16 years ago

Comment 2 of 4

Thanks for the heads up Mark. I also cleaned up  a grammar error too.

Posted 16 years ago

Comment 3 of 4

No problem.

I should have been a proofreader.

The halls are kind of echoing around here.  I suspect there are even fewer .net Pascal programmers than there were win32 pascal programmers.

Posted 16 years ago

Latest Comment
Comment 4 of 4

Hi Mark,

>>The halls are kind of echoing around here.

Yes, we get a lot of Delphi and Prism developers that "pass through" but don't stick around. Not sure why, but that's the reality. I was hoping over the years as the content got better and better that more developers would "stick" around. We do have quite a few that visit from time to time but only a few dozen that visit more than once a week.

Posted 16 years ago
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1234A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile


Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

Intermediate

1 Intermediate Level Question

Question #1: Multiple Choice

The class visibility specifiers are:

Answer:
1. 

private, strict private, protected, stict protected, public, and published.

2. 

private, protected, public, and published.

3. 

private, protected, assembly and protected, assembly or protected, and public.

4. 

private, protected, internal, protected internal, and public.

5. 

Private, Protected, Friend, Protected Friend, and Public.


 KB Article #101734 Counter
20559
Since 12/19/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2025 Prestwood IT Solutions.   [Security & Privacy]