Automate everything

I am a huge fan of automation. If I repeat something more than one time, I find this task a candidat

I'm a huge fan of automation. I don't like repeating things and I don't like doing everything manually. Everything can be automated - code generation, deployments and migrations. You can script how your application is being built, how it is being packed and how to notify everyone interested in this fact. After few months of work it saves even days of your priceless time. You can hardly believe in that? Let's see(all below examples are real functionalities prepared for my side-project):

  • Using command line to generate modules or features in your application

Most applications are based on very simple CRUD modules, which allow users to manage the data. No one likes to write such code - just query the database, do some validation, return a success or an error. Such modules or features, developed by many devs, tend to evolve into some kind of "an-app-inside-an-app" - everyone uses different conventions, code is formatted differently, the very same functionalities are structured using different patterns. Even when you are creating an application on your own, you sometimes change your style and approach. To get rid of this problem I've created a simple command line tool, which creates whole feature structure using only given feature name(of course it generates both handlers for API and AngularJS controllers and factories). I think, it saves me about one hour of writing the same code all over again per each feature. I have around 20 features so far.

  • Generating AngularJS factories based on requests data using Fody

It's a similar feature to previous one but it extends it rather than overrides it. When I have my structure created, it is obvious, that in some point in the future, I will have to add something new to my features. Because requests, which are a part of my API, are also used by factories in AngularJS(at least in terms of URL structure/HTTP verb), I don't want to change something in my JS code each time server-side code changes. That's why I'm using Fody(or Mono.Cecil if you wish) to generate this kind of client-side code.

  • Notifying users about new deployment/delivery using EventStore

I wanted to notify each user about the fact, that a new version of the application has been delivered. Because I extensively use TeamCity and psake, I decided, that my build script should just send an event to EventStore, which will be processed and respective action will be taken. I don't think about it, it just happens.

  •  Packing and deploying application using TeamCity + psake

Although I haven't got Octopus yet, I really wanted to pack and deploy my application automatically. It's the biggest problem for most companies - automate your deployment/delivery process so human factor is minimized. I decided, that everything necessary can be zipped by psake and just deployed to the destination server. Because psake is basically PowerShell, I was able to shut down the old version of my application, deploy new version and start it much faster, than doing it manually. No mistake is possible.

  • Creating issues in YouTrack automatically when not handled exception occurs

This is something unusual, but I realized that it's a real pain in the ass. Working with your client can be difficult sometimes, especially when you're trying to get some details about error he or she mentioned. Yes, you have logs and some general idea what was the flow but sometimes, you need a whole context. You can implement audit of each operation performed in you application(and this is not a bad idea). I decided to do something more interesting from my point of view - to automatically report an issue in my YouTrack when a HTTP 500 error occurs. It saves my time, it saves my client's time and that makes him happy.

Personally I think, that automating things - in development, in your process, in management - is a great opportunity to try and test your ideas. Initially you have to invest some time in making all those things, but after few months, when you just write

--create -featureName=Foo

instead of writing boilerplate code again and again, you will now it was worth it.

Add comment