Hiding change behind an Interface
The powers that be (my manager and above) decided that instead of the week I had to write the code for my program that they are only going to give me 3 days. I explained that to do this is going to mean that I am going to have to hard code a lot of stuff and rather than extend the current code, it is going to be a one off and not very reusable piece of code instead.
Well the customer is desperate, they want it now.
So we have had to drop everything and work full steam a head on this project. What makes this extra interesting for me is that I am going to have to go there and install and run it this Thursday as well. It's going to be an interesting day to say the least, the code is going to have minimal testing and hardly any other than my development environment.
Still it's quite exciting all this rushing around in the code and there is nothing like a looming deadline to motivate you.
My plan was the first draft, e.g. maximum hard coding and then once that is working then I am going to try and link it up to some XML files so they can change some of the variables and allow a bit of flexibility.
I have been coding it so that although there is hard coding, I have put the hard coding inside a class which generates the variables needed. In some ways it's a bit like a mock object. I have also hidden this behind an interface. Hopefully once I get to try and read it off the XML files I can just add a different set of data behind the interface and all the rest of the code will work just the same.
I am still learning how, when and where to use interfaces. Sometimes I struggle to think where should I use an interface because they are so easily added in with no benefit. I was surprised in the end how useful the interface is going to be. Actually I wouldn't say surprised by pleased how well the interface is going to work in this scenario. It also high lights the power of the interface and it's ability to hide change, to create flex points in the code where you can literally hide different varieties of classes behind the interface.
Interfaces are quite an unusual beast, I don't feel Sun's tutorials and most books actually describe what interfaces purpose are very well. Granted they write very clearly how they work but I felt they never told you the why of interfaces. It has only since I have been reading some design patterns and Object Orientated articles that I have realised their real value and purpose.
Anyway the race is on for me to get the coding done by Wednesday evening, well it's not a race as such it's code as much as I can and then I'm taking out to the customer on Thursday, Rock and roll.
Well the customer is desperate, they want it now.
So we have had to drop everything and work full steam a head on this project. What makes this extra interesting for me is that I am going to have to go there and install and run it this Thursday as well. It's going to be an interesting day to say the least, the code is going to have minimal testing and hardly any other than my development environment.
Still it's quite exciting all this rushing around in the code and there is nothing like a looming deadline to motivate you.
My plan was the first draft, e.g. maximum hard coding and then once that is working then I am going to try and link it up to some XML files so they can change some of the variables and allow a bit of flexibility.
I have been coding it so that although there is hard coding, I have put the hard coding inside a class which generates the variables needed. In some ways it's a bit like a mock object. I have also hidden this behind an interface. Hopefully once I get to try and read it off the XML files I can just add a different set of data behind the interface and all the rest of the code will work just the same.
I am still learning how, when and where to use interfaces. Sometimes I struggle to think where should I use an interface because they are so easily added in with no benefit. I was surprised in the end how useful the interface is going to be. Actually I wouldn't say surprised by pleased how well the interface is going to work in this scenario. It also high lights the power of the interface and it's ability to hide change, to create flex points in the code where you can literally hide different varieties of classes behind the interface.
Interfaces are quite an unusual beast, I don't feel Sun's tutorials and most books actually describe what interfaces purpose are very well. Granted they write very clearly how they work but I felt they never told you the why of interfaces. It has only since I have been reading some design patterns and Object Orientated articles that I have realised their real value and purpose.
Anyway the race is on for me to get the coding done by Wednesday evening, well it's not a race as such it's code as much as I can and then I'm taking out to the customer on Thursday, Rock and roll.
0 Comments:
Post a Comment
<< Home