This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: Separate generating content from printing it out
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
I am currently working on a legacy application that has a lot of the following:
show_article()
show_article() goes out, grabs the article (based on some evil global variables ;) and prints it out as it goes.
This makes it bloody hard to test, and *really* hard to cache. To handle scalability I may want to get that article and save the HTML to disk for use later, or grab the article object and put it in a distributed cache, or ....
The fact that most of the methods in this application do not return strings, but rather just go ahead and print to STDOUT makes life a real nightmare.
This is one of the pros of Velocity vs. JSP. Why can't we create a JSP engine, setup bindings, execute, and get back a string? Then we could even use JSP outside of the web scope (e.g. to generate emails).