views:

1693

answers:

12

NB - This question is not a stab at RoR or at Redmine's plugin system


I have been working on a custom plugin for Redmine, a project manager platform built with Ruby on Rails (RoR). Now I am not really a RoR or for that matter, a Ruby guy. I have managed to write the plugin and everything works, despite being a mess behind the scenes. The "You're Doing It Wrong!!" feeling is coming from the fact that I know RoR is a highly-regarded framework, so there must be simple, better, elegant, [insert best-practice term here], ways of doing what I have done. I am not too concerned with making this code as perfect as possible, for the sole reason that this is only used internally, and really, people only care that it "works" (I am the only one who will look at the code).

What words of wisdom can be passed on to suppress the "You're Doing It Wrong!!" feeling? I am pretty sure if this feeling is present, then it is probably true that the task at hand is being done wrong.

+58  A: 

What is the problem? The “You’re Doing It Wrong!!” feeling is the essence of our existence.

tuinstoel
best. answer. ever.
Jeff Atwood
Indeed. A programmer who never feels that itch needs to find another line of work. Or at least stay off my teams.
Tim Lesher
I can only agree. Let me quote Scott ( http://simpable.com/code/sick/ ): "If as a developer you can ever look at code you wrote 6 months ago and do not get a little nausea, it is time to pack it in and go do something else."
Cohen
True! Your answer made me laugh.
Gabriel Florit
+4  A: 

RoR like a lot of other frameworks, make it really easy to do things that they anticipate, and quite difficult to do things that they didn't anticipate. This is true of almost all frameworks that aren't custom frameworks that you designed specifically for your project. The fact that you had to do a lot of messy stuff behind the scenes to do something doesn't surprise me at all. So, if you are doing something that wasn't anticipated, then it's perfectly natural to feel like you are doing it wrong, because from the eye of the framework designers, you shouldn't be doing that at all.

Kibbee
Considering that he meant that his lack of familiarity with RoR was most the trouble with the plugin's "You're doing it wrong"-ness and code-mess ... -1 for lack of reading.
The Wicked Flea
+10  A: 

Don't suppress the feeling! That this is wrong feeling is the key to innovation. Just ask yourself "if this is wrong, then what would be better?"

Charlie Martin
+8  A: 

Don't think of it as "You're doing it Wrong!!" Think of it as "What's a better way to do this?" Best case you end up doing it more efficiently, worst case you discover something that may be useful on your next project.

Ian Jacobs
+5  A: 

I have never finished a piece of code that I am 100% happy with. But then, I don't believe there is a single (non-trivial) piece of code in the World that can't be improved upon.

It is the developers who always think they have delivered great code that I worry about.

DanSingerman
+4  A: 

In many cases RoR employs 'syntactic vinegar' precisely to give you this feeling that there is a better way. You should probably look at some other plugins to get a feel for the conventions used. Generally if you follow the convention with RoR, it feels right.

frankodwyer
+1 for the phrase syntactic vinegar.
Chris Marasti-Georg
+25  A: 

I read a piece of advice a while back that helps me in such situations. It can be paralyzing to try to do something the "right" way when you don't know anything about it.

So if I have to build, say, a customer-management application, my first step might be:

Build a really crappy customer-management application.

It's hard to build a good one, but it's easy to build a crappy one that does a thing or two. And while it's hard to know when something is good enough, it's pretty easy to know when something is crappy.

Once I have the crappy one in front of me, I can clearly see what needs improvement. And it's easy to change it, because the crappy one actually does something; so, using the TDD principle, I improve it while keeping it working. Eventually the crappy application evolves into a good one.

Many of the applications I've worked on that ended up crappy started out attempting not to be...and thus were overly complicated and hard to change, debug, and improve.

Kyralessa
i agree wholeheartedly
Nice. I didn't know that my way of developing is appreciated :)
VVS
+5  A: 

They say writers should write something every day, whether it's good or not.

Marc Raibert's advice is if you can't write something good, write something bad, and then polish the heck out of it.

My experience programming is when I've done something several times over, I finally start to get good at it.

So don't expect perfection.

Mike Dunlavey
+2  A: 

If you look back on any piece of code you write today a few years in the future, chances are you'd be shocked how bad it is. Put another way, it may show how much you've progressed over time. The feeling you are getting is part of continous learning. Start by getting it right and making it stable. Elegance comes with time, and fashion changes in computer programming style same as with everything else.

Shane MacLaughlin
Well said, i definately get stuck in the "must-be-most-elegant-on-first-iteration" rut. Nothing is more of a reality check then looking at half-started scripts i have.
+1  A: 

The first time you work with a language, framework, etc, you're going to do something "wrong." As you develop other applications, or make tweaks & improvements to your original application, you'll find out what needs fixing, or what you could do better.

On every project, I almost always feel like I've done something sub-optimally, or not perfectly, but when it comes down to it, the code works, allows people to do what they need, and is in a way, a success. So keep writing and keep learning!

aghman
+3  A: 

Specifically with Redmine, the plugin system is still new and we are trying to work out the best practices. Since Redmine (and Ruby on Rails) are Open Source, I'd suggest bringing up your feelings to the project's forums and see what people think. Others might agree with you and can help to improve the systems.

Note: I'm one of the core developers of Redmine, helped build the Redmine plugin system, and have about a dozen Redmine plugins released. And even I feel things are backwards from time to time.

Eric Davis
+2  A: 

"What is the problem? The “You’re Doing It Wrong!!” feeling is the essence of our existence."

Perhaps not really related, but :

"A programmer is someone who makes a living out of solving the problems that were caused by the solutions he invented before."