This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes web application design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "web application design" Watch "web application design" New topic
Author

web application design

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 236
Hi there,

I wanted to pose a basic question as to what is a best approach when designing a web application. Case in point for a scholastic application:

1) thirty students login to their accounts and try to access the same information.
2) in doing so, they all call the same servlet which in turn calls a class named "StudentModel" and a method named getStudentList() which would return a 2D String array of data.
3) the getStudentList() method retrieves from a database the list of all the students in the school

Is it better to make the method getStudentList() a static method so that the servlet calls it directly as in:
String[][] data = StringStudentModel.getStudentList()?

Or is it better to make the method non-static, in which case, the servlet would have to make an instance of the class StudentModel thirty times?

What are your thoughts, pros vs cons?

Alan
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

Making the method static because of an anticipated performance issue is folly. Please look up the term "premature optimization".

Design according to established OO principles, and then if (and only if) performance issues raise their head, use profiling tools to locate actual bottlenecks.
[ July 23, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web application design
 
Similar Threads
multi-dimesional arrays
287 Pre-assessment test questions - Please answer
How make true Singleton, even if loaded by Class.forName?
Is JAX-WS method ArrayList
how integrate MySQL and Tomcat