August 2010 - Posts

I was doing a task and I noticed that I was repeatedly deleting and renaming a folder in windows. I'm running a process that makes a backup of a folder and then do some update on an existing one. Whenever I wanted to restore the original (backed-up) folder, I would delete the existing one and rename the original.

I got a little tired and created a small batch file that would do this for me automatically. Here goes...

 

IF EXIST "SomeFolder-Backup" GOTO DELETEANDRENAME
EXIT
:DELETEANDRENAME
rmdir /S /Q "SomeFolder"
ren "SomeFolder-Backup" "SomeFolder"

"Save this as a .bat file"

What the above code does is it checks if the backup folder exists. If it doesn't then it would just exit the batch script. If it the backup folder exists then it removes the modified folder (SomeFolder) and then restores the backup folder. Hmmm...  I wish I could explain better. Anyway, if you're on the same situation then I'm sure you'll understand. If it does help, please drop a comment below!

 

Disclaimer: I will not be responsible for any damage done to your file system by running this script. Before using this simple script, make sure you understand what it does and what you want to do. Use at your own risk!

Posted by lamia | with no comments
Filed under:

Since I don't have any code to post, I decided to share more of my experiences regarding software development in general. This is base on real world experience. Sometimes, I tend to go on and proceed with solving the problem without doing sufficient analysis. I think my experience doing maintenance work has helped me mature and be more analytic towards solving problems.

 

1. Find out what's the problem - Find out what's the problem first is the fundamental question asked in Math in grade 1. It's like What is asked?

 

2. Find out where the problem lies - Secondly, when you've identified what the problem is try to find out where the problem is. There is a big chance that there is no problem at all and the problem might be the user. I'm just stating that as a possibility but of course there's always and higher chances that there is a problem with the software involved.

 

3. Find out What's causing the problem - In this step, you identify if the problem is being caused by a dead server, typo, logic error, etc.If it's a NullPointerException, where is the offending code and why is it causing a that? It's very tempting to conclude that such problem is caused  by a call to a null reference but it's more often more than that.

 

4. Research how to fix the problem - Once you know what's causing the problem, it's time to propose solutions. There can be many ways to approach a problem so it's good to identify your options. Then from that list of options, identify the best solution. It's always a good idea to ask other people for a second opinion.

 

5. Code the Solution - Finally,  you have decided on a solution it's time to code. However, before writing your first code it's always a good idea to write unit tests against them. Now, I feel a little guilty having discussed this because I tend to go lazy sometimes and just code straight away. It really totally depends on how much time you have but for maintenance work, I would suggest to write unit tests first. You will then know that your solution works such as when you put your changes the unit tests passes and when you take out your changes the unit test fails.

Posted by lamia | with no comments