This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Need suggestions on complete refactoring of my web app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Need suggestions on complete refactoring of my web app" Watch "Need suggestions on complete refactoring of my web app" New topic
Author

Need suggestions on complete refactoring of my web app

Matteo Di Furia
Ranch Hand

Joined: Jun 20, 2008
Posts: 102
Hello ranchers,
I'm seriously thinking about a complete refactoring of my web application, which is now implemented with just servlets and jsp, with the addition of business classes to perform database operations and some utility functions. I think about it because the application has grown quite a bit since its beginning and chaos is growing with it. I'd like to find a solution to this problem, although I know that it will be a long and tedious job.
So, this time I'd like to apply the so called best-practices and, of course, I'd like to take advantage of the many frameworks around to make my web app more compliant to the de-facto standards (this way, if someday someone will work on it on my behalf, he might have a chance to understand something about it).

I'm thinking about Hibernate for DB layer and Stripes as main web app framework.
And here comes my problems.
1) I'm using iBatis at office, so I know how to use it, but I've also read that Hibernate is more powerfull and more complete than iBatis. But, on the other hand, I don't know Hibernate, so I'd like to read your opinion about it, to understand if I might be better to study it or if I should avoid it.
2) I also use Spring + WebFlow + Tiles at office, but reading the Stripes documentation it seems to me you can do with it what we do with the combination of 3 different frameworks. So, what do you think about it ? Which is better in your opinion (I know that "better" has little to no sense when comparing different frameworks, just leave your two cents about this argument).
3) I've also had a look at portlets and portal frameworks (especially Liferay). What about them ? They seems quite powerfull, my main doubt is that I need maximum customization on the layout and contents of the site, and I don't know how far I could go with it. Could you share any experience about it ?

I think I'm too much confused about all these, I just would like to choose the best solutions since they all need a bit of studying to get them started.
Thank you in advance.

Matteo
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

As this is more about frameworks than Servlets, I've moved it to a more appropriate location.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Frederic Daoud
author
Ranch Hand

Joined: May 22, 2008
Posts: 71
Matteo Di Furia wrote:
1) I'm using iBatis at office, so I know how to use it, but I've also read that Hibernate is more powerfull and more complete than iBatis. But, on the other hand, I don't know Hibernate, so I'd like to read your opinion about it, to understand if I might be better to study it or if I should avoid it.


If you are already using iBatis, I don't see why you'd need to switch to Hibernate, especially if your SQL is good and if you have several complex, well-designed SQL queries and so on. On the other hand, if you have a ton of SQL "boilerplate" that is just mapping between Java properties and SQL table columns (which really should not be the case if you are using iBatis properly, or rather, MyBatis), then perhaps switching to Hibernate would reduce this boilerplate code.

Matteo Di Furia wrote:
2) I also use Spring + WebFlow + Tiles at office, but reading the Stripes documentation it seems to me you can do with it what we do with the combination of 3 different frameworks. So, what do you think about it ? Which is better in your opinion (I know that "better" has little to no sense when comparing different frameworks, just leave your two cents about this argument).


Indeed, you can achieve with Stripes what you are doing with SpringMVC+WebFlow+Tiles, with less code and less configuration. Stripes is easy to learn and use, and gives you a lot of bang for your development effort buck.

Hope that helps. Wish you good success with your project.


Frederic Daoud
Author, Stripes...and Java Web Development is Fun Again
Stripes book
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

While I'm a HUGE fan of Stripes and I 100% agree with Freddy here, you might also consider looking at Grails if a re-write is at all being considered. It uses Spring + Sitemesh + Hibernate but it is all neatly tucked away behind some Groovy love. For example, consider the following...

grails create-app TestApp

cd TestApp

grails create-domain-class com.test.User

Editing the User.groovy...


That is 100% all you need to do and this is what you get automatically.



And I could go on and on. Note that I didn't have to touch a single Hibernate file, XML, nothing. This is all out of the box. Again, Stripes is GREAT and it is really easy to migrate an existing app over gradually because it can sit next to anything else.


GenRocket - Experts at Building Test Data
Matteo Di Furia
Ranch Hand

Joined: Jun 20, 2008
Posts: 102
Hi Frederic and Gregg,
I'll answer at both of you.
First of all, I'm using iBatis at work, but I'm thinking about an ORM tool for a personal project I'm developing.
What I can't get, and I discussed with a colleague about this, is what do you actually benefit from using such tools ? I mean, of course you don't have to manage by hand the persistence business and you get facilities to handle transaction and connection issues, but on the other hand you have to manage a very lot of configuration files and/or properties, along with the conversion from your model to the one generated by IBatis/Hibernate. Both these tasks must be done by hand (correct me if I'm wrong), so you're actually moving a lot of work from the classes that actually perform database operations to the files the configure them (and to converters!). I'm missing the point.
But this is another discussion that maybe should be opened in a separate topic of its own.
I was just asking what would you use between i(My)Batis and Hibernate if you were to start a project from scratch and considering you know something about iBatis but you know Hibernate is more powerfull.

@Gregg : indeed what you wrote about Groovy is impressive. But I'm always sceptical about those tools that generate so much code starting from few lines. Again, the effort you have to pay when it comes to personalize the result of such code generation (and you always need to tune or adjust something in real applications) is nearly equal to the time spent by making everything by your own (of course, using the right frameworks).
In the example I made, Spring + Webflow + Tiles let you do everything and they're great, of course, but you really have to configure everything in a lot of XML files. Stripes, on the other hand, works with just some add to the web.xml and some little more. But it's not so difficult to extend and to personalize Stripes to fit it to your needs.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Matteo,

You're going through a very similar process that I went through several years ago. Skepticism is a good thing. I'll never convince you just by typing words here. The best thing you can do is download the tools and give them a go yourself.

Again, the effort you have to pay when it comes to personalize the result of such code generation (and you always need to tune or adjust something in real applications) is nearly equal to the time spent by making everything by your own (of course, using the right frameworks).


You're exactly right! Which is why I don't use Grails to generate code. Let me clear here with a few things here:

1) grails create-app TestApp - This does the same thing you do when you create a new application. It gathers JAR files. Creates a project structure. Stubs in some configuration. That's it. There's no real magic here. It's just taking what you would normally do by hand or, God forbid, with Maven, and does it for you. Nothing scary here.

2) grails create-domain-class com.test.User - All this does is create an empty User.groovy class and an empty UserTest.groovy. If you want, you can manaually create User.groovy yourself without the grails command. I do this quite often. Nothing is happening with that command that you can't reproduce yourself by simply creating the class manually.

3) All the GORM stuff - So this is where you could have reason for more concern. Understand that with core Grails and it's ORM layer there are no annotations required, no XML files required, and zero configuration required for 80% of the work you need to do. All those query examples are called Dynamic Finders. They are dynamic because they are simply in-memory methods that get called (there some nifty caching stuff that happens to keep method lookups quicker, but that is beyond the scope of this topic). There's quite a bit of groovy love happening behind the scenes to make those work. That said, it saves *you* from having to wire it all up. It's already wired up for you. And since Grails is a child project of SpringSource, you can breathe easy that it's done the right way (99% at least).

Stripes, on the other hand, works with just some add to the web.xml and some little more. But it's not so difficult to extend and to personalize Stripes to fit it to your needs.


Indeed, Stripes is awesome because of this. And if you want to roll your own ORM layer Stripes can't be beat. Again, I'd recommend giving both a go. Try Stripes for a simple project. Try Grails. Pick the one that fits your development style better. There is no ONE solution here.
Matteo Di Furia
Ranch Hand

Joined: Jun 20, 2008
Posts: 102
Thanks Gregg,
I understand your point and I'm happy, at least, that mine are not the doubts of a fool ("what !? who are you to have doubts about Hibernate and such tools?!").
I think I'll take my time to test each framework and see which one is the best for me. It's my own project anyway, made in my free time, so I guess I can take all the time I need ;)

Regards.
 
 
subject: Need suggestions on complete refactoring of my web app