Should I keep bad naming conventions?

2020-08-20 12:52发布

问题:

I'm currently working on a site which went through god knows how many developers' hands. One of the things I don't like about it is the way every table in the database has the prefix "tbl_" and every field "fld_".

I've started work on a new feature and I'm faced with the following problem: should my new tables continue with the old convention, or not?

I guess I should, but I feel stupid doing it :)

回答1:

I would keep the same convention.. Regardless of if it's bad or not at least it would be consistent. And consistency will be very important to the next developer who gets ahold of the code.



回答2:

Being a contractor, I am faced with this problem a lot. Here is my 2 cents:

If it isn't broken, then the client is wasting their money having me change that. Unless I am rewriting the entire app, I usually keep with the old (bad) standards (at least that way, you don't have part of the app with one convention and other parts using something different - this keeps the code readable by other developers).



回答3:

You have two options.

  1. Change all the bad naming conventions to new ones.
  2. Use the old conventions.

Someone will be looking at this code later and will need to deal with any differences you create. That means you need to be aware that other people are affected by this decision. Do the right thing if you have time, do the ugly thing if you don't have the time... but keep it consistant.



回答4:

If it a constant style throughout the application I would follow the naming convention it will make it much easier on the next developer.



回答5:

I tend to look at the scale involved. The consistency of a bad naming convention, to me, is preferable over a multitude of different ones in the same codebase or database.

If there are a handful of tables and you can safely change them, my feeling is to make the change. But anything of scale or an application that you're only doing a bugfix on is likely not worth the time and effort involved.



回答6:

Go with which ever route costs less, in money and resources. If it's not going to save you money going through and re-tilling the ground, then don't. Just grit your teeth and move forward.



回答7:

"If it ain't broke, don't fix it"



回答8:

I think you should prefer consistency and follow the convention already being used.

Think of the poor developer(s) who come along behind you and have to deal with two different naming conventions (the original one and your new one), neither of which the new developers like.



回答9:

Welcome to the world of maintenance. ;)

Who's to say that the next person who works on the site won't despise the way you did things?



回答10:

Any naming convention is better than no/inconsistent naming convention.



回答11:

I say change it iff there's a significant difference between the old code and the new code. For example, if the old way was a terribly dead-end and the new way is completely independent, then go ahead and start a new convention.

It's good to be visually consistent if the new material is structurally and semantically consistent, but if what you're doing is a clean break from what came before, then it's even more important that different things look different.



回答12:

Like everyone said, stay with the bad convention since you are not writing it from scratch. However, use "good practice" if there is a compelling need for it (aka the end-user will be negatively affected otherwise). For example, if the "bad convention" makes the API users use boxing, change the value of strings and other performance-hit to a great degree; do not add to the problem! The end goal of software and API's is not to make the developers' life easier; but the end-user's. Developers that stay in the business long are highly aware of this and you want to be one of those developers.