The Artima Developer Community
Sponsored Link

Java Buzz Forum
Hiding change behind an Interface

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ben Hosking

Posts: 208
Nickname: hoskinator
Registered: Apr, 2006

Ben Hosking is Java Developer with about 5 years experience and interest in OO
Hiding change behind an Interface Posted: May 23, 2006 6:32 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ben Hosking.
Original Post: Hiding change behind an Interface
Feed Title: A Funny Java Flavoured Look at the World
Feed URL: http://businesslogs.com/WebLog/RSS.xml
Feed Description: The blog looks at using Java and programming in general as it pops up in life as a Java programmer. It will have links to interesting Java articles and resources. It will also have a lot of SCJP Java 1.5 information and links as I am currently studying
Latest Java Buzz Posts
Latest Java Buzz Posts by Ben Hosking
Latest Posts From A Funny Java Flavoured Look at the World

Advertisement

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 and who says being a programmer is boring.

Read: Hiding change behind an Interface

Topic: Google Trends: Struts vs JSF Previous Topic   Next Topic Topic: Tom Wheeler Wins The 2006 NetBeans Community Award

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use