编写长存储过程是否是糟糕的数据库设计和编码风格的标志?
我遇到过一个人,他声称自己已经在 Sql Server 中写入了超过 5000 行存储过程。那个长存储过程实际上是必需的吗?或者这是糟糕的数据库和编码设计的标志?我真的很担心。在我的一个基于保险的实时项目中,我从未在存储过程中编写过超过 100 行的代码,该项目必须处理美国协议和补充。顺便说一句,他在吹嘘自己好像写了这么长的存储过程做得很好。
预先感谢:)
等待您的回复。
I've met one person who claims he has wrote to over 5000
lines of stored procedure in Sql Server. Is that long stored procedure actually required ever? Or is it sign of a bad database and coding design? I am really worried. I never wrote anything long than 100 lines of code in Stored Procedure in one my live projects based on Insurance which had to deal with U.S Acords and Supplements. Btw, he was boasting as if he did some great job writing such long stored procedure.
Thanks in advance :)
Waiting for your replies.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我个人的经验,有几个条件迫使你编写这么长的存储过程,这是我现在记得的两个条件
我不认为编写这么长的存储过程是一件好事,我个人认为这是一件很糟糕的事情,它表明数据库被搞乱了,计划不够周密。
From my personal experience, there are several conditions that force you to write such a long stored procedure, these are 2 of the ones that I'm remembering right now
I don't think that writing such a long stored procedure is a good thing, I personally think that it's a pretty bad thing, it shows that the database is messed up, not planned thoroughly enough.
我不认为存储过程的长度是糟糕的设计或编码风格的标志。
我认为存储过程中的代码是糟糕的设计或编码风格的标志。
他本可以写
“那可以增长得很快,正如你知道的那样,可以放在一行中,也许他认为它更具可读性”。
重点是,我不认为长度是确定存储过程好坏的一个很好的指标。您可能会编写一个 100 行存储过程,但它比 5000 行存储过程要差。
如果我个人正在查看我的全新 5000 线存储过程,即使没有其他选择,我也会感到担忧而不是自豪。维持这一点将是一场噩梦。
但在您朋友的情况下,如果不知道存储过程执行什么操作或如何执行操作,就很难以任何方式进行评论。
I don't think the length of a stored procedure is a sign of bad design or coding style.
I think the code in a stored procedure is a sign of bad design or coding style.
He could have wrote
That could grow pretty quickly, as you know that could fit on one line, maybe he thinks its more readable.
The point being, I don't think the length is a good metric to determine whether a sproc is good or bad. You can probably write a 100 line sproc which is worse than a 5000 line sproc.
If I personally was looking at my brand new 5000 line sproc, I would be worried and not proud, even if there was no other choice. Maintaining that will be a nightmare.
But in your friends case it's difficult to comment either way without knowing either what action the sproc performs or how it does it.