?
Solved

Wether to keep url params in method parameters or fetch it inside the method

Posted on 2016-08-11
4
Medium Priority
?
73 Views
Last Modified: 2016-08-13
HI,
I have a function like :
 
@RequestMapping(value = "")
    public ModelAndView newNote(@RequestParam(value = "noteEvent", required = false) String noteEvent, HttpServletResponse response, HttpServletRequest request) throws IOException {
        String token = request.getParameter("token");

Open in new window

The noteEvent is actually a json param like : { "name":"sdfsdf","button":"sdfds","userId":"u:guid1","sdfdf":"sdfds","chat":"u:sdf","chatName":"Ben sdf"}

1) Once approach is i put everything in the params... Like here i am accessing request.getParameter("token")
which i could move to method params.. But somtimes i have noticed the function param list gets too large.

2) Other approach is to not put anything in params and access everything inside.

3) Or mix match

Need views from experts. What approach you follow and when ...Whats best to do ?

Thanks
0
Comment
Question by:Rohit Bajaj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Expert Comment

by:gurpsbassi
ID: 41753606
Is this a GET request?
0
 

Author Comment

by:Rohit Bajaj
ID: 41753641
yes this is a get request
0
 
LVL 36

Accepted Solution

by:
mccarl earned 1600 total points
ID: 41753679
Personally, I would probably just put them all as method parameters, but I don't have much of a problem with methods that have numerous parameters, I know some people do though.

The other possibility that I might consider, if you have some params that are required and some that are optional, is to leave the required ones in the method and attempt to retrieve the optional ones if/when needed.
0
 
LVL 16

Assisted Solution

by:gurpsbassi
gurpsbassi earned 400 total points
ID: 41754138
if you were to flatten that JSON object into request params, it wouldn't be so bas as mccarl suggested. Its only a handful.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This video teaches viewers about errors in exception handling.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question