• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best Practices  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm a web developer that focuses mainly on the frontend. I wrote a custom anttask to perform various functions during our build process; minimize JS/CSS, tack a hash string on to static assets, and create an absolute url to our CDN.

So, before I send the code out to my colleagues, I was hoping to get some feedback. I'm looking for general pointers/best practices. For example, am I reading and writing file contents in an optimal way? Is the flow ok? My use of public/private methods?

The code can be found here (sorry for the weird whitespace): http://pastebin.com/WMMz5wBa

You'll need YUI Compressor, and the ant libs in your classpath. If need be, I can post the buildscript.

Thanks in advance,

Matt

 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing that might be worth looking into is JAWR. It's basically a packaging / bundling and minifying solution that allows you to develop your .js and .css in seperate files, instead of a murky one-huge-file-to-rule-them-all approach. At container start-up it bundles files as needed and minifies them, using a compressor of your choosing, YUI for instance. Similar to what you are doing in your custom ANT task with the added benefit of packaging / bundling.
 
Matt Ramon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Campbell thanks

@Jelle Wow, JAWR looks awesome! I'll definitely look in to that.


Any recommendations for my code, though?

Much appreciated!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt Ramon wrote:Hi all,

I'm a web developer that focuses mainly on the frontend. I wrote a custom anttask to perform various functions during our build process; minimize JS/CSS, tack a hash string on to static assets, and create an absolute url to our CDN.

So, before I send the code out to my colleagues, I was hoping to get some feedback. I'm looking for general pointers/best practices. For example, am I reading and writing file contents in an optimal way? Is the flow ok? My use of public/private methods?

The code can be found here (sorry for the weird whitespace): http://pastebin.com/WMMz5wBa

You'll need YUI Compressor, and the ant libs in your classpath. If need be, I can post the buildscript.

Thanks in advance,

Matt



If you are familiar or use Maven, there is a build time solution (maven plugin) called wro4j (which have also a runtime solution using filters). Here is the documentation about how to use the plugin: http://code.google.com/p/wro4j/wiki/MavenPlugin
 
Campbell Ritchie
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Alex Objelean
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!