Adam Caudill

Security Leader, Researcher, Developer, Writer, & Photographer

Glue & Reuse

This post was imported from an old blog archive, and predates the creation of AdamCaudill.com.

On an average day, I take about 10 screenshots, and upload them to my FTP server. Now, this is easy enough, but it does take a minute, let’s break down the process:

  • Press Alt+PrtScr.
  • Go to the start menu, and use the “Run” command to open mspaint.
  • Paste (and crop if needed).
  • Save the image.
  • Find the image.
  • Open FTP program and upload the file.

Now, while that’s not hard, doing it a dozen times a day is annoying. So I decided to find a better way, or in this case, build a better way. Here’s what I set out to build:

  • Simple hotkey to do everything.
  • Automatically save the image.
  • Automatically upload to my FTP server.
  • Require no user intervention other than pressing the hotkey.

So, I built something to solve the problem.

At this point I’m sure you are wonder what this has to do with anything, well my friend, I’m about to explain. One of the core concepts of OOP is code reuse, designing code to be reused in many applications. This is a key to efficiency, but is often something overlooked when starting a project.

With this small project I faced two choices, I could glue, or I could start from scratch. Starting from scratch does give a better understanding of both the quality and the exact functionality of the code. Though this extra knowledge and experience does come at a price: development time. By doing it all yourself tends to draw out development time significantly.

Facing those choices, I opted to go the sticky route, and glue together existing components and code to build this little tool. Finding pre-made classes (that were very well developed) made the tasks of FTP’ing the file, and capturing and saving the screenshots simple. Two lines of code and the most important parts are done.

Careful reuse of existing code made this project trivial, taking only half an hour to finish (and most of that was in making the “toast” popup). Whenever you have the chance, look at how you can reuse code to save yourself some time. It’s often worth it.

Adam Caudill