CodeSOD: Drop it Like it's a Deployment |
Zeniths company went ahead on and outsourced 95% of their development to the lowest bidder. Said bidder promised a lot of XML and MVC and whatever TLAs sounded buzzwordy that day, and off they went. Its okay, though, the customer isnt just taking that code and deploying it- Zenith gets to do code reviews to ensure code quality. The general flow of the post-code-review conversation goes something like:
Zenith: This code shouldnt go into production, hell, its so bad that a proud parent wouldnt even hang it on their fridge.
Management: Ill raise your concerns.
Outsourced Team: We did the needful, please review again.
Zenith: They didnt change anything. It doesnt even compile.
Offshore Team: There are too many barriers, we cannot hit deadlines, your team is too strict
Managment: Yeah… I guess youre gonna have to lay off the contractors. Dont be so strict in your code reviews. We have to deliver software!
The worst code ended up, not in the software, but in the deployment scripts. The team didnt have and didnt want a build environment (because they didnt want to be expected to test their deployment scripts), so they essentially just guessed what the deployment scripts should be like and hoped for the best. They didnt check them, they certainly didnt run them.
For deploying changes to stored procedures, they got especially interested in using DROP commands, like so:
DROP PROCEDURE [schema].[foo];
CREATE PROCEDURE [schema].[foo] AS…
DROP statements destroy the object and any grants associated with it- meaning the permissions got wiped out with every deployment. After a long weekend cleaning up a botched deployment, Zenith gave them a template to follow. All they needed to do was plug their code into a script that would never drop, but instead create/alter as needed.
They… adapted his script to their own processes.
IF EXISTS(select * from sys.all_objects where name = 'USPCandidateSearchElectionInfo')
DROP PROCEDURE CF.USPCandidateSearchElectionInfo
GO
IF OBJECT_ID('[CFO].[USPCandidateSearchElectionInfo]') IS NULL
BEGIN
EXECUTE('CREATE PROCEDURE [CFO].[USPCandidateSearchElectionInfo] AS BEGIN SELECT NULL; END');
END
GO
ALTER PROCEDURE [CF].[USPCandidateSearchElectionInfo]
@Request XML
AS
BEGIN
--pages and pages of horrific code follow, the details of which are inconsequential
RETURN @@ROWCOUNT
END
Not only did they keep the DROP, thus defeating the entire reason why he had given them a script in the first place, they also couldnt even get so far using the same name forr the procedure all the way through.
Zenith raised this with management, and was once again scolded: Code reviews are supposed to facilitate development, not provide a barrier to deployments.
[Advertisement] Release!
is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!
https://thedailywtf.com/articles/drop-it-like-it-s-a-deployment
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |