Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm in an anti-pattern and I want to get out

I am developing a java webapp, using jsp/jquery/ejb/jboss.

I have a web-form that enables the user to select any combination of 100 fields (all from different unrelated tables/objects) from the database. These fields are then output, via a java servlet, to an excel spreadsheet. A stored procedure is executed that always returns all 100 fields.

The web-form sets 100 boolean values in a transfer object(TO) to determine whether data should be then be displayed. This TO is then referenced to produce the title row of the spreadsheet and also for each row from database which is iterated over.

It all works fine, however it feels wrong. I cannot think of a viable way which does not reference 100 booleans (N+1 times) to determine whether a field should be included in the outputted spreadsheet. When I say viable I mean, for example, that I don't want to rewrite stored procedure or create 100 different stored procedures.

like image 812
NimChimpsky Avatar asked Aug 11 '10 14:08

NimChimpsky


People also ask

What is considered an anti-pattern?

Wikipedia defines the term “Anti-pattern” as follows: “An anti-pattern is a common response to a recurring problem that is usually ineffective and risks being highly counterproductive.”

Is anti-pattern good?

Anti-patterns are considered bad software design, and are usually ineffective or obscure fixes. They generally also add "technical debt" - which is code you have to come back and fix properly later.

What is the difference between a pattern and an anti-pattern?

An anti-pattern is the evil twin of a good design pattern. A good design pattern is a reusable requirement, design, or implementation that solves hard problems in a standard way, which is well designed, well documented, easy to maintain, and easy to extend.


1 Answers

Our solution was in similar situations to create a dynamic Transfer Object. Basically, it was a Map instead of a POJO having a number of getters and setters.

The codes which fills and reads this transfer object were simple iterations.

like image 146
pcjuzer Avatar answered Sep 19 '22 22:09

pcjuzer