Skip to main content

Work Smarter, Not Harder

So a few weeks back, I checked in over 600 files worth of code in one day, and it occurred to me that that was a lot.  Why so much?  I was reorganizing code that was scattered about one large project into multiple projects so that it would build as libraries and so that there was some semblance of sanity to the location of things like objects and methods.

I know that I'm a fast programmer, but I think other people believe that I spend all day at the keyboard sweating trying to get that much code in, and that simply isn't true.  So here's my tips on how to work smarter, not harder, and get a lot of code on the books.

I should note that all of these screen shots I'll be presenting were taken during the actual exercise of cleaning and reorganizing code.  These are not "examples" or "samples" but actual code in a real environment.  The things I'm showing here are the actual things I did in the course of building the 600 files that I checked in.

Use your IDE

I cannot emphasize the value of an Integrated Development Environment.  In the examples I'll be giving you, I'll be using Visual Studio, but there are dozens of spectacular IDEs with very similar features out there.  Using your IDE is not just a matter of understanding the text editor.  You need to explore plugins, learn the shortcut keys, try out different features, and ultimately figure out what makes you most efficient.  Yes, the learning period for an IDE is extensive (took me about 3 months to learn VS) but the payoff is worth it.  For example, in Visual Studio, the shortcut Ctrl + . is a quick way to add using statements when your cursor is on a class name that has not been imported into the file you're working on.

Learn Regular Expressions

Don't be fooled by jokes about RegEx.  Regular Expressions save my butt every day.  During my 600 file change day, I updated about 80% of the files with 2 Regular Expressions, saving myself a ton of time.  No, I absolutely do not advise you to live by them, but the rule applies with everything.  Use the right tool for the right job.  In the case of RegEx, we're talking about a jackhammer.  It can seriously dig through the crap for you, as long as you don't try and use it on a porcelain vase.

Read Documentation

In this case, I'm referring to MSDN, and how you can quickly find the assembly for a strange class so you can reference it, but the same thing applies to all documentation.  It's extremely easy to find things in the documentation if you know how to read it.  And the only way to get used to reading it is to read a lot of it, so read your documentation.

Read The (Build) Errors

Build errors aren't the only kind, but chances are your IDE is constantly presenting you with error information about your code.  Read it, and learn how to read it quickly and identify the important information.  It can save you a ton of time to know how to read a stack trace, or even just memorizing common error messages and their causes.  Below, notice how I've highlighted an example error message that is a result of other errors (the library didn't build, so the other libraries that depend on it couldn't find it) and then an example of an actual error that was part of the source problem (missing a reference).

Build Everything

Visual Studio has a feature called "Rebuild" which deletes everything in the directories before running "Build".  Most developers use "Build" because it's faster, and only builds files that VS is aware of changes to.  Most of the IDEs (well, the build commands because most IDEs are only wrappers for build commands) have configuration settings or something to define this same concept.  I always recommend taking the longer, delete first, approach to building software, because the IDE is stupid, and I once spent 6 hours debugging a project only to find that an artifact had been left behind in the build directory and was causing everything to break.  Never again, I said.  I mean it, the extra 30 seconds for a full delete and rebuild are worth it to avoid debugging hassles and serious strangeness.

Save All

This is a simple one.  Visual Studio, Eclipse, Android Studio, and heck even most text editors have a feature to Save All instead of just Save.  This saves all the file you've made changes to.  This is particularly useful if you change a ton of files at once with, for example, a regular expression.  Use Save All to save large sets of changes.

Use Search

There are literally hundreds of search features built into most IDEs.  In fact, there are even search Plugins you can download to enhance the search capabilities of your IDE.  The search box is literally thousands of times more efficient than trying to scan the code with your eyes.  Ctrl + F will save your career.  Use the search to find anything and everything, and if your IDE has fancy quick search features, all the better!  Master them!

Simplify it

The reason I made all these code changes in the first place was because the code I was looking at was basically unreadable.  Nothing pointed directly at anything.  Objects and methods were mishmashed into horrifying blobs of spaghetti code.  I couldn't find anything.  This is why code quality matters.  Taking the time to clean up code, or at least break what you're working on into small bite-sized chunks makes the extremely complex logic that is programming manageable, and even nightmarish spaghetti-code can be enjoyable.

If you guys have an other great tips, drop them in the comments.
Happy Coding.


Popular posts from this blog

Teams and Complexity

Let's pretend you're a car mechanic (I don't know, maybe you are).  But you don't work at some shop in town, you work at a bigtime auto-maker onsite at the factory.  You help build cars from scratch.  You work with a lot of other car mechanics, and various engineers of different levels.  If we were looking at the 1910s, you might be working for Henry Ford on one of the first ever assembly lines.  Either way, you have a specific part of the car you're responsible for.  Your skills probably extend beyond that, and you might work on a different part of the car each day as your manager moves you around to keep the factory efficient.

One of your coworkers, Bob, is a superb engineer.  He is very good at building cars, far better than you, and he does it faster than everyone else.  Your boss really likes him.  You often get stuck after him in the assembly line, so you know exactly what sorts of things he does.  He's not sloppy, but he likes to do things his way.  He w…

Managing Programmers

Working with other programmers is tricky.  That said, it's nothing compared to the job of managing programmers.  One of my favorite quotes about Perl is that (paraphrased) "a Perl developer is like a rockstar.  Now imaging having a bunch of rockstars in one room together and you will understand why you don't want an entire team of Perl developers."  It's not about Perl here though. What's important to understand is that any developer worth his salt is going to be like a rockstar.  And yes, there are a lot of professional developers out there who aren't worth their salt, but that's for another post another day.  Rockstar may not be the right term here, but think of it this way.  These guys are smart.  They may not be geniuses, but there's going to be things that they know that you don't and probably never will.

I've seen it more than once and it's not going to make some Product Managers happy, but I'm going to state a fact, an eleph…

Managing Developers is HARD

I've been a software dev for a long time.  I've also been running my own software company for a few years now.  This is important information because of why I do these things.  I am a sofware developer because I love learning.  I slack off when doing a job that bores me, and software development always has something new to experience which keeps me excited and interested.  Why start a software company then?  That puts me in the role of manager rather than developer.  The truth is simple.  I've worked for a lot of companies, and I don't see any of them doing a great job of managing their software development.  That's not to say none of them have done a good job, but no one out there seems to be doing a great job.

How are they different?
A lot of companies get this part right.  Software developers are different from other employees.  The distinction is important in the same way it's important to acknowledge that an insurance agent is different from a construction…