dry

Configuring project report generation for Hudson within Hudson

There are a number of plugins for Hudson to create coverage, test result, metrics and other reports. It seems that all of them require you to add extra configuration to your build scripts (or Maven POM) for every project that you want to have the reporting done. For example, if you want to have a FindBugs or a Cobertura report, you need...

Alternative to django form processing boilerplate?

The suggested pattern for processing a form in a view seems overly complex and non-DRY to me: def contact(request): if request.method == 'POST': # If the form has been submitted... form = ContactForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process th...

Avoid code-duplication in the controller beforeInterceptor-blocks in Grails

I have the following identical code-block in all my controllers' beforeInterceptor blocks: def beforeInterceptor = { request.someField = Foo.someFoo(request) if (!request.someField) { redirect(...) return } } Repeating the exact same code fragment in all controllers violates DRY. Is there some standard Grails way to defi...

DRYing my has_many's in Rails

I have a model class that has, among other things: class Group < ActiveRecord::Base has_many :subscriptions has_many :users, :through => :subscriptions has_many :admins, :through => :subscriptions, :source => :user, :conditions => "subscriptions.role = #{ROLES[:admin]}" has_many :subscribers, :through => :subscriptions, :source...

Model-View-ViewModel pattern violation of DRY?

I read this article today http://dotnetslackers.com/articles/silverlight/Silverlight-3-and-the-Data-Form-Control-part-I.aspx about the use of the MVVM pattern within a silverlight app where you have your domain entities and view spesific entities which basically is a subset of the real entity objects. Isn't this a clear violation of the ...

How do I DRY up my CouchDB views?

What can I do to share code among views in CouchDB? Example 1 -- utility methods Jesse Hallett has some good utility methods, including function dot(attr) { return function(obj) { return obj[attr]; } } Array.prototype.map = function(func) { var i, r = [], for (i = 0; i < this.length; i += 1) { r[i] = func(this[i]); ...

How do I bring DRY (don't repeat yourself) to Objective-C

I'm coming from Ruby to Objective-C and I keep doing: NSObject *foo; @property (nonatomic,retain) NSObject *foo; in the .h file, and then in .m file: @synthesize foo; at the top and [foo release] in dealloc. It's 4 steps to add foo! Do seasoned Objective-C programmers do all four steps manually each and every time they want t...

Best practices to keep a Cairngorm Flex Project DRY (don't repeat yourself)

I'm having a hard time building a Cairngorm Flex3 app that connects to a rails app... I'm used to rails DRY approad, and the Convention over Configuration thing too.. and Cairngorm in awful at these. How do you keep you flex code as DRY as possible? I've implemented a generic delegate to avoid a delegate for each command, at least. Any...

How can I reduce repetition in this Ruby on Rails code?

This is a snippet of code from an update method in my application. The method is POSTed an array of user id's in params[:assigned_ users_ list_ id] The idea is to synchronise the DB associations entries with the ones that were just submitted, by removing the right ones (those that exist in the DB but not the list) and adding the right o...

Django cross-site reverse URLs

Probably simple question and I'm just missing something, but I'm stuck out of ideas. I have Django project serving several sites with distinct sessions.py and completely different ROOT_URLCONFs. One site handles user registration, authentication and profile settings, other site (on another domain) acts as file manager and so on. Sites a...

Properties Expansion Languages (DSLs) - Do any exist?

Here's my problem: We have N applications running in M different environments (qa/prod/etc.) with P servers per environment. Multiplied out, the number of unique configurations is in the hundreds. Each of these applications has a set of environment-specific properties (public hostname, listening port, max memory, etc.). Multiplied ou...

Is there any way to have language independent controllers/views/actions

I'm coding some web-applications in MVC, and I have a problem with something that has been on my mind for a time. The web-aplications I'm developing are mostly going to be used in Swedish, and because of the language I want to have my URL routing mapped against Swedish URL names. mysite.com/products/details/1 (English URL) mysite.com/...

How to balance DRY principle with minimizing dependencies?

I'm having a problem with the DRY principle (Don't Repeat Yourself) and minimizing dependencies that revolves around Rete rules engines. Rules engines in large IT organizations tend to be Enterprise (note the capital "E" - that's serious business). All rules must be expressed once, nice and DRY, and centralized in an expensive rules en...

How To Clone/Mutate A Model In Django Without Subclassing

'Ello, all. I'm trying to create a model in Django based on - but not subclassing or having a DB relation to - another model. My original model looks something like this: it stores some data with a date/time stamp. class Entry(Model): data1 = FloatField() data2 = FloatField() entered = DateTimeField() I'd also like ...

ASP.NET MVC 2 - When To Use Templates vs When to Use Partial Views

One of the new features in ASP.NET MVC 2 Preview 1 is support for the concept of Editor Templates and Display Templates which allow you to pre-define how a given object will be rendered for display or editing with a simple HTML helper call: <%=Html.EditorFor(customer => customer) %> <%=Html.DisplayFor(customer => customer) %> This is ...

Correct way to optimize repeated Rails code

Hello everyone, I have a Rails application with several models-views-controllers which have some similar characteristics, for example 5 different models can be commented on, voted on or tagged, I am also heavily using external plugins. At the moment I introduced comments, votes, tags, etc. only to a single model (and its view and cont...

Keeping XSLT Code DRY with 'if' Tests and 'value-of' Selects.

In XSLT, what is the preferred way to keep code DRY when it comes to 'if's? At the moment I am doing this: <xsl:if test="select/some/long/path"> <element> <xsl:value-of select="select/some/long/path" /> </element> </xsl:if> I would prefer to only write "select/some/long/path" once. ...

How to generate a non-const method from a const method?

While striving for const-correctness, I often find myself writing code such as this class Bar; class Foo { public: const Bar* bar() const { /* code that gets a Bar somewhere */ } Bar* bar() { return const_cast< Bar* >( static_cast< const Foo* >(this)->bar()); } }; for lots of methods like bar(). Writing these non-con...

Drupal6: Where to keep functions/constants needed across multiple modules?

I have a few modules with some functionality overlap. In accordance with DRY, I'd like to move this out to another location, so I will have less code to maintain. Where is the best place to do this? If I just make a module (and make it a dependency of the ones that need it), will I be guaranteed that the constants, functions and variable...

More efficient way to plot x-axis points?

I have been working on a project that requires a bar graph to be populated with price results. The chart displays the number of items within a given price range. For instance, if on amazon there are 9 items within the price range of $0-$10 the x-axis would display $0-$10 and the y-axis would be populated with a value of 9. My bar graph...