﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-学历代表过去，能力代表现在，学习力代表未来！-文章分类-Groovy&amp;Grails</title><link>http://www.blogjava.net/ljc-java/category/49410.html</link><description>模仿中成长，在创新中成功！</description><language>zh-cn</language><lastBuildDate>Fri, 19 Aug 2011 06:58:11 GMT</lastBuildDate><pubDate>Fri, 19 Aug 2011 06:58:11 GMT</pubDate><ttl>60</ttl><item><title>给Grails开发者的10个建议(转载)</title><link>http://www.blogjava.net/ljc-java/articles/356844.html</link><dc:creator>小罗</dc:creator><author>小罗</author><pubDate>Fri, 19 Aug 2011 03:43:00 GMT</pubDate><guid>http://www.blogjava.net/ljc-java/articles/356844.html</guid><wfw:comment>http://www.blogjava.net/ljc-java/comments/356844.html</wfw:comment><comments>http://www.blogjava.net/ljc-java/articles/356844.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ljc-java/comments/commentRss/356844.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ljc-java/services/trackbacks/356844.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: Arial; font-size: 12px; line-height: 20px; background-color: #d2c0ac; "><p style="line-height: normal; ">from InfoQ &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://www.infoq.com/cn/news/2009/02/grails-10-tips&amp;usg=AFQjCNEsWTmWC5663oSojc52MAglwtQLpA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://www.infoq.com/cn/news/2009/02/grails-10-tips</a>&gt;</p><p style="line-height: normal; ">如果要列举近些年来Java领域中最令人激动的事件，Grails的诞生绝对应该榜上有名。在打开Grails官方网站&lt;<a href="http://www.google.com/url?sa=D&amp;q=http://www.grails.org/&amp;usg=AFQjCNGDWpJ4NLMjdlfi3rn5gAH-9HVdFA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://www.grails.org/</a>&gt;时，&nbsp;<br style="line-height: normal; " />你会在浏览器的标题栏上看到这样的内容：&#8220;Grails - 寻找就此结束&#8221;。虽然这句话不见得适用于所有场合，但对于不少从事Java&nbsp;<br style="line-height: normal; " />Web开发的人来说，赞同者恐怕不在少数。由于具备Rails风格的框架、兼容绝大多数Java语法的Groovy动态语言、以业界口碑良好的框架为基&nbsp;<br style="line-height: normal; " />础、对企业现有Java开发资产的保护、Plugin架构等特点，再加上Spring社区的强力介入，Grails行情看涨应该是意料之中的。</p><p style="line-height: normal; ">然而Grails却没有看上去那么简单，在其包装的糖衣之下，有着许多作为Java Web开发者不得不了解的知识。最近，Peter&nbsp;<br style="line-height: normal; " />Delahunty&lt;<a href="http://www.google.com/url?sa=D&amp;q=http://blog.peterdelahunty.com/&amp;usg=AFQjCNGHrDOa5hB7sxQOETdXuguatEdC1w" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://blog.peterdelahunty.com/</a>&gt;&nbsp;<br style="line-height: normal; " />发表了题为Grails开发者需要知道的10个技巧&lt;<a href="http://www.google.com/url?sa=D&amp;q=http://blog.peterdelahunty.com/2009/02/10-ten-tips-for-grails-developer.html&amp;usg=AFQjCNHHsmHmYWFT01458aI0rz8v8cVaHA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://blog.peterdelahunty.com/2009/02/10-ten-tips-for-grails-develop...</a>&gt;&nbsp;<br style="line-height: normal; " />的博文。不要被标题所迷惑了，这里所说的&#8220;技巧&#8221;可不是那些语言层面的&#8220;技巧&#8221;，把它们称为&#8220;建议&#8221;恐怕更合适一些。</p><p style="line-height: normal; ">技巧1：把Grails的书籍买来读读。对此，Peter Delahunty推荐了已出版的《Definitive Guide to Grails 2nd&nbsp;<br style="line-height: normal; " />edition》和《Groovy and Grails Recipes》，以及即将出版的《Grails in Action》。</p><p style="line-height: normal; ">技巧2：学习Groovy，并按照Groovy进行思考。Peter Delahunty通过一个例子说明了Java思维和Groovy思维的不同。</p><p style="line-height: normal; ">这儿有个好例子：</p><p style="line-height: normal; ">传播操作符（spread operator）：*</p><p style="line-height: normal; ">在Java中，要想遍历一组人并收集人名。我可能得这样写：</p><p style="line-height: normal; ">List names = new ArrayList();&nbsp;<br style="line-height: normal; " />for (Iterator iterator = people.iterator(); iterator.hasNext();) {&nbsp;<br style="line-height: normal; " />Person person = (Person) iterator.next();&nbsp;<br style="line-height: normal; " />names.add(person.getName());</p><div class="qt" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; display: block; ">}</div>System.out.println(names);&nbsp;<br style="line-height: normal; " /><p style="line-height: normal; ">用Groovy，我会这么写：</p><p style="line-height: normal; ">def names = people*.name&nbsp;<br style="line-height: normal; " />println names</p><p style="line-height: normal; ">呵呵，简单吧。我还可以这样写：</p><p style="line-height: normal; ">def names = people.collect {it.name}&nbsp;<br style="line-height: normal; " />println names</p><p style="line-height: normal; ">在这个建议中，他列举了一些资源：</p><p style="line-height: normal; ">- Groovy官方网站 &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://groovy.codehaus.org/&amp;usg=AFQjCNFVxAFH0a_xYOxU5FKLzdlZNY4FnA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://groovy.codehaus.org/</a>&gt;&nbsp;<br style="line-height: normal; " />- PLEAC &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://pleac.sourceforge.net/pleac_groovy/index.html&amp;usg=AFQjCNGplGB3sfqQAFSBjR4osyQgH8VS9Q" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://pleac.sourceforge.net/pleac_groovy/index.html</a>&gt;</p><p style="line-height: normal; ">以及一些书籍：</p><p style="line-height: normal; ">- Programming Groovy&nbsp;<br style="line-height: normal; " />- Groovy Recipies&nbsp;<br style="line-height: normal; " />- Groovy in action</p><p style="line-height: normal; ">技巧3：了解Grails的各个插件。Peter&nbsp;<br style="line-height: normal; " />Delahunty给出的理由：Grails本身是个插件系统，而且现在已经有大量的插件可供下载。在自行实现之前，不妨看看其中是否有称手的。</p><p style="line-height: normal; ">技巧4：学习Hibernate和Spring。这一点不难理解，既然Grails是建立在这些工具之上的，了解这些工具本身的使用，对于熟练使用Grails 自然大有脾益。</p><p style="line-height: normal; ">技巧5：使单元测试、集成测试和一般测试的自动化。Peter Delahunty在这里推荐了两个Grails的插件：Testing&nbsp;<br style="line-height: normal; " />Plugin&lt;<a href="http://www.google.com/url?sa=D&amp;q=http://www.grails.org/Testing%2BPlugin&amp;usg=AFQjCNGJl5dVQlu7O9s83HsWnF56oDgJHA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://www.grails.org/Testing+Plugin</a>&gt;&nbsp;<br style="line-height: normal; " />和Functional testing plugin&nbsp;<br style="line-height: normal; " />&lt;<a href="http://www.google.com/url?sa=D&amp;q=http://www.grails.org/Grails%2BFunctional%2BTesting&amp;usg=AFQjCNEcCQcRvNGJHPrSrKDxYPFSmRR6_g" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://www.grails.org/Grails+Functional+Testing</a>&gt;。前者将成为Grails&nbsp;<br style="line-height: normal; " />1.1的内置插件。</p><p style="line-height: normal; ">技巧6：使用好的IDE。Peter Delahunty表示，他自己使用的是Intellij，但对于Netbeans也寄予厚望。</p><p style="line-height: normal; ">技巧7：学习并使用HTML W3C标准。&#8220;遵循标准将消除你90%的问题&#8221;，Peter Delahunty如是说。</p><p style="line-height: normal; ">技巧8：看上去不错一定不错。这其实说的是&#8220;面子工程&#8221;，通过提高应用的外观设计来提高应用的竞争力。Peter Delahunty给出了2个资源：</p><p style="line-height: normal; ">- 99designs.com&nbsp;<br style="line-height: normal; " />- 圆角矩形产生器 &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://www.roundedcornr.com/&amp;usg=AFQjCNHUjanSWW-yywDgd1OShkPkyl8O0Q" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://www.roundedcornr.com/</a>&gt;</p><p style="line-height: normal; ">技巧9：使用Firefox上的Firebug。对于浏览器端的调试工作，Firebug绝对是一个必备工具。</p><p style="line-height: normal; ">技巧10：跟上Groovy和Grails社区的步伐。在这最后一个建议中，Peter&nbsp;<br style="line-height: normal; " />Delahunty给出了获取Groovy和Grails信息的主要资源链接：</p><p style="line-height: normal; ">- Grails官方网站 &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://www.grails.org/&amp;usg=AFQjCNGDWpJ4NLMjdlfi3rn5gAH-9HVdFA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://www.grails.org/</a>&gt;&nbsp;<br style="line-height: normal; " />- Groovy和Grails相关的博客 &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://groovyblogs.org/entries/recent&amp;usg=AFQjCNHRRqk-ta_6q_ebcJ8HmIybBp-mBA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://groovyblogs.org/entries/recent</a>&gt;&nbsp;<br style="line-height: normal; " />- Grails创始人Graeme Rocher的Twitter &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://twitter.com/graemerocher&amp;usg=AFQjCNHzMC7S837ttVx3GPOBY0SlwDdbdA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://twitter.com/graemerocher</a>&gt;&nbsp;<br style="line-height: normal; " />- Groovy项目领导人Guillaume Laforge的Twitter &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://twitter.com/glaforge&amp;usg=AFQjCNEM8evNtn5XZe3qxfJd8kpA_tMHTA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://twitter.com/glaforge</a>&gt;&nbsp;<br style="line-height: normal; " />- Groovyblogs.org的创始人Glen Smith &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://twitter.com/glen_a_smith&amp;usg=AFQjCNEoGy0AJlaWiBaJ-BKpQVhn4kpAmw" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://twitter.com/glen_a_smith</a>&gt;</p><p style="line-height: normal; ">请务必阅读Peter Delahunty的原文&lt;<a href="http://www.google.com/url?sa=D&amp;q=http://blog.peterdelahunty.com/2009/02/10-ten-tips-for-grails-developer.html&amp;usg=AFQjCNHHsmHmYWFT01458aI0rz8v8cVaHA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://blog.peterdelahunty.com/2009/02/10-ten-tips-for-grails-develop...</a>&gt;。对于Grails的新老使用者，你都可以从Peter&nbsp;<br style="line-height: normal; " />Delahunty的建议中有所收获。关于InfoQ中文站Groovy和Grails的其它内容，请访问这里&lt;<a href="http://www.google.com/url?sa=D&amp;q=http://www.infoq.com/cn/groovy&amp;usg=AFQjCNEnmj98ciMtu2jt6VdgJ5oKtqj5lA" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://www.infoq.com/cn/groovy</a>&gt;&nbsp;<br style="line-height: normal; " />和这里 &lt;<a href="http://www.google.com/url?sa=D&amp;q=http://www.infoq.com/cn/grails&amp;usg=AFQjCNHyCmVieZPR4E7f3NaBdXx54JU5bQ" rel="nofollow" target="_blank" style="font-size: 12px; color: #0000cc; text-decoration: none; line-height: 20px; font-family: Georgia; ">http://www.infoq.com/cn/grails</a>&gt;。</p></span><img src ="http://www.blogjava.net/ljc-java/aggbug/356844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ljc-java/" target="_blank">小罗</a> 2011-08-19 11:43 <a href="http://www.blogjava.net/ljc-java/articles/356844.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>