Grails Key Considerations on NFR
Grails Key Considerations on NFR
Join the DZone community and get the full member experience.Join For Free
Atomist automates your software deliver experience. It's how modern teams deliver modern software.
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
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.
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.
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?.
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
SummaryGrails’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
Opinions expressed by DZone contributors are their own.