This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is good design ?  RSS feed

 
YuenLian Wu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I am currently designing Java Web application using servlet and Jsp. The Jsp will trigger Servlet by action, and the Servlet will determinate will jsp it will forward to. Here is the code:

if (action.equals("add")) {
..do Something
}
else if ( action.equals("addConfirm") )

}
else if ( action.equals("addConfirmed") )

}


My company is currently using that design. HOwever, do you guys thinK it's a good design ? It will definitely consume certain time to execute the if else clause. I am thinking may be I should just call different Servlets from the form action to reduce the complexity of the Servlet class.

Myriad Thanks,

Transistor
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a difference between the design ideal and what you have to do to get your work done. In my mind, if something works, doesn't max out memory or cpu, and isn't a pain to maintain, it is Good Enough.
Of course it is always a Good Thing to hand the design and maintainance to someone else. It looks like you are reimplementing Struts. Give it a look and it may save you some work.
 
Paul Clapham
Sheriff
Posts: 22505
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't say that an if-else clause by itself constitutes a bad design.

If the three "do something" code sections are completely unrelated to each other, then that might be bad design. But if they are just variations, or this code is followed by some common code, then it might be good design.
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

There seems to be a similar discussion going on over here

http://www.coderanch.com/t/202687/Performance/java/Selecting-code-without-switch

Check it out.

Br
Rahul
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!