Coding

I just started my second week at a new job (yes, things have been a bit quiet around here as I’ve been adapting), and the strangest thing has been happening. It’s really a very good thing that I don’t have Excel at home, because I don’t want to stop working at the end of the day. Weird, I know.

What’s going on? I’m coding again. I’m coding for the first time since that Pascal class in college that assumed I had a whole bunch of background knowledge on the structure of programming languages that I didn’t have. Let me just say that any programming course–with no prerequisites–that takes a student who was doing side projects in high school Basic and leaves them wondering what everyone is talking about is poorly designed.

Luckily, programming classes have mostly improved since then. So has my knowledge of programming language structures. I didn’t study it in between. I’ve just been in the middle of enough discussions about bad code to figure out what kind of mistakes people can make. Knowing what can go wrong is a great way of understanding how things should go right.

Still, I was a little worried. I expected more headaches as I moved from heavy Excel use, only sometimes adapting existing macros for my needs, to creating macros from scratch in VBA as a way to automate processes for my new company.

Nope.

As it turns out, knowing how to manipulate just about any kind of data in Excel means I already create data algorithms that work in VBA. Having picked up programming language structures by osmosis means I know what sorts of commands I’m looking for when I want to translate those algorithms into code. Plus I know most of the “shortcuts” VBA takes by using Excel’s built-in abilities.

On my third day, I solved a problem that had been stumping the local “VBA guru”. Now, I’m not going to tell you it was because I’m already that good at VBA. In fact, I learned a lot looking at his code, turned around and immediately changed something I had just written to use his more elegant, faster method.

I do, however, know dates. I know how to add, compare, increment, and round them in just about any way imaginable, because someone has not only imagined it, but used it to hang decisions on. Then I had to make sure a spreadsheet could handle the calculation. It turns out that this knowledge is critical to getting macros to handle dates properly.

Now, two business days later, I want to go back and streamline that macro, though. There’s duplication that’s just begging for mistakes if have to edit it again. Also, I want to play more with calling subs. Still, learning about proper error handling comes first. Userforms aren’t much good if they can’t recover from someone entering the wrong kind of data.

Have I mentioned that my dialog boxes are pretty? None of that off-center, non-aligned crap for me. Also, I’ve been doing this for a week, and I’m prompting for user-defined variables. My code is properly indented and thoroughly commented too.

I’m not gloating, really. I’m just tickled to have my skills and experience come together in a way that’s as useful as this is. I’m thrilled to have the framework on which to hang so much new knowledge so quickly. And it’s so, so nice to be coding again. It’s nice to have it verified that I hit bad pedagogy in college, not a wall.

But that’s enough of that. Time to go crash so I can do more, more, more of this tomorrow. We’ll see how long VBA manages to satisfy me.

{advertisement}
Coding
{advertisement}

14 thoughts on “Coding

  1. 4

    My code is properly indented and thoroughly commented too.

    As a professional programmer that last bit warms my heart. Coding is the easy part of being a programmer, knowledge of the domain you are working in the intermediate (and it seems you have that in spades), the hard part is documentation. So I’m happy there is at least one more person out there who makes work of documentation.

  2. 6

    Neat. πŸ™‚

    Of course, there’s the One True Indenting Styleβ„’: Tabs for indenting (one per indent level), spaces for alignment. Others disagree, but they are wrong. πŸ˜›

    I always hate when people don’t consistently indent and mix styles. Trailing white-space at the end of lines is really annoying too. I blame IDEs: they often don’t properly show white-space, and even “auto-format” things in weird ways.

  3. 7

    Have I mentioned that my dialog boxes are pretty? None of that off-center, non-aligned crap for me. Also, I’ve been doing this for a week, and I’m prompting for user-defined variables. My code is properly indented and thoroughly commented too.

    I could cry tears of joy at this. Properly commented and indented code is a joy to work on (I’ll often re-indent code that isn’t done properly because it’s nearly impossible to figure out quickly what is where).

    Good luck πŸ™‚

  4. 8

    “Thoroughly commented”?!

    If it was hard to write, it should be hard to read. You’ll never become indispensable if you leave the learning curve too flat for those who might think about replacing you.

    Don’t forget to re-write a boatload of library functions, giving them weird names and non-traditional parameters. For example, take the good old SUM() function, call it AddEmUp(), and have it return the total as a hex string.

  5. 9

    Cool, glad the job is going well… As to VBA and Excel, yuk, for me anyway, I never got into it. But Google Spreadsheets! Oh yes, very cool to pull in data from online sources, parse and manipulate in the online spreadsheet and share as a web app. All using JavaScript as well, with a Sheets API, so much nicer than VBA (IMO). Check it out if you have time πŸ™‚

  6. 11

    My code is properly indented and thoroughly commented too.

    To echo Dave W , you’re doing it all wrong!!

    Other tips: use abbreviations heavily when naming functions, while simultaneously making them incredibly long don’t use camelCase or underscore_notation, and be sure variable names are not descriptive. For example:


    // Wrote this to do something. Probably while drunk.
    function myfunct2wrtsmthg4gmyblg(int thisisanumber, String thisisastring) returns Something

    is best practice.

Comments are closed.