Class fields naming convention and style

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Class fields naming convention and style

Beitragvon Michael_S » Di 27. Aug 2013, 15:19

Hi All,

What Naming Convention and Style would the group recommend for Class fields?

I've been using bumpy caps / camel caps for a long time now and including the Class name. For example if I have a Class called 'Article' I would name my fields in the singular ... 'ArticleTitle', 'ArticleDescription', 'ArticleMapLat', 'ArticleMapLong'.

Would the group consider the inclusion of the Class name 'noise' or useful in certain situations?

Michael.
Production Area
London, UK
http://productionarea.com

Benutzeravatar
Carrear
webEdition Partner
webEdition Partner
Beiträge: 646
Registriert: Do 17. Jan 2013, 03:02
Wohnort: Hannover
Kontaktdaten:

Re: Class fields naming convention and style

Beitragvon Carrear » Di 27. Aug 2013, 15:52

I dont like to use prefixes. I just call my fields like "title", "content" a.s.o. When i call this fields in a listview or something like that, than i know, which class i am talking about, so there is no problem.

Pro:
In different Classes with similar fields like "title" and "content" i can create queries over all classes without calling all the different "title" fields (e.g. "ArticleTitle", "DateTitle", a.s.o.).

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Class fields naming convention and style

Beitragvon Michael_S » Di 27. Aug 2013, 16:49

Hi Carrear,

I can see that the single words have advantages when working with queries but then you get into the issue of case sensitive reserved words "Title, Description, Keywords" so you would have to use lowercase words. But then you still need a way of delimiting the words as a single string would be hard to read and easy to mistype.

Michael.
Production Area
London, UK
http://productionarea.com

Benutzeravatar
Carrear
webEdition Partner
webEdition Partner
Beiträge: 646
Registriert: Do 17. Jan 2013, 03:02
Wohnort: Hannover
Kontaktdaten:

Re: Class fields naming convention and style

Beitragvon Carrear » Di 27. Aug 2013, 21:49

Yes :D I am working with german titles (titEl, Inhalt (like content) a.s.o.) so im working with short keywords that are not crashing with system keywords like meta datas :)


Zurück zu „Off-Topic & Smalltalk“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 3 Gäste