News for hackers. Stuff that matters.
Re:Every app has a scary basement—dark old mysterious code v... by sliverstorm on Tuesday September 07, 2010 @05:42PM (#1670194)
Things like this make it seem worthwhile to create a code translator. In the same way the compiler converts the code from horrific basement language to computer language, it would convert the code from basement language to a properly structured maintainable form. Not just re-formatting, but perhaps changing dated methodologies etc.

Kind of like perltidy, but much more aggressive, pruning and re-arranging and re-writing bits as needed.

On the one hand, in theory a computer could never do it as well as a human, and we should learn to code properly. On the other hand, it's a very common problem, and computers are supposed to be time-saving devices above anything else.

Re:Every app has a scary basement—dark old mysterious code v... by DougWebb on Tuesday September 07, 2010 @08:56PM (#1670670)
Perltidy just handles formatting. Scary basement code is often poorly formatted and reformatting is a necessary first step in fixing it, but it's a trivial first step. It doesn't address the hard part.

Perlcritic is closer to what you're thinking of; it examines the structure of the code and points out design and implementation problems. It can't fix them for you though, and it only handles common designs that it knows about. It can't judge the quality of a design that it's not already programmed to recognize. Again, a useful tool for fixing all of the common problems, but it can't address the overall design.

The refactoring tools in IDEs like Visual Studio are useful too, but they don't understand your code in a way that would help redesign it. They just automate much of the process of extracting code from one method to another method/class. Useful, but not redesigning your code for you.

Ultimately, it takes an intelligent software designer to do this kind of work. Maybe artificial intelligence will handle it some day, but that's not coming for a while.

Re:Every app has a scary basement—dark old mysterious code v... by tomjen3 on Wednesday September 08, 2010 @03:52AM (#1671327)
Writing such code would, unfortunately, be non-trivial (in the geek meaning) at best. Most likely undecidable.