I work in a very hostile environment/company (which I am a junior dev in), and of course, if you do some coding, it goes live, and there is an error, your job is on the line.
In this company (and all others I have worked in), I have never had any dedicated testing tools available. We have no source control, test servers, bug tracking, etc., yet we have completed large scale development for clients.
How can I ensure that my code, however small, will work in all environments? I already don't leave anything to chance and try to build in redundancies and backup plans. Eg if for whatever reason I decide to log errors by email, I know this means I am putting all my eggs in the basket of "the internet must be live" and it could easily not be, and if so, no logging will happen and if someone says there was an error, I have no proof and "his word against mine" doesn't work for me as I am junior. So everything has to be logged, which incurs a performance and storage penalty of course.
What techniques can I apply to ensure my code will work in different environments? This doesn't apply to browser compatibility, just with things like winform apps and making sure I can write to the event log on every machine.
I am doing the backup/redundancy idea (eg if I can't log to mail, log to local file), as well as logging everything, and not hard coding system values which vary from machine to machine.
At home I have things like unit testing tools, Exception Hunter, all sorts of stuff, to help me. At work I don't.
I am interested in C# techniques to help with this (the language I use at work and generally my primary skill) and general programming techniques. I haven't found much on this on Google.
Also, is it a bad technique if I log to email and in my catch method, if that fails, I log to file? (so I have a plan if one method doesn't work). It seems I should make the performance/technical sacrifice to cover my back.
Thanks
This sounds like a nightmare. I've worked at places where there was no source control, people made changes on the fly to live systems, and where I've had to definitively prove that my code wasn't the problem. But our jobs weren't on the line if someone screwed something up. Just so long as it didn't happen too often.
That's probably because one of the senior developers was the worst offenders. His favorite trick was to have shell scripts calling shell scripts calling shell scripts and explicitly redirecting stdout and stderr to /dev/null, sometimes 2 and 3 layers deep.
Then there was the time he "verified a customer's backup" at their request by making sure the job was running from cron rather than actually reading data from the tape. Of course the tape was bad - and he'd redirected stderr to /dev/null. When the customer lost a hard drive and 5 years of historical data 2 months later, I got to lead the effort of scanning in and OCRing their printed records to rebuild something resembling a database. They promoted the other guy. I quit not long after.
Which brings me back to your situation.
Good luck. As another commenter put it: we've all been there.
Set up source control for yourself, if nothing else.
If it were me, I'd go further: I'd install Trac & Subversion on my dev machine, and use it. If others start to wonder how I managed to track down the exact change that introduced a bug, etc, I'd point them at the URL. Let it grow virally.
But it sounds like you need to find a better place to work.
(Disclosure: I'm one of the Trac devs, so I'm biased.)
I work in a very hostile environment/company (which I am a junior dev in), and of course, if you do some coding, it goes live, and there is an error, you're job is on the line.
Been there, done that. How many people have you seen actually fired because they had a bug in their code?
In this company (and all others I have worked in), I have never had any dedicated testing tools available. We have no source control, test servers, bug tracking, etc
Therein lies the problem.
What techniques can I apply to ensure my code will work in different environments?
You can't. You can have a bank of machines (or virtual images) with various configurations to check against. But it doesn't sound like your work environment is conducive to that. If you just want logging capability, that should be a given.
I am interested in C# techniques to help with this (the language I use at work and generally my primary skill) and general programming techniques.
While I admire your dedication, that's like making a doctor build their own stethoscope, when it's much more cost-effective and safer to buy one.
Unfortunately, your organization will probably not make the changes they need to do it correctly, and you can't do it all yourself. Pay your dues there for a few years, learn all of the right tools, and then find a better place to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With