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

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

   ► KBProgrammingDelphi PrismOOP   Print This     
  From the August 2011 Issue of Prestwood eMag
 
Prism OOP:
Delphi Prism Member Property (property..read..write)
 
Posted 12 years ago on 12/20/2008 and updated 7/9/2010
Prism Code Snippet:
 A flashcard from our Prism Flashcards Library
 A code snippet from our Prism Code Snippets Page

KB101740

Delphi Prism Member Property

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.

Prism also supports a shortcut syntax called implicit fields (known as auto-generated properties in C#):

property CyborgAge: Integer;

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" (FCName in our example) and drop the "F" with properties that manage member fields (CyborgName in our example).

Syntax Example:
Cyborg = class(System.Object)
private
  FCName: String;
public
  property CyborgName: String read FCName write FCName;
end;

Comments

1 Comments.
Share a thought or comment...
Comment 1 of 2

Although I don't think Microsoft makes it indisputably clear, this link:

http://msdn.microsoft.com/en-us/library/x2dbyw72%28VS.71%29.aspx?ppud=4

Says that Properties should be Pascal Case and Protected (non-public?) instance fields should be Camel Case.

So I think in your example, CyborgName should be Pascal, as it is, but the backing field should be fcName or Camel Case.

Admittedly, they DON'T specifically say what to do with PRIVATE instance fields so that muddies the waters.  But if the backing fields are Pascal and properties are Pascal, then it gets harder to read the code and tell which is which.

Of course, personally, I think having case sensitivity in a language is dumb and the same thing goes for these kinds of "case conventions".

However, I believe that camel case for the (non-public) fields is the recommendation.

FWIW.

Posted 10 years ago

Comment 2 of 2

FWIW, good points. Nothing wrong with standards. I'll sweep thru and update all these examples. For what it's worth, I agree that private and protected probably could both be camel capped.

Posted 10 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 = P1121A1
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

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


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