+ Reply to Thread
Results 1 to 4 of 4

Style vs substance?

  1. #1
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    201

    Style vs substance?

    I have two methods for writing code. The first way is how I write a certain routine.

    Here is the before:
    Please Login or Register  to view this content.
    After that works, I simplify to this:
    Please Login or Register  to view this content.
    Now, I do realise that the first way is easier to trouble shoot and modify. But, the second doesn't use any variables and is "one line".

    And, in this particular example, since the function is only one line, I can forgo the function call entirely.

    So this:
    Please Login or Register  to view this content.
    Becomes this:
    Please Login or Register  to view this content.
    The last uses no extra variables and no function calls.
    So, which is better / faster / tighter?

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Style vs substance?

    Good code is optimized for efficiency AND maintainability.
    If you "got hit by a bus" and I had to maintain your code...I'd want to deal with your first snippet. I can see how the final result is derived. Long, run-on lines of code are confusing to work with and rarely give a clue about what they're trying to achieve.
    (sort of like one of my pet peeves about "homework coders" who build code as if it only needs to run once and never get looked at again:
    Example:
    Would you rather work with this:
    Please Login or Register  to view this content.
    or this?:
    Please Login or Register  to view this content.
    )
    Your last bit of code would make me have to explain why my shoe was sticking out of my computer monitor.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Style vs substance?

    Also, your 'simplified' code reads the cell eight times. That's very inefficient.
    Last edited by shg; 09-24-2014 at 04:07 PM.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    201

    Re: Style vs substance?

    So, the "follow-up-ability" of code is absolutely paramount.

    Plus, I'd love to have someone later look at some code I wrote and want to buy me a beer (not a bullet).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Normal Style to No Spacing Style by default.
    By dogberry in forum Word Formatting & General
    Replies: 1
    Last Post: 12-23-2012, 11:48 PM
  2. Changing "old style" buttons to "new style"?
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-22-2010, 10:23 AM
  3. From Dollar ($) sign style to Dirhams (Dhs.) sign style
    By Bohemianzzrek in forum Excel General
    Replies: 2
    Last Post: 04-03-2006, 07:30 PM
  4. Spreadsheet Style
    By philc in forum Excel General
    Replies: 2
    Last Post: 10-20-2005, 10:05 AM
  5. How to delete a style?
    By serdar in forum Excel General
    Replies: 3
    Last Post: 08-27-2005, 10:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1