In the Zen Zone

I was reading a blog the other day about Zen Coding and it really just bummed me out. Zen Coding is a very real thing. You all know what I’m talking about, even if you don’t realize it. It’s when you’re just in it, completely in it. It’s when you don’t exist anymore, you’re in the zone and there’s just the code, nothing else. There’s just the code and you make the computer dance. You bend it to your whim and will. It’s the most beautiful thing that can happen to a programmer… and I have not had that experience in a very long time now.

What’s worse than not being able to experience the bliss of letting myself go, of losing myself in the meaningless lines of text in front of me that I give meaning to, is not understanding why I can’t find that place. It’s utterly frustrating. If I did not know this state of mind, this Zen Coding, I would not care. However I do know it and this knowledge is a burden, but rather than whine and bemoan my sad state of affairs, I would prefer to explore why this state of zen has eluded me. Perhaps more so, I want to explore how I can attain it more often.

The biggest road block to finding the zazen of programming is distraction. When the phone rings or someone comes into your office, you have just been kicked out of the zone. It will take you longer to figure out where you were than it will take to deal with the interruption. These kinds of distractions can not be stopped and they are hands down my worst nightmare. It’s never just one either. These distractions come in packs. One phone call takes you away to deal with an emergency, then just as you’re finishing up that one, the phone will ring again. To medigate the damage from this you must finish your current thought. Whatever it is, it can wait 30-60 seconds for you to wrap up your immediate thought. You’ll thank yourself later for having one less “what the fuck?” to cope with when trying to get back to what you were working on six hours ago.

Interruptions aren’t the only distraction though, oh no. Email is a huge culprit too. If you can, only check your mail a few times a day. Don’t jump to every little thing. They emailed you. They don’t expect an immediate response, so don’t give them one at the sacrifice of your concentration and focus. While you’re at it, turn off those “oh so helpful” desktop notifications. They catch your eye and take your mind away from the task at hand. The longer you spend consecutively focused on your task, the easier it will be to slip into Zen Coding.

What is the real problem though? Why is it so hard to just get in the zone? I have one word for you, stress. Fear is the mind killer and stress is its asshole cousin. In order to be productive, stress must be removed from the equation. Stress will scatter your mind like dandelion seeds in the wind. Do whatever you have to do to reduce and eliminate stress from your workday. Five minutes doing push-ups, or simply walking away from your desk, will buy you twice that time back. I promise.

There’s one more trap that I know I fall into far too often. I’m not enjoying myself. In order to be productive and happy, you must be enjoying yourself. There is no other way to be one with you code, but to want to be. Sometimes this means putting off a new feature and fixing that crap you wrote six months ago. You know the code I’m talking about. You wrote it in a hurry, or just didn’t really know what you were doing yet. It sits in your code base like a giant stinking turd taunting you every chance it gets. There’s never time to fix it, so it stays there just festering and driving you crazy. I’m telling you, take the time to polish that turd into something you’re proud of. The next thing you know, you’ll have refactored half of your code base because cleaning up that one method or class slipped you into zen mode. You’ve gotten your mojo back and each new change and feature will be that much easier to implement. You owe it to yourself. It will be cathartic. Just do it. Trust me on this one.

Deep Copy or Clone an ADODB recordset in VBA

Christopher J. McClellan:

Make a deep copy of an ADODB Recordset the easy way; use a stream.

Originally posted on VBA 4 all:

Inspired by this post on SO.

Problem description:

I have been searching for a way of duplicating or copying a recordset in VBA. And by that I mean, having the undelying data independent of each other.

I have tried

Set copyRS = origRS.Clone
Set copyRS = origRS

When I use any of the methods I cant modify one recordset without modifying the other. So in this example:

  1. I create a recordset
  2. I populate the recordset with the name John
  3. I clone the recordset
  4. I modify the cloned one
  5. Check result

But unfortunately for me, this modifies both recordsets

My question is:

Is there a way of copying a recordset from another recordset and then modify the data independently of each other (without looping)?

I know that evidently you can do it through a loop, but is there no other way?

I usually get away with creating an

View original 105 more words

I’ve been slacking…

about writing here at least. In reality, it’s been a really busy summer. In between work, trips to the zoo, horse riding camps, volunteering some time at Code Review SE and (oh, yeah) getting ready for our wedding, I’ve not had much time to think about this blog. Which is okay, but I did promise myself I would write something at least once a month.

It’s important to me that I keep that promise to myself. Most Programmers think that their most important skill is the ability to write clear and concise code. I would challenge that. We should generalize that and work on being able to write clearly and concisely whether we’re writing in C#, VB, or English. If we can’t communicate with the business, we will not be effective programmers. If we can’t communicate with each other, we will not be effective programmers. If we can’t communicate with the non-programmers in our lives, we will not be effective human beings.

I know I’ve been absent for a while, but I kept my promise. I’ve accomplished a goal and I feel better for it.

Until next time, Semper Cogitet.

Very Cool Writer/Reader Library

I found this native vba file input/output library over at the CodeReview Stack Exchange site. I thought you all might appreciate taking a look at it.

If you’ve not been to SE’s code review beta, you should really check it out. The people are ubër friendly and there’s a lot to be learned by letting someone else dissect your code. It makes you really stop and think about what you’re doing with every line of code you type.

Until next time…
Semper Cogitet.

Metaprogramming In VBA

Metaprogramming In VBA

I came across an interesting question over at StackOverflow this morning. I thought you all might be interested as well. While I truly don’t recommend running code stored in a spreadsheet, the VBIDE library does allow for more efficient development by writing “snippets” and metaprogramming. Perhaps I’ll do a more in depth write up in the future.

The Last Mile – Why Good Enough Isn’t

A few weeks ago I was talking to a particularly good friend of mine. We somehow got on the topic of “good enough” and how it just isn’t. Let me preface this with “I’m guilty”, and I truly am. There’s no way for me to say this without sounding condescending, so please believe me that I don’t mean it to be arrogant. My “good enough” tends to be better than average. This has allowed me to more or less skate through life and let me tell you something, I have not done nearly enough.

Oh sure. I’ve done pretty well. I have a good career, a great family, and the best friends a guy could ask for, but what have I done? The truth is I’ve done a lot, but not nearly as much as I could. Why is this? Because I, like you, am lazy. Of course I’m lazy. I didn’t intentionally become a programmer. I became one because I was lazy. I understood that if I put the effort in up front to build a piece of software to do it for me, I would never have to waste another second doing it by hand again. That’s also the only reason my good enough is better than average. I’m lazy, but I recognize that it’s a better investment to do some extra work up front in order to reduce the overall amount of effort over time. Continue reading

VBA ODBC DSN Installer

One of the most common questions we come across as MS Access developers is “How do I make sure every user can access the database?”. Often, and with good reason, a DSN-less connection is the way to go. However, DSN-less connections aren’t for every situation in Access. Sometimes they’re clunky, or some functionality of Access just doesn’t work with a DSN-less connection. I suspect this is because Access was designed specifically to use linked tables, which use a DSN by nature.

I ran across this problem a little while back. While I can’t remember exactly what it was that just wouldn’t work no matter what I tried, I did need a fairly robust solution for manipulating the Domain System Names via VBA. Not only did I need to install them, I needed to fix them when they weren’t set up correctly. So, for my case, a *.reg file just wouldn’t do. I had to code this. Continue reading