Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Ninja style coding... is it bad?

by kvale (Monsignor)
on Sep 03, 2004 at 23:14 UTC ( #388448=note: print w/replies, xml ) Need Help??

in reply to Ninja style coding... is it bad?

I think maintaining the coding style (indentation, brace styles, etc.) is perfectly reasonable, as it helps legibilty by not taking the programmer 'outside' the content to consider a new style.

Maintaining the semantic content in the face of badly written code is a more tricky issue. When I am tasked with fixing buggy code that is badly written, I usually consider how much time I have available and the amount of code that needs to be changed. Refactoring ugly code is an almost palpable desire among good programmers, but that has to be balanced against time pressures and the introduction of new bugs in the refactored code.

If time is short and the change is a line or two, it is probably just best to make the change fit the surrounding code, along with a comment as to what was changed, and a corresponding test in the suite.

If there is more time available and/or the bug is more fundamental, I'll try to refactor the subroutine(s) that contain the bug. If this is a personal project with no time limit, I might refactor the whole program :)

No matter what the size of the change, it is good to add a test to check your work; larger refactorings may need multiple tests.

I'd check with the boss or owner of the code as well. I once joined a physics lab as a new grad student and the lab space was a complete disaster. While waiting for parts for my expt, I organized and cleaned up the place. My advisor took one look, and had a full-blown conniption: eyes popping, orange smoke coming out of his ears, the works. I had messed up his organization. We spent hours getting it back to it's original state.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://388448]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2018-04-23 04:21 GMT
Find Nodes?
    Voting Booth?