Tech Off Thread

16 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

What notation do you guys use for control naming?

Back to Forum: Tech Off
  • User profile image
    Deactivated User

    Comment removed at user's request.

  • User profile image
    balupton

    TheGroupOfTheControl_TheNameOfTheControl

    So

    About - tab page / group
    About_Authors - just something in the group
    About_Translators - just something in the group

    I don't put the type of variable inside my names because I do most of my work in C# .NET 2005, and it tells you the type of the control during the intellisense.

    And if i'm not using C# then i'm using PHP 4, and there variable types don't matter, i can easily make a int be a string or whatever.

    In PHP most of my stuff is inside classes, and there is no point going

    class About {
    $About_Authors;
    $About_Translators;
    }

    You just do

    class About {
    $Authors;
    $Translators;
    }

    Yer I'm really against the hungarian notation, sure it would be good back 15 years ago, where memory was such a problem and you had to make sure that you don't run out of memory when assigning to your variables.

    Yer...

  • User profile image
    sysrpl

    I believe it's more important to put function before type, so in a form for collecting information I might have:

    CustomerGroupBox
      CustomerName
      CustomerPhone
      CustomerEmail
      CustomerNotes
    OrderGrid
        OrderNumber
        OrderDate
        OrderStatus
    CancelButton
    SaveButton

    I care less about naming controls after the control type, and more about what they are used for. Of couse you can use camel case, or underscores, or whatever ... you get the idea.

  • User profile image
    W3bbo

    sysrpl wrote:
    I believe it's more important to put function before type, so in a form for collecting information I might have:

    CustomerGroupBox
      CustomerName
      CustomerPhone
      CustomerEmail
      CustomerNotes
    OrderGrid
        OrderNumber
        OrderDate
        OrderStatus
    CancelButton
    SaveButton


    Lies!

    You'd hate my source then Smiley I name my functions like so:

    CustomerGet, CustomerUpdate, CustomerDelete, ObjectCreate, ObjectGet rather than GetCustomer, UpdateCustomer, DeleteCustomer, CreateObject, and GetObject.

    I understand this naming system is "more correct" since it follows OOP's "Noun Verb" syntax rather than English "Verb Noun" which makes no sense until you've got the entire sentance.

    In English, you say "Open the door", in more logical languages you say "Door, open".

  • User profile image
    Sven Groot

    W3bbo wrote:
    I understand this naming system is "more correct" since it follows OOP's "Noun Verb" syntax rather than English "Verb Noun" which makes no sense until you've got the entire sentance.

    Actually, most stuff I've read on OOP says you should use "verb noun" for actions (methods).

  • User profile image
    W3bbo

    Sven Groot wrote:
    W3bbo wrote:I understand this naming system is "more correct" since it follows OOP's "Noun Verb" syntax rather than English "Verb Noun" which makes no sense until you've got the entire sentance.

    Actually, most stuff I've read on OOP says you should use "verb noun" for actions (methods).


    But you call "Door.Open()" not "Open(Door)"

  • User profile image
    SlackmasterK

    W3bbo wrote:

    But you call "Door.Open()" not "Open(Door)"


    ahh, sometimes I miss BASIC.  The non-visual kind. It was so simple, even if it didn't do anything useful. See if I remember correctly...

    function open(object$)
       if object$ = "door" doorOpen = 1
    end function
    open("door")

  • User profile image
    Andrew Davey

    If you have methods in the Noun-Verb form maybe you should consider creating an object, such as Customer, and then having methods on that.

    Customer.Get() would be a static factory method for example.

  • User profile image
    W3bbo

    Andrew Davey wrote:
    If you have methods in the Noun-Verb form maybe you should consider creating an object, such as Customer, and then having methods on that.

    Customer.Get() would be a static factory method for example.


    That's the methodology I switched to for my latest project, but sometimes it's just easier to have all the methods in a single class.

  • User profile image
    amotif

    W3bbo wrote:

    But you call "Door.Open()" not "Open(Door)"


    verb-noun:

    door.OilHinge();

    noun-verb:

    door.HingeOil();

    It should make sense to English speakers. Smiley


  • User profile image
    W3bbo

    amotif wrote:
    W3bbo wrote:
    But you call "Door.Open()" not "Open(Door)"


    verb-noun:

    door.OilHinge();

    noun-verb:

    door.HingeOil();

    It should make sense to English speakers. Smiley




    Bad example, the Hinge may be a member of Door, but it isn't the Door's responsibility to Oil the Hinge.

    Maybe that kind of operation would be better done under Aspect-Orientated Programming rather than Object Orientated.

    Here's a better example:

    Oil.Lubricate(Door.Hinge);

  • User profile image
    amotif

    I suppose you'd say the same of door.TurnKnob()?

    That's okay, we all have preferences...
    Smiley

    Besides, the point is about verb-noun order.

  • User profile image
    Maurits

    Hand.Turn(Door.Knob)
    OilCan.ApplyTo(Door.Hinge)

  • User profile image
    Sven Groot

    This is starting to remind me of old Sierra adventures, where the parser would allow you to be correct "Use key to open the door" but often if you typed "Use key door" it'd also have the desired result. Smiley

  • User profile image
    W3bbo

    amotif wrote:
    I suppose you'd say the same of door.TurnKnob()?

    That's okay, we all have preferences...
    Smiley


    Actually, If I were using your methodology I'd change the casing:

    Door.turnKnob();

    Java's caseing system (Class, memberOf, NameSpace) makes a lot more sense than C#'s PascalCaseEverything.

  • User profile image
    Cannot​Resolve​Symbol

    As far as methods go, I typically use verbNoun.  Part of that is coming from a Java background--  Java exposes properties through methods like getName() and setName(string s), so that's the syntax I'm used to using.

    For controls--  it tends to be pretty arbitrary.  I haven't done enough GUI programming to settle on a naming style really, but I tend to just use descriptive names w/o control types UNLESS it's something like a button.

    I don't like how hard it is to change the name of a control in C# (it's buried in the properties sheet)...  makes me lazy (I get names like Button1 when working on smaller projects and don't change them).  Whatever happened to that quick property editor from Beta 1???

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.