Wednesday, November 5, 2008

Polymorphism work

I have recently started to study polymorphism more. My goal is to continue to improve my ability to think in Java. For example, with polymorphism if you have a cascading series of if statements which is meant to branch out like a case/switch statement and call the different methods that basically do the same type of things, you probably should refactor it to take advantage of polymorphism. I read the following article and it helped me create a solution to such a refactoring problem which was fresh and useful: http://www.javaworld.com/javaworld/javatips/jw-javatip30.html

I hope you find this example useful also. The syntax of this person's examples is not perfect, but the concepts are there, and there are enough parts of the example to put together some refactoring of your own as I described above.

No comments: