CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    108

    Smile Good coding convections ?

    I have some trouble with generic var naming. I use to mix uppercase & lowercase to define my variables in case sensitive languages, something like this.
    Code:
    FileInfo fileInfo;
    public void TheClass(FileInfo fileInfo) {
      this.fileInfo = fileInfo;
    }
    I don't need to name fileInfo "TheInfoOfTheFile", fileInfo is great, but the code in VB becomes confusing. I cant imagine a good coding convection in VB. Could I have some advice ?

    This is how I do it by now...
    Code:
    Private FileInfo1 As System.IO.FileInfo;
    Public Sub New(ByVal FileInfo1 As System.IO.FileInfo)
      Me.FileInfo1 = FileInfo1;
    End Sub
    Good Luck
    HackmanC

  2. #2
    Join Date
    Nov 2007
    Posts
    110

    Re: Good coding convections ?

    It is kind of your own preference, but you should always use relevant names(i.e. don't call it fileInfo if the variable type is FileInfo, it's confusing).

    Name it something that is obvious for when you are glancing over the code, fi wouldn't tell you much but at least you could tell it is a variable and not a class. Just my opinion though =-)

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Good coding convections ?

    Yeah. Right.
    With objects or classes I always try to prefix the name with an abbreviation of the typename/classname and then give a name describing the dedication.

    For example a variable of type FileInfo would always start with the prefix fi followed by a name describing its usage. Example fiInputFile, or whatnot fiNextFile if being a file in a loop.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured