views:

201

answers:

5

After developing some web apps i tend to have some routines/best practises for my apps. For example to create an common Login Controller/Views etc for my app.

I try to talk about it with my colleagues and test some different apps how they do it. After a while it gets a bit boring. Usally there are new features in a application that really thrills me and keep me going on.

How do handle Tasks etc that you have done over and over again? Do you reuse your code often or start do you start creating it in a new way.

A: 

You might be interested by this question : What do programmers do to solve a problem? How they do that? and the answer I gave to it :

Basically, if you can re-use, do so ;-)
Writing a library for common code is nice ; some snippets repository too !

Instead of re-writing the same code over and over again, why not just re-use it ? It'll take less time, you will have less chances to introduce new bugs, ... And even if you cannot re-use a code portion "as-is", modifying it a bit will be faster / less boring than re-writing a full new solution, I suppose...

Pascal MARTIN
+1  A: 

Some web MVC frameworks should provide basic functionality for you, such as Login handling etc. If not, there may be 3rd party extensions available as well that will.

Creating reusable code is quite difficult though as different apps usually have different needs. Just to make it clear the act of creating reusable code is not the act to copy and paste it.

Refactoring is a good step towards maintainable code design but if you really want to learn the dark arts of reusable code, try to write or maintain libraries for a change. Nobody can be told how to write a reusable library, you need to do it for yourself.

Spoike
Thats the point...creating reusable code is difficult. From my point of view i want to improve with every project.
bastianneu
all right, I amended my answer with a tip then on how to write reusable code
Spoike
A: 

A good framework should help

Steerpike
Usually i agree with you. Frameworks were created to make such Tasks easier. On the other hand it is always nice to know what is going on behind the scenes and what other developers thought then they created an solution. Just want to add that...
bastianneu
+3  A: 

If you're annoyed by tedium, good! Frustration (not necessity) is the mother of invention. Maybe you've stumbled on one or more areas where there really is a need for things to be done better. It sounds like you're already using some frameworks and have possibly stumbled into some artificial limitations. Have you considered identifying the areas that you seem to keep doing over and over again, and then making your own library?

The world doesn't always need Yet Another App Framework in response to every problem, but if you think you can make an improvement on the way things are done, why not give it a shot? (And open-source it so everyone can check it out.)

How do handle Tasks etc that you have done over and over again? Do you reuse your code often or start do you start creating it in a new way.

On a project that someone's paying you for, I wouldn't usually recommend doing something in a different way just because you're bored with the previous or best-practices way of doing things. Creativity is good, but clients are paying for creative solutions to their problems, not a cool new way to login to their app.

John Feminella
Couldn't agree more, and I find taking code that I have to do over often, and improving it, and making it a resuable piece and adding it to a library actually exciting. When I am done i say "YES I don't have to do that tedious crap over again!"
Zoidberg
+1 for clearing up customer perspective. Thank you for that answer.
bastianneu
A: 

Learn/use a templateing language(e.g.: T4, XSLT) or a code generator product (e.g. CodeSmith).

alexs