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.
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.”
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With