2

My co-worker has been assigned the task of editing one of our Java application's tables. She is almost done, but needs to make one final adjustment to the table - this requires her to add a CSS attribute to a single table cell so that it does not wrap to the next line.

However, she's informing me that 'best practice' is to define TD behavior in our CSS definitions.

Changing our TD behavior rather than an individual cell is best practice for sure, but this app is already in production, and there are thousands of different table cells all throughout it - changing the behavior of our cells now could affect every single table cell in the app - so I'm encouraging her to make the change in just that cell to minimize the scope of her change.

Is my suggestion correct - is it better to minimize the scope of this change, or to follow the best practice and change the attribute in our CSS definitions?

4
  • 2
    This question boils down to "Who is right? Me or my coworker?" Those types of questions don't make for good Q&A for this site as the answers reduce down to opinion. Pull together the decision making leads on your project and work through the question at hand. Your team will have enough knowledge of the details of the project to be able to make the correct decision for your team.
    – user53019
    Commented Apr 5, 2016 at 17:41
  • 1
    @GlenH7: such questions can be perfectly answered in the form "under condition A, your coworker is right, under condition B, she is not". At least, if the conditions A and B are simple enough.
    – Doc Brown
    Commented Apr 5, 2016 at 18:03
  • If she is talking about adding "td { whitespace:nowrap }" to your global stylesheet, then she's crazy. That could cause every table in your application to change its layout, to some degree.
    – GHP
    Commented Apr 7, 2016 at 14:57
  • @Graham That is exactly what she was proposing, and exactly what I was hesitant to agree with. If we were designing a new app wholly, that wouldn't be a problem, but this app has been around for years.
    – Zibbobz
    Commented Apr 7, 2016 at 15:11

1 Answer 1

4

If one makes a change to an application which will cause a three weeks manual test cycle, the person or the team is not "always done", not even close. If that is your situation, then it should be obvious that keeping the change locally is clearly the better option.

However, if you have an automatic test suite at hand with a high test coverage, which can do the testing in less than ten minutes, and it gives you confidence nothing got broken, then you can safely apply the change. Or, if the change breaks too many tests, you can still revert the change using your VCS and look for a different solution.

In reality, however, you might face a situation somewhere in between these two extremes, and it is often a trade-off. Nevertheless you should try to keep your software evolvable, and try to make changes possible in a safe manner even when they affect more than part of your system.

So if your team has no such test suite, the best short-term option is probably to minimize the scope of a change. The better mid or long term option, however, is to build such a test suite, so you can safely apply refactorings even if they have a broader scope. Always minimizing the scope of changes typically leads to a degredation of the code quality, increases the "technical debt", and often ends up in a "big ball of mud" architecture.

2
  • Answer: Not nearly big enough that I'd feel comfortable justifying this change. But an excellent answer regardless of my personal situation.
    – Zibbobz
    Commented Apr 5, 2016 at 17:51
  • 1
    @Zibbobz: just bear in mind that "changing just this cell" and not going for the all out change, you have introduced something that can become an exception to general behavior and if you do it often enough these little exceptions will make life that much harder when you do want to go for the all out change. The resistance to doing it the proper way will increase with every "just this cell" change you make... Commented Apr 7, 2016 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.