Book a Demo

Author Topic: Naming - Adornments  (Read 8680 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Naming - Adornments
« on: April 04, 2006, 06:49:17 am »
[size=24]AdornToReduceErrors[/size]
[size=16]Context:[/size]
[size=13]You need to use named elements correctly.[/size]
[size=16]Issue(s):[/size]
[size=13]Various factors often contribute to errors in writing code.  Often these are picked up by the language processor, but often they aren't.  Some of these are:
  • Scoping (coding block)
  • Visibility (Public ... Private)
  • Datatype (Integer, String, Real, Boolean...)
  • Volatility (Constant, variable, WORM)
  • Nature (atomic element versus structure)
[/font][/size][/color]
[size=16]Force(s):[/size]
[size=13]
  • limited range of mechanisms to indicate these issues
[/font][/size][/color]
[size=16]Therefore:[/size]
[size=13]Adorn the basic name to reduce errors[/size]
[size=16]Example(s):[/size]
[size=13]gsSECTION_NAME        (global string constant Section Name)
moAncestorClassifier        (private member object reference to Ancestor Classifier)
IsEmpty        (public boolean property indicating the instance is empty)
validateSubTypeCluster        (private method to validate a subtype cluster)
SetLogicalOnlyInferenceOnEntity        (public method)
s_camel_cased_logical_table_persistence_caption         (local string WORM variable containing the camel cased caption to be used for this logical table)
[/size]

[size=16]Discussion:[/size]
[size=13]My experience has been that with the kinds of adornments I use, I actually reduce the number of errors I make in coding.  The form of the name tells you a lot about where it can be used (LV versus RV), where it came from, what it looks like or how it can be cast.  Also, the adornments allow the same conceptual thing, rendered differently to have the same semantic name, but be differently adorned.  I find this capability to be most useful.

Finally, language processors often can't process hardcopy very well...   ;)
[/size]


[size=0]©2006 Paolo Cantoni, -Semantica-[/size]

Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

SF_lt

  • EA User
  • **
  • Posts: 216
  • Karma: +1/-0
  • The Truth Is Out There
    • View Profile
Re: Naming - Adornments
« Reply #1 on: April 05, 2006, 01:05:00 pm »
one thing: LV and RV stands for something left and right?  ???
registertm everything to SparX

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Naming - Adornments
« Reply #2 on: April 05, 2006, 03:03:27 pm »
Quote
one thing: LV and RV stands for something left and right?  ???
Yes...

LV is short for LValue and RV correspondingly.

Quote
LValue:
<programming> A reference to a location, an expression which
can appear as the destination of an assignment operator
indicating where a value should be stored. For example, a
variable or an array element are lvalues but the constant 42
and the expression i+1 are not. A constant string may or may
not be an lvalue (it usually is in {C}).

(1995-04-28)

Source: The Free On-line Dictionary of Computing, © 1993-2005 Denis Howe


HTH,
Paolo
« Last Edit: April 05, 2006, 03:04:09 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

TrtnJohn

  • EA User
  • **
  • Posts: 176
  • Karma: +0/-0
    • View Profile
Re: Naming - Adornments
« Reply #3 on: April 17, 2006, 12:16:27 pm »
While I understand and agree that adornments are useful, I don't always like them because:

1)  Lack of consistent standards.  If adornments are so good I really believe there should be global standards enforced by the compiler.

2)  Readability.  Adornments can cause the code to start to look less like plain spoken English and more like gobbly-gook only understood by the author.  (See comment 1).

Because of this I like to minimize my usage of adornments myself.  When I code, I typically try and expose every data element as interface elements in my classes.  I don't want to burden these names with adornment rules because the name itself should communicate exact meaning to a client of the class.

jeshaw2

  • EA User
  • **
  • Posts: 701
  • Karma: +0/-0
  • I'm a Singleton, what pattern are you?
    • View Profile
Re: Naming - Adornments
« Reply #4 on: April 17, 2006, 03:01:47 pm »
This looks like an object oriented version of the old Hungarian notation.
Verbal Use Cases aren't worth the paper they are written upon.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Naming - Adornments
« Reply #5 on: April 18, 2006, 05:41:10 am »
Quote
This looks like an object oriented version of the old Hungarian notation.
Looks can be deceiving...  ;)

Yes, there are elements of Simonyi's Hungarian notation.  I actually bothered to read the original paper.  One interesting feature is that Charles Simonyi decreed was that the datatype should be the abstract datatype.  This appears to observed "more in the breach"!

Also, if you look at all the public examples in the original pattern, they are almost all unadorned.

So, in my view, it is sufficiently distinct from Hungarian notation to not be tagged as such...

The examples I give are from my naming architecture; but, as I previously said, each team should decide what their needs are, document them, and then compare any naming architecture proposal with the stated requirements.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Naming - Adornments
« Reply #6 on: April 18, 2006, 06:16:33 am »
Quote
While I understand and agree that adornments are useful, I don't always like them because:

1)  Lack of consistent standards.  If adornments are so good I really believe there should be global standards enforced by the compiler.
Adornments, as you suggest, shouldn't take the place of semantically valid names.  I don't think there can be universal standards.  
Some adornments are like additional metadata about the element.  My preference would be to formalise these metadata similar to .NET attributes and then let the compiler or runtime use this information to locate errors.
Quote
2)  Readability.  Adornments can cause the code to start to look less like plain spoken English and more like gobbly-gook only understood by the author.  (See comment 1).
While, technically this is true, when you use adornments in a consistent fashion, you become "blind" to them.
Quote
Because of this I like to minimize my usage of adornments myself.  When I code, I typically try and expose every data element as interface elements in my classes.  I don't want to burden these names with adornment rules because the name itself should communicate exact meaning to a client of the class.
In my naming architecture, the use of adornments is not universal (but, I hope, consistent).  They are used within methods and attributes.  As with your point here, publicly visible elements are essentially unadorned.

Paolo

Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Naming - Adornments
« Reply #7 on: April 18, 2006, 04:10:16 pm »
Quote
...there should be global standards enforced by the compiler.


I reckon they should be global facilities provided by the IDE.  (Sort of like a certain modelling tool... ;) )

We now accept and deliver requirements for end user systems that provide useability features to make their lives easier.  My beef is that we put up with this entire problem when we should be complaining to the IDE deliverers to come up with a workable solution.

bruce

(P.S. I'm not having a go at this thread tho!)
« Last Edit: April 18, 2006, 04:11:58 pm by sargasso »
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Naming - Adornments
« Reply #8 on: April 18, 2006, 04:24:15 pm »
Quote

I reckon they should be global facilities provided by the IDE.  (Sort of like a certain modelling tool... ;) )

We now accept and deliver requirements for end user systems that provide useability features to make their lives easier.  My beef is that we put up with this entire problem when we should be complaining to the IDE deliverers to come up with a workable solution.

bruce

(P.S. I'm not having a go at this thread tho!)
Yes!

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Hans

  • EA User
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: Naming - Adornments
« Reply #9 on: April 22, 2006, 12:42:39 pm »
Personally, I think, that goes a bit too far: Although I am withh you that consistent naming is the decisive measure for good domain modeling and thus for the rest of the application, it is domain driven.
Hungarian notation itself is not a good strategy. The same holds for any table centric naming convention for stored procedures (within the database).

Regards
Hans

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Naming - Adornments
« Reply #10 on: April 23, 2006, 02:44:58 am »
Hi Hans,
Welcome...
Quote
Personally, I think, that goes a bit too far:
It's not clear to me what you are referring to here.  The pattern or some of the subsequent discussion.
Quote
Although I am with you that consistent naming is the decisive measure for good domain modeling and thus for the rest of the application, it is domain driven.
This should be obvious, but apparently it isn't.  I still find I have to argue this.
Quote
Hungarian notation itself is not a good strategy.
Why is Hungarian not a good strategy?  As I mention, I don't use it, but do use elements of it.  I know why I don't use it, but as I mentioned when I started this series of threads, I'm interested in why others do and say what they do.  Can you elaborate on WHY you see Hungarian notation as not a good strategy.
Quote
The same holds for any table centric naming convention for stored procedures (within the database).
Can you elaborate further what you mean here.  I have an inkling, but as I'm said else where, I prefer not to make any assumptions whenever I can.

Paolo
« Last Edit: April 23, 2006, 02:46:19 am by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Hans

  • EA User
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: Naming - Adornments
« Reply #11 on: April 24, 2006, 02:32:02 pm »
Hi Paolo,
there is certainly much personal taste in naming strategies.
Sure, nothing is wrong to a certain style.
Personally, I make a distinction between local and nonlocal variables, avoid any prefixes. (I admit, I do respect the styles of others while maintaining apps.)

Clearly, you can get addicted to prefixes (I remember the gold-old T.. classes of the Borland OWL e.g.).
But, the real faults are mostly not in the naming convention, but in the sluggishly chosen words.
These often tell alot of what will await you upon respection.

As to SPs: These mostly don't belong to the db: They are part of application code. The actions of these have a different semantics than the actual table names. Other than that, I'd rather prefer to be a Java guy loading bulks of packages into the server cache, be rid of SPs, and enforce the db administrators to wait for hours until the cache gets loaded (or be crashed because of DB changes).

Cheers
Hans