aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Alternative to Strategy Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Alternative to Strategy Pattern" Watch "Alternative to Strategy Pattern" New topic
Author

Alternative to Strategy Pattern

Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi All,

I am trying to apply OO principles in some of the project that I am working right now.
But I am not sure if this is correct.

For some readings on the net about OO principles, I always see that 'You should encapsulate what varies'.

I try to apply it in what I am working right and its about how to draw the UI of my apps.

Say, I notice that the way UI are being drawn is what varies in my apps so I created this interface.



and in my Concrete class I have an instance variable referring to this.



Now, I have this class implements the transaction



Now, I am a bit confused about the instantiation of the class. Dont you think, my hierarchy is not good? Because I need to hard code the class to be instantiated and I cannot protect this class from further change.

I am not sure, but I think what I am doing is what they call as Strategy Pattern. Though I have not done much reading about design patterns.
I think this class is still volatile to change. Could you comment on this?


Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
ramesh maredu
Ranch Hand

Joined: Mar 15, 2008
Posts: 210

The only issue I could see here is creating the instance of concrete class should be moved outside, I guess you can use factory pattern.


SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Alternative to Strategy Pattern