Re: core struts -- best practise fundementals
peru cheppanu wrote: Thanks for replying me. The basic idea is knowing the need for tag libraries.. for which the explanation was given as reusability. In my opinion, the purpose of tags, besides reusability (after all, plain objects and methods are reusable and easier to implement), is rendering the JSPs more readable and understandable by programmers more familiar with HTML. But this is true not only if assuming that one working with the JSPs is "java challenged". And to demonstrate this I suggest the following experiment. Take a JSP (say medium sized) and make 2 versions of it: one using the logic tags and the other using java scriptlets instead (the replacement should be straightforward). Then compare the 2 versions - the more readable one should be obvious. :-) Now, coming to specific example I have given: I agree that it should not be a part of logic: library. But, I think one such tag (substring) is useful in some cases. Why not prepare the data in the form required by the view before getting there? Usually doing so in a custom tag requires for more intermediary steps to be done. And, as already suggested, maybe someone out there already made such a "handy tools" tag library that has one custom tag which does substring. Say I need to populate a 40 * 10 table with two variables in each cell. I will need a object array of size 400 with two parameters in it. ( I can have Hashmap if I have identical keys, but say thats not the case either). Instead I can have 400 String objects sent with some delimeter. I will save lot of object instantiations and substring the ones with two params. What do you think? I think that in the end, by doing substring in the jsp, you'll have even more objects created for each cell: the original string with the delimiter and two strings representing your needed values after extracting them. Remember that String is immutable and .substring() creates a new one when you call it on an instance. If all you have to do with each the values pairs is showing it in a table cell, why don't you just concatenate the values using a space as separator and then just display the string in the cell? Anyway... this kind of potential problems solving should be left aside initially when you design and develop your application. Otherwise it could really prevent you on concentrating on the business logic and model and postponing your delivery date. This kind of performance problems should only be addressed at the end, **if** they really show up as performance bottlenecks. You could be surprised by how fast java is... ;-) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: core struts -- best practise fundementals
Thanks [EMAIL PROTECTED] wrote: On Tue, 2005-08-30 at 13:06 -0700, peru cheppanu wrote: > Thanks a lot Craig. That cleared up a lot. > > For the rest of 1%, I better put my question straight to the case. > > I want to display two properties on 40*10 cell table. I have these options. > 1. use a hashmap that contains 400 values. Or have four with 100 each so that > I can have identical keys. > 2. use a String that has 400 values (still have to substring on jsp) > 3. use a custom object that has two parameters, there are 400 object > instantiations in aciton class. Put this one in ActionForm. This table is > just a part of the entire display thing. > > What do you think is the best route to take? I feel that custom object thing > goes with the logic. But, I am afraid of performance. As said in the previous reply, and in many discussions and articles about programming - at this level of application programming (i.e. you are not writing some real-time multi- gigabyte network driver for a rocket launcher on a gunship) worry about performance when it hits you. Go for the "custom object" as you call it and see what you get. --Amos - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: core struts -- best practise fundementals
On Tue, 2005-08-30 at 13:06 -0700, peru cheppanu wrote: > Thanks a lot Craig. That cleared up a lot. > > For the rest of 1%, I better put my question straight to the case. > > I want to display two properties on 40*10 cell table. I have these options. > 1. use a hashmap that contains 400 values. Or have four with 100 each so that > I can have identical keys. > 2. use a String that has 400 values (still have to substring on jsp) > 3. use a custom object that has two parameters, there are 400 object > instantiations in aciton class. Put this one in ActionForm. This table is > just a part of the entire display thing. > > What do you think is the best route to take? I feel that custom object thing > goes with the logic. But, I am afraid of performance. As said in the previous reply, and in many discussions and articles about programming - at this level of application programming (i.e. you are not writing some real-time multi- gigabyte network driver for a rocket launcher on a gunship) worry about performance when it hits you. Go for the "custom object" as you call it and see what you get. --Amos - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: core struts -- best practise fundementals
Thanks a lot Craig. That cleared up a lot. For the rest of 1%, I better put my question straight to the case. I want to display two properties on 40*10 cell table. I have these options. 1. use a hashmap that contains 400 values. Or have four with 100 each so that I can have identical keys. 2. use a String that has 400 values (still have to substring on jsp) 3. use a custom object that has two parameters, there are 400 object instantiations in aciton class. Put this one in ActionForm. This table is just a part of the entire display thing. What do you think is the best route to take? I feel that custom object thing goes with the logic. But, I am afraid of performance. Thanks again. Craig McClanahan <[EMAIL PROTECTED]> wrote: On 8/30/05, peru cheppanu wrote: > > Thanks for replying me. > > The basic idea is knowing the need for tag libraries.. for which the > explanation was given as reusability. > > Now, coming to specific example I have given: > > I agree that it should not be a part of logic: library. But, I think one > such tag (substring) is useful in some cases. > > Say I need to populate a 40 * 10 table with two variables in each cell. I > will need a object array of size 400 with two parameters in it. ( I can have > Hashmap if I have identical keys, but say thats not the case either). > Instead I can have 400 String objects sent with some delimeter. I will save > lot of object instantiations and substring the ones with two params. What do > you think? Quite frankly, I think this particular case is worrying about the wrong problem entirely. The focus during app development should be on creating simple logic that gets the job done, and is easy to modify later because it is clearly structured. *Only* if you have performance issues related to CPU time on the middle tier where your servlet container is running will issues like object instantiations versus substringing matter -- and, even if that matters, I doubt that one solution will be particularly better than the other, because both have tradeoffs. But, you should really be focusing on figuring out what makes for a clean, understandable architecture for the entire app, and how to make sure that, over the long term, it can be maintained and enhanced. And, I would focus on writing logic that is relevant to your application, rather than infrastructure things like new tags, until you can demonstrate a need for reusable code that can't easily be met without extending the underlying framework. (And, even there, I would look for other tag libraries *before* trying to invent my own ... do not be limited in thinking that you can't combine tag libraries from multiple sources in a Struts app. Your value to your company is the unique knowledge you have about *your* application requirements. Craig McClanahan Radu Badita wrote: > > Although the previous two answers are basically correct, I don't think > they really contain the response to Peru's initial question. I hope that > the "elders" of this list will clarify things a bit for him. :-) > I considered that I'd better avoid responding myself to this, as one > that sometime ago was asking (myself and others) why should using the > or be better than using the equivalent > java code - which was also faster for me to do than learning the new > tags > Still... In this specific case, maybe the answer is not writing a whole > new custom tag at all. It wouldn't be very efficient anyway, especially > if the "parsing" mentioned is done in one or two particular places only. > It might show that maybe a model layer does not exist for the > application, and maybe the data is directly retrieved from a (probably > legacy) database. (Forgive me if I'm wrong.) At least that parsing could > be done in the Action that prepares the view, and the data stored in a > form that is easier to display. > Even if you will still chose to use a custom tag for that, attaching it > to the struts standard "logic" taglib wouldn't be a good choice ( if > that was what you meant by a tag used as > > ) > > Radu > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > Start your day with Yahoo! - make it your home page > __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: core struts -- best practise fundementals
On 8/30/05, peru cheppanu <[EMAIL PROTECTED]> wrote: > > Thanks for replying me. > > The basic idea is knowing the need for tag libraries.. for which the > explanation was given as reusability. > > Now, coming to specific example I have given: > > I agree that it should not be a part of logic: library. But, I think one > such tag (substring) is useful in some cases. > > Say I need to populate a 40 * 10 table with two variables in each cell. I > will need a object array of size 400 with two parameters in it. ( I can have > Hashmap if I have identical keys, but say thats not the case either). > Instead I can have 400 String objects sent with some delimeter. I will save > lot of object instantiations and substring the ones with two params. What do > you think? Quite frankly, I think this particular case is worrying about the wrong problem entirely. The focus during app development should be on creating simple logic that gets the job done, and is easy to modify later because it is clearly structured. *Only* if you have performance issues related to CPU time on the middle tier where your servlet container is running will issues like object instantiations versus substringing matter -- and, even if that matters, I doubt that one solution will be particularly better than the other, because both have tradeoffs. But, you should really be focusing on figuring out what makes for a clean, understandable architecture for the entire app, and how to make sure that, over the long term, it can be maintained and enhanced. And, I would focus on writing logic that is relevant to your application, rather than infrastructure things like new tags, until you can demonstrate a need for reusable code that can't easily be met without extending the underlying framework. (And, even there, I would look for other tag libraries *before* trying to invent my own ... do not be limited in thinking that you can't combine tag libraries from multiple sources in a Struts app. Your value to your company is the unique knowledge you have about *your* application requirements. Craig McClanahan Radu Badita <[EMAIL PROTECTED]> wrote: > > Although the previous two answers are basically correct, I don't think > they really contain the response to Peru's initial question. I hope that > the "elders" of this list will clarify things a bit for him. :-) > I considered that I'd better avoid responding myself to this, as one > that sometime ago was asking (myself and others) why should using the > or be better than using the equivalent > java code - which was also faster for me to do than learning the new > tags > Still... In this specific case, maybe the answer is not writing a whole > new custom tag at all. It wouldn't be very efficient anyway, especially > if the "parsing" mentioned is done in one or two particular places only. > It might show that maybe a model layer does not exist for the > application, and maybe the data is directly retrieved from a (probably > legacy) database. (Forgive me if I'm wrong.) At least that parsing could > be done in the Action that prepares the view, and the data stored in a > form that is easier to display. > Even if you will still chose to use a custom tag for that, attaching it > to the struts standard "logic" taglib wouldn't be a good choice ( if > that was what you meant by a tag used as > > ) > > Radu > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > Start your day with Yahoo! - make it your home page >
Re: core struts -- best practise fundementals
Thanks for replying me. The basic idea is knowing the need for tag libraries.. for which the explanation was given as reusability. Now, coming to specific example I have given: I agree that it should not be a part of logic: library. But, I think one such tag (substring) is useful in some cases. Say I need to populate a 40 * 10 table with two variables in each cell. I will need a object array of size 400 with two parameters in it. ( I can have Hashmap if I have identical keys, but say thats not the case either). Instead I can have 400 String objects sent with some delimeter. I will save lot of object instantiations and substring the ones with two params. What do you think? Radu Badita <[EMAIL PROTECTED]> wrote: Although the previous two answers are basically correct, I don't think they really contain the response to Peru's initial question. I hope that the "elders" of this list will clarify things a bit for him. :-) I considered that I'd better avoid responding myself to this, as one that sometime ago was asking (myself and others) why should using the or be better than using the equivalent java code - which was also faster for me to do than learning the new tags Still... In this specific case, maybe the answer is not writing a whole new custom tag at all. It wouldn't be very efficient anyway, especially if the "parsing" mentioned is done in one or two particular places only. It might show that maybe a model layer does not exist for the application, and maybe the data is directly retrieved from a (probably legacy) database. (Forgive me if I'm wrong.) At least that parsing could be done in the Action that prepares the view, and the data stored in a form that is easier to display. Even if you will still chose to use a custom tag for that, attaching it to the struts standard "logic" taglib wouldn't be a good choice ( if that was what you meant by a tag used as ) Radu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Start your day with Yahoo! - make it your home page
Re: core struts -- best practise fundementals
Although the previous two answers are basically correct, I don't think they really contain the response to Peru's initial question. I hope that the "elders" of this list will clarify things a bit for him. :-) I considered that I'd better avoid responding myself to this, as one that sometime ago was asking (myself and others) why should using the or be better than using the equivalent java code - which was also faster for me to do than learning the new tags Still... In this specific case, maybe the answer is not writing a whole new custom tag at all. It wouldn't be very efficient anyway, especially if the "parsing" mentioned is done in one or two particular places only. It might show that maybe a model layer does not exist for the application, and maybe the data is directly retrieved from a (probably legacy) database. (Forgive me if I'm wrong.) At least that parsing could be done in the Action that prepares the view, and the data stored in a form that is easier to display. Even if you will still chose to use a custom tag for that, attaching it to the struts standard "logic" taglib wouldn't be a good choice ( if that was what you meant by a tag used as ) Radu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: core struts -- best practise fundementals
For the most part you are correct. However, it is a little more straight forward than that. Logic should be wrappered in a logic object. The Tag Library can bridge the presentation to this generic logic. This is so that the generic logic can be used universally from either a presentation screen or from another logic object that needs the same functionallity. This is good practice because it allows you to write the code once and reuse it in many places. This saves on memory, Maintenance time, Development time, etc. The reason you want to extract presentation from logic, is because many companies rebrand themselves often on the internet. New look and feel keeps thing nice and fresh, but is a nightmare if you have to rewrite your applications just to take on a new layout. Additionally, after a site is released, you often find the users do not use the application as you expected during development. By rearranging the screen layout and application flow, you can make the users more productive and generally happier. If you tie your logic to your screen this becomes much more complex. The key to any object oriented language is to develop small compartmentalized objects. These objects should focus on just the functionallity it needs to complete its task. A fell defined set of interfaces should handle getting the information to and from the little back box. This is where Struts, Taglibraries, JSF, etc come into play. peru cheppanu <[EMAIL PROTECTED]> peru cheppanu <[EMAIL PROTECTED]> 08/29/2005 12:41 PM Please respond to "Struts Users Mailing List" To user@struts.apache.org cc Subject core struts -- best practise fundementals Hi all, I am trying to understand the motivation behind seperation of logic and presentation in struts framework. I was wondering if any of you can provide some light if I am thinking in right direction. Now, if you write scriptlets in JSP, that is a bad practice.., however if you hide that functionality in a tag class and implement that tag like struts tags or any other tags.. thats a good practice. For example, I want to send a concatenated string instead of a hashmap to display as per key-value relationship. I meant send "[EMAIL PROTECTED]" string rather than a hashmap and want to parse it for display. If I write a scriptlet that I use to substring and display only that user is concerned with -- that is bad practice. If I use a tag lib that looks more like , --> good. Am I getting this whole thing wrong? Pls excuse if I sound too stupid and this is my first post here.. --Ashrita - Yahoo! Mail for Mobile Take Yahoo! Mail with you! Check email on your mobile phone.
RE: core struts -- best practise fundementals
The tag library allows reuse whereas scriptlets lead to copy/paste oriented programming ;-). Separation of concerns is one of the main principles of OOAD. It allows you to change the logic and presentation layer objects independent of each other. It is easier to develop, maintain and extend a system that conforms to this principle. Bala -Original Message- From: peru cheppanu [mailto:[EMAIL PROTECTED] Sent: Monday, August 29, 2005 12:42 PM To: user@struts.apache.org Subject: core struts -- best practise fundementals Hi all, I am trying to understand the motivation behind seperation of logic and presentation in struts framework. I was wondering if any of you can provide some light if I am thinking in right direction. Now, if you write scriptlets in JSP, that is a bad practice.., however if you hide that functionality in a tag class and implement that tag like struts tags or any other tags.. thats a good practice. For example, I want to send a concatenated string instead of a hashmap to display as per key-value relationship. I meant send "[EMAIL PROTECTED]" string rather than a hashmap and want to parse it for display. If I write a scriptlet that I use to substring and display only that user is concerned with -- that is bad practice. If I use a tag lib that looks more like , --> good. Am I getting this whole thing wrong? Pls excuse if I sound too stupid and this is my first post here.. --Ashrita - Yahoo! Mail for Mobile Take Yahoo! Mail with you! Check email on your mobile phone. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
core struts -- best practise fundementals
Hi all, I am trying to understand the motivation behind seperation of logic and presentation in struts framework. I was wondering if any of you can provide some light if I am thinking in right direction. Now, if you write scriptlets in JSP, that is a bad practice.., however if you hide that functionality in a tag class and implement that tag like struts tags or any other tags.. thats a good practice. For example, I want to send a concatenated string instead of a hashmap to display as per key-value relationship. I meant send "[EMAIL PROTECTED]" string rather than a hashmap and want to parse it for display. If I write a scriptlet that I use to substring and display only that user is concerned with -- that is bad practice. If I use a tag lib that looks more like , --> good. Am I getting this whole thing wrong? Pls excuse if I sound too stupid and this is my first post here.. --Ashrita - Yahoo! Mail for Mobile Take Yahoo! Mail with you! Check email on your mobile phone.