java - How to refactor this code -


I am currently reapplying some old code I used here to instruct on the best design patterns I am searching. I'm thinking about the pattern of the factory, but I'm not sure whether this is the best way to go.

So here's a brief outline of the pseudo-horn, its main business argument in Class Foo.

  square fu {Private list & lt; Things & gt; Luggage; Private static integer count; // Doc. Setter {this.stuff = stuff; for content public fu (list & lt; items & gt; stuff); This.count = 1; } // The following 3 methods are: 90% equal public list & lt; Newthings & gt; DoSomeThingFirst () uses the // // catalog item and also increases static member count for each entry in the list & lt; NewThings & gt; } Public list on the basis of some situations & lt; Newthings & gt; DoSomethingSecond () uses the {// catalog stuff and lists & lt; NewThings & gt; Strengthen member count for each entry also increases. } Public list on the basis of some situations & lt; Newthings & gt; DoSomethingThird () {// list uses the list and list & lt; NewThings & gt; Strengthen member count for each entry also increases. Depending on some situations) // might happen in the future doSomethingFourth (), doSomethingFifth () ... etc) The class Fu collar looks something like the bottom class SomeServiceImpl {public list & lt; Things & gt; GetAllFoo (list & lt; things & gt; stuff) {map & lt; Integer, new things & gt; FooList = new hashmop & lt; Integer, nuitton & gt; (); Fu Fu = new fu (luggage); FooList.put (1, foo.doSomeThingFirst ()); FooList.put (2, foo.doSomeThingSecond ()); FooList.put (3, foo.doSomeThingThird ()); New Array List and Lieutenant; Things & gt; (FooList.values ​​()); }}  

Tell me how to retain and reuse this code should be re-implemented or is it OK?

Thanks for your input

Looks like the code> BUILDER pattern.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -