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.

Comments

Popular posts from this blog

How to identify a skilled programmer during an interview

How does one identify a skilled programmer?  No company that has interviewed me could tell the difference between myself and other programmers they'd interview.  The interview process is truly a game of luck in this industry--on both sides.  Both the programmer and the company are basing their actions entirely on luck.

Companies have come up with numerous methods to attempt to discern a good programmer from a bad one.  The best tricks they have include a series of math problems, algorithms, problem solving technique tests, and even obscure programming questions, some without definitive answers.  As an example: Is there an authoritative source of information on the core principles that define object oriented programming?  I've heard everywhere from 3 to 7.  In a field of research about a synthetic concept, an authoritative answer is almost impossible to obtain.

Programmers were then forced to study to the interview.  Careercup is one of my favorite sites for this.  This almost …

Dependency Injection - You're doing it wrong!

So I have worked at a lot of places and seen a lot of different styles of programming.  Early on in my career, I became acquainted with the concept of dependency injection.  It was a hard topic to grasp, but I have learned understand it deeply.  Now, when I step into a new application that uses it, I can very quickly see the flaws in the implementation, and there's a common one I want to talk about today: global singletons.  But we'll get to that in a minute.

What is Dependency Injection?
Dependency Injection is exactly what it sounds like.  You use it to inject your dependencies. The unique part about Dependency Injection though, is that you can do this at runtime.  Now this sounds fancier than it is.  By inject we don't mean they're downloaded for you.  You still have to have all of the parts installed where you want to run your app.

Dependency Injection is somewhat of a complicated topic to a newbie.  Let's start with defining the word dependency here.  Specific…

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…