Old dog new tricks?
You can teach an old dog new tricks.
I am on the process of going live with a rather interesting project. Yes in the process, the project will only be fully live in about a month. Don't ask!! Real life sometimes gets in the way of technology projects. Basically the project serves as an abstraction layer between two third party systems (later more external systems). Loads of integration which of course means loads of interesting problems. So I thought I would just make a note of a couple of things I (being the old dog) learned during the project. More for myself but it might prove usefull to someone else.
Unit tests will save you when you need it most
Yes I realise it is obvious, but once again this point becomes very real when you make a last minute change at the end of the day and suddenly tests start failing. So spend time writing those unit tests and do them properly. And keep on writing those tests even if you think the piece of functionality could never fail. It might never fail, but the functionality will change and without unit tests the change will become more difficult. Write unit tests for failure scenarios. Write a test to simulate a database failure. Write a test to test a network failure. Those scenarios will happen so be prepared.
Write end to end tests. Call it integration tests, call it acceptance test, call it whatever just write it and use it
You know those tests testing a scenario from start to finish in an environment as close as possible to the live environment in which the system under test will run. Your unit tests might all pass but it does not mean all the scenarios are working as expected once the system is running hot (I always wanted to say that!!). These tests will surface any integration issues between the modules in your system, integration with external systems and integration with the infrastructure around your system. These tests are also great to test failure scenarios. It goes without saying these tests need to be automated.
Distributed system fallacies are not fictitious
The distributed systems fallacies (http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing) we all have read and all agreed with is real! Shock! Horror! It is easy to read something and agree in principle to what you are reading. But when it happens in your system you are surprised. And then the light bulb goes on and all the reading you have done around distributed systems suddenly makes a lot of sense. So read those fallacies again and look at your code and decide and implement the functionality to negate the assumptions.
Stay close to someone with a good understanding of the business
This person is invaluable during the development process. They have the answer. They have the correct answer. They understand the business side of the project because they work in the business process every day. So use their knowledge to the advantage of the project, with their contribution the project has a huge chance of being a success.
Automate everything
Be the laziest developer you could possibly be or more politely put, automate those tedious jobs and spend your time focusing on the difficult (and fun) parts of the project. This includes automated builds, automated tests and automated deployment scripts. But it also includes simple things like scripts/macros/snippets to generate boiler plate code for you. If your unit tests all have the same structure (which I would imagine they do), why not use a script/macro/snippet to generate a new unit test class? It will take you about 10 minutes to set up and save you about 1 minute when writing the first unit test class. But when you have 500 unit test class that little script/macro/snippet will save you 500 minutes. That is 8 hours. That is a full day. The other great thing about automation scripts/macros/snippets are that they are not temperamental, they will always behave in the same manner. This property is great when the stress is on and you have sufficient trust (after you have spent time doing it properly) in your automation. The script/macro/snippet can be run and it will work and that leaves you to focus on other things.
Measure and monitor you system
How else will you know whether you system is stable and will survive the onslaught that will come in the live environment? How will you know if you system is surviving out there in the big bad live enviroment? Build operational functionality into your system from day one of the development. And keep adding monitoring information to the system as a whole through out the development process. It does not have to be complex but focus on operational information that will make the support of your system easier. It could even feed into your team's dashboard.
Log, log, log and just to be sure log a bit more
Use your logging framework to it's full potential and use the functionality to the benefit of the system, but more importantly to make the support of the system easier. This means logging useful information which will assist the support of the system. Don't log rubbish. Log answers to questions which the support developer will ask when troubleshooting the system. And don't be afraid to update and add more logging to the system. The extra logging is a feature of the system, maybe not a tangible feature, but if it makes the support of the system easier it's worth will become very clear.
If something can go wrong it will go wrong
This applies to both the system under your control and any system your system integrates with. So be prepared for it and take proactive steps to handle failures in your system and failures occuring in the external systems. This might sound obvious but how often does a system fail and no one is quite sure why the system failed? The inevitable hunt through log files can be a royal pain and often just proves the lack of useful logging. A way to be prepared for the failures is to make testing part of the development process and not leave the testing to the end of the project. So write those unit and integration tests and continue writing the tests. And test for failures in both your unit and integration tests.
As a whole the project has been hugely enjoyable and a lot of lessons were (re)learnt.
