View Poll Results: Which way is yours?

Voters
16. You may not vote on this poll
  • 1

    0 0%
  • 2

    0 0%
  • 3

    8 50.00%
  • 4

    0 0%
  • 5

    1 6.25%
  • 6

    7 43.75%
  • 7

    0 0%
Results 1 to 26 of 26

Thread: Which way is yours?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2013
    Posts
    124

    Which way is yours?

    #1
    Code:
    Select Case c
           Case True
           i = i + 1
    End Select
    #2
    Code:
    If c = True Then
       i = i + 1
    End If
    #3
    Code:
    If c Then
       i = i + 1
    End If
    #4
    Code:
    If c = True Then i = i + 1
    #5
    Code:
    If c Then i = i + 1
    #6
    Code:
    If c Then i += 1
    #7
    Code:
    i += 1 And CInt(c)
    Mine is this #5

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,489

    Re: Which way is yours?

    Should have made this a poll...
    but...
    #6 for me.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,729

    Re: Which way is yours?

    #6 for me too... all lower numbers add extra text without helping readability (except arguably #5), and #7 reduces readability.

    Quote Originally Posted by techgnome View Post
    Should have made this a poll...
    I added a poll

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,583

    Re: Which way is yours?

    I would blend #3 and #6. I don't like one line If statements. Since I don't use them, I tend to trip over them. Therefore, I'd use the style of #3. However, I would use the i +=1 style from #6.
    My usual boring signature: Nothing

  5. #5
    Fanatic Member kpmc's Avatar
    Join Date
    Sep 2017
    Posts
    1,012

    Re: Which way is yours?

    If I had to conditionally increment i then I am with Shaggy as there is generally more code in the block. #6 but in block style as #3

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: Which way is yours?

    Quote Originally Posted by Shaggy Hiker View Post
    I would blend #3 and #6. I don't like one line If statements. Since I don't use them, I tend to trip over them. Therefore, I'd use the style of #3. However, I would use the i +=1 style from #6.
    Quote Originally Posted by kpmc View Post
    If I had to conditionally increment i then I am with Shaggy as there is generally more code in the block. #6 but in block style as #3
    I concur. I would always use += when incrementing a number but I never use single-line If statements because I think that it is too easy to overlook that they are an If statement when scanning code. To me, the more verbose option increases readability in this case. I do recognise that such things are highly subjective though.

  7. #7
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,762

    Re: Which way is yours?

    I don't like one line If statements either, just don't fit my eye.

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,583

    Re: Which way is yours?

    When the code fit your eye
    Like a catch with a try
    That's a style.
    My usual boring signature: Nothing

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,704

    Re: Which way is yours?

    I answered 6 but would typically use the blend of 3 and 6. Most of the time I avoid the one line if statements but have been known to use them.

  10. #10
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,739

    Re: Which way is yours?

    #3 almost exclusively until we switched to c#. Now I actually prefer #6 (if(c) i+=1 in c#)
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  11. #11
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: Which way is yours?

    Quote Originally Posted by kebo View Post
    #3 almost exclusively until we switched to c#. Now I actually prefer #6 (if(c) i+=1 in c#)
    You're out of the club if you don't use 'i++'.

  12. #12
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,739

    Re: Which way is yours?

    You're out of the club if you don't use 'i++'.
    I guess the invite got lost in the mail.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  13. #13
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,402

    Re: Which way is yours?

    I use nr. 6. I consider adding " = True" to be superfluous and one of the things I love about vb.net is that you can use "x += " instead "x = x + ".

  14. #14
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,704

    Re: Which way is yours?

    Quote Originally Posted by Peter Swinkels View Post
    I use nr. 6. I consider adding " = True" to be superfluous and one of the things I love about vb.net is that you can use "x += " instead "x = x + ".
    Yes and while x+=1 is only one keystroke from x=x+1 It starts to become a larger thing when you use descriptive variable names.
    intSomeLongDescriptiveName +=1
    vs
    intSomeLongDescriptiveName=intSomeLongDescriptiveName+1

  15. #15
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: Which way is yours?

    Quote Originally Posted by DataMiser View Post
    Yes and while x+=1 is only one keystroke from x=x+1 It starts to become a larger thing when you use descriptive variable names.
    intSomeLongDescriptiveName +=1
    vs
    intSomeLongDescriptiveName=intSomeLongDescriptiveName+1
    It's less of an issue in these days of Intellisense, which is why long descriptive names are more commonly used these days. It's also less of an issue if you don't use type-indicative prefixes because you have to type fewer character to get to the actual description and thus, in this case, will get a match after three fewer characters.

  16. #16
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Which way is yours?

    #3 but with the += for back in the day programming in vb.net. Its all c# now for me and that style would be...


    Code:
    if (c)
        i += 1;
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,739

    Re: Which way is yours?

    Quote Originally Posted by RobDog888 View Post
    #3 but with the += for back in the day programming in vb.net. Its all c# now for me and that style would be...


    Code:
    if (c)
        i += 1;
    Looks like you're out of the club too.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  18. #18
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Which way is yours?

    Quote Originally Posted by kebo View Post
    Looks like you're out of the club too.
    we are in a different better club
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  19. #19
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,583

    Re: Which way is yours?

    Quote Originally Posted by RobDog888 View Post
    we are in a different better club
    Club Meh!
    My usual boring signature: Nothing

  20. #20
    Junior Member
    Join Date
    Jun 2010
    Location
    the Netherlands
    Posts
    18

    Re: Which way is yours?

    I go for maximum readability and prefer #6.
    #7 is too cryptic. All other options are unnecessarily verbose.
    English is not my native language. I trust my contributions are comprehensible. Please ask for clarification if neccessary.

  21. #21
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Which way is yours?

    I vote #8 (needs to be added):

    vb.net Code:
    1. Select Case True
    2.     Case c
    3.         i += 1
    4. End Select
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  22. #22
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,739

    Re: Which way is yours?

    Quote Originally Posted by JuggaloBrotha View Post
    I vote #8 (needs to be added):

    vb.net Code:
    1. Select Case True
    2.     Case c
    3.         i += 1
    4. End Select
    That just looks weird in every way.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  23. #23
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Which way is yours?

    Not much point to do a select case with only one case and no default etc
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  24. #24
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Which way is yours?

    Quote Originally Posted by kebo View Post
    That just looks weird in every way.
    I do this often enough I've gotten used to seeing it.
    It comes in handy when I have a series of functions that each return a Boolean, this allows them to run through till it finds the one that passes.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  25. #25
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: Which way is yours?

    Quote Originally Posted by JuggaloBrotha View Post
    I do this often enough I've gotten used to seeing it.
    It comes in handy when I have a series of functions that each return a Boolean, this allows them to run through till it finds the one that passes.
    That sounds like a niche case at best. Certainly not a pattern that should be used with the basic example provided here.

  26. #26
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,583

    Re: Which way is yours?

    Yeah, but it's essentially case #1. The voting is almost entirely for 3 and 6, and a mashup of 3 and 6. So, now we have a vote for 1, or a mashup of 1 and N. Seems fitting.
    My usual boring signature: Nothing

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