Nitin Kumar works as a Software Architect , predominately focus on Agile, TDD, Service Oriented Architecture, Grails and JEE. Besides working in software development, He writes technical articles and watch and study new technologies. He has been in IT for over 13 years and advocating on Craftsmanship, Domain driven development, TDD, Refactoring , Pair-Programming and lean development. He has expertise in high performance Java system and contributed to various open source projects. Nitin is a DZone MVB and is not an employee of DZone and has posted 13 posts at DZone. You can read more from them at their website. View Full User Profile

Grails Key Considerations on NFR

04.09.2013
| 4000 views |
  • submit to reddit

 Grails is an Open Source, full stack, web application framework for the JVM. It takes advantage of the Groovy programming language and convention over configuration to provide a productive and stream-lined development experience

Grails builds on several well-established software frameworks, and combines their functionality via Groovy. These frameworks include Java Enterprise Edition (Java EE, JEE), spring, Hibernate and Quartz. Grails combines the speed of scripting languages with the stability and security of Java and is therefore ideally suited for enterprise use.

This paper is aimed for the best practices on Non Functional Requirements

Layers Separations

Layered Architecture: Keep Enabling loose coupling and parallel development streams. Keep separate layer for domain logic and presentation logic. Keep domain logic to domain classes and presentation logic in controllers/views

Performance

Profiling:The best practice is to always profile your application to find out the bottleneck of your application and do the corrective action. e.g. P6Spy will give you good insight into your query timings. Apache JMeter will provide pretty good simulations of how your app will perform.

Disable Open Session: Always disable Open Session in production environment.  This could be bottleneck as it increases the number of concurrent requests that can be processed as each Hibernate session fetches a database connection.

Flash and sessions: Flash scope will increase the number of active session if many people hit flash-enables pages.

XML and JSON rendering: Try using alternative libraries such as Jackson for JSON for rendering JSON file.

Large Operation: Always use the service layer when there is a large operation to be done. Use scheduler for offline processes.

Inheritance: When evaluating your inheritance options, understand the potential performance cost of using a one-table-per-class strategy, and weigh that against the relaxed validation constraints required when using the one table-per-hierarchy approach.

Throughput

Use caching at the service and view layer via the Cache plugin.
Use Grails 2.x+ with Ehcache for 2nd level cache to avoid thread blocking.

Re-usability

Share Common: Share common domain/services that need to be shared into a plugin, and sharing that across your projects.  It will keep complexity low, while allowing you to reuse the shared code from one maintainable place.

Web Service: Expose your business logic as RESTful web services, which would be language agnostic.

Bundle common service together: For the service which needs to offer to other Grails application if we have a number of services we want to offer to other Grails applications, it then a good idea to bundle them in a separate project / grails app?.

Security

Access Rule: Apply to the access-control rules you set up. A framework like Spring Security can make it easy to add access control to an application.

Develop with security in mind: Remember that security is a process and a mindset. In order for your application to be secure, you have to consciously consider the potential effects of the code you write.

Use security tools: Use existing security tools such IBM APP scan the application and find vulnerabilities quickly.

Use the security framework: Use to get the right security framework to apply on your Grails application e.g. Spring security.

Security test: Make sure that the application isn’t susceptible to common types of attack by using functional tests and automated tools like OWASP’s Scarab.

Strive for perfection

Use Builders, proper plugins, Commands, Meta programming, whatever, to make your code shorter, more readable, groovier

Summary

Grails’s main target is to develop web application quickly and rapidly in agile manner. Here we focused some of the key consideration to handle Non Functional Requirements (NFRs) on Grails based development
Published at DZone with permission of Nitin Kumar, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)