locked
Suggestion RRS feed

  • General discussion

  • I've been seeing from regulars here assisting new developers with great code but not much thought when it comes to naming variables and most of the time writing data centric logic directly in forms rather than in classes. 

    Keep in mind that many newcomers here take what is given to them lock stock and barrel including patterns mentioned above which may be carried with them for a long time so I would love to see regulars take more time in these areas and this includes me.

    Examples of bad naming

    Dim a As New Demo

    Why not

    Dim demo As New Demo

    While dt is perfectly acceptable for dt while d is not.

    Using rowIndex rather than x in a for-next especially when there may be for-next within for-next this makes code easier to read. 

    I believe the above is a good example of naming objects



    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, April 18, 2019 7:36 PM

All replies

  • Please feel free to call me out if you ever see such bad examples in my posts! I think I do alright, though.



    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Thursday, April 18, 2019 7:43 PM
  • Please feel free to call me out if you ever see such bad examples in my posts! I think I do alright, though.



    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    I will not call out any member here including you. The idea for this post is to get people thinking but they don't have to listen to me either.

    You, no problem with your code :-)



    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, April 18, 2019 7:51 PM
  • It doesn't hurt.

    https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/naming-conventions


    Maybe your post can be one of those thumbtack posts.
    • Edited by DA924x Thursday, April 18, 2019 7:54 PM
    Thursday, April 18, 2019 7:52 PM
  • I keep getting put off by how code is posted, like if you add a comment caret it seems to comment out everything to the end. I keep forgetting how to copy code from VS in such a way that pastes more accurately in this forum

    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi


    • Edited by Gtripodi Thursday, April 18, 2019 8:06 PM
    Thursday, April 18, 2019 8:06 PM

  • Dim demo As New Demo


    I don't know if things are changed. But while this is a standard suggestion for case sensitive program language (c types), has it always been a strict sign of bad coding for case insensitive program languages. 

    If you look at the code that is created in VB by generators (For instance datasets), then you will see that what you show is strongly avoided. Personally I use in VB meaningfullnames on global level. But in samples I avoid that on lower levels to show that a name is just an identifier and has no longer lifetime than in the level it is used. People think for me to often that every name has to be unique what is not the case in VB.

    I find 

    For i = 0 to object.count - 1 ........
    

    beter code for demonstration purpose then

    for theIndexerUsedInThisLoop = 1 to theClassNameOfThisObject.Count - 1 ....... 

    However, I commit that if you show code, then do it in the style of all going conventions for Visual Basic. 

    Therefore I even change the code from persons in camelCase en change cases according the conventions if I show that in this forum. 

    That is something I see seldom done and I recognized lately as well not by you.


    Success
    Cor

    Friday, April 19, 2019 12:49 AM

  • Dim demo As New Demo


    I don't know if things are changed. But while this is a standard suggestion for case sensitive program language (c types), has it always been a strict sign of bad coding for case insensitive program languages. 

    If you look at the code that is created in VB by generators (For instance datasets), then you will see that what you show is strongly avoided. Personally I use in VB meaningfullnames on global level. But in samples I avoid that on lower levels to show that a name is just an identifier and has no longer lifetime than in the level it is used. People think for me to often that every name has to be unique what is not the case in VB.

    I find 

    For i = 0 to object.count - 1 ........

    beter code for demonstration purpose then

    for theIndexerUsedInThisLoop = 1 to theClassNameOfThisObject.Count - 1 ....... 

    However, I commit that if you show code, then do it in the style of all going conventions for Visual Basic. 

    Therefore I even change the code from persons in camelCase en change cases according the conventions if I show that in this forum. 

    That is something I see seldom done and I recognized lately as well not by you.


    Success
    Cor

    I see you still have a negative attitude to change and I'm refraining from being drugged into a meaningless discussion with you.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, April 19, 2019 1:19 AM

  • Dim demo As New Demo


    I don't know if things are changed. But while this is a standard suggestion for case sensitive program language (c types), has it always been a strict sign of bad coding for case insensitive program languages. 

    If you look at the code that is created in VB by generators (For instance datasets), then you will see that what you show is strongly avoided. Personally I use in VB meaningfullnames on global level. But in samples I avoid that on lower levels to show that a name is just an identifier and has no longer lifetime than in the level it is used. People think for me to often that every name has to be unique what is not the case in VB.

    I find 

    For i = 0 to object.count - 1 ........

    beter code for demonstration purpose then

    for theIndexerUsedInThisLoop = 1 to theClassNameOfThisObject.Count - 1 ....... 

    However, I commit that if you show code, then do it in the style of all going conventions for Visual Basic. 

    Therefore I even change the code from persons in camelCase en change cases according the conventions if I show that in this forum. 

    That is something I see seldom done and I recognized lately as well not by you.


    Success
    Cor

    I see you still have a negative attitude to change and I'm refraining from being drugged into a meaningless discussion with you.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    That is too funny. :)
    • Edited by DA924x Friday, April 19, 2019 2:23 AM
    Friday, April 19, 2019 2:20 AM