Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. A tour of Liferay APIs > Organizing larger applications

10.2. Organizing larger applications

After all the discussions we’ve had about frameworks, one thing should be clear: MVC is usually the design pattern of choice for web applications. And as you’ve seen, Liferay uses MVC internally—with Struts at its core—and also provides its own MVC framework for portlet applications. One thing that’s cool about Struts and other MVC frameworks is the ability to move individual actions into separate classes. If you didn’t have this ability and you had a large, complex application, all your actions would have to be in your portlet class, resulting in a single, large Java file containing many methods. When you have something like this in an application, it can be difficult for other developers to follow the application’s logic. For this reason, it’s a good idea to break up larger applications into smaller components that are easier to follow, especially if other developers need to get up to speed on your code. One way to do this is to split your actions out into separate classes. This makes a large application that has a lot of actions much easier to follow.

A matter of preference

Some developers like breaking functionality out into multiple components; some don’t. I was once tasked with providing an enhancement to an application that was written by somebody else. Along the way, I also refactored some of the code to break it into smaller parts, because I found it hard to follow the way it was written. Later, I heard that the original developer wasn’t pleased with what I had done.

I still maintain that I made the application easier for other developers to understand. But maybe it would’ve been better to ask first.



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial