Article 6Z0RY CodeSOD: What a CAD

CodeSOD: What a CAD

by
Remy Porter
from The Daily WTF on (#6Z0RY)
Story Image

In my career, several times I've ended up being the pet programmer for a team of engineers and CNC operators, which frequently meant helping them do automation in their CAD tools. At its peak complexity, it resulted in a (mostly unsuccessful) attempt to build a lens/optics simulator in RhinoCAD.

Which brings us to the code Nick L sends us. It sounds like Nick's in a similar position: engineers write VB.Net code to control their CAD tool, and then Nick tries desperately to get them to follow some sort of decent coding practice. The result is code like:

'Looping Through S_Parts that have to be inital createdFor Each Item As Object In RootPart.S_PartsToCreateIf Item.objNamDe IsNot String.Empty ThenIf Item.objNamEn IsNot String.Empty ThenIf Item.artCat IsNot String.Empty ThenIf Item.prodFam IsNot String.Empty ThenIf Item.prodGrp IsNot String.Empty Then'Checking if the Mandatory Properties are in the partfamilies and not emptyIf Item.Properties.ContainsKey("From_sDesign") Then' I omitted 134 lines of logic that really should be their own functionElseMsgBox("Property From_SDesign is missing or empty.", MsgBoxStyle.DefaultButton2, "Information RS2TC")Exit SubEnd IfElseMsgBox("Property prodGrp is missing or empty.", MsgBoxStyle.DefaultButton2, "Information RS2TC")Exit SubEnd IfElseMsgBox("Property prodFam is missing or empty.", MsgBoxStyle.DefaultButton2, "Information RS2TC")Exit SubEnd IfElseMsgBox("Property artCat is missing or empty.", MsgBoxStyle.DefaultButton2, "Information RS2TC")Exit SubEnd IfElseMsgBox("objNamEn is missing or empty.", MsgBoxStyle.DefaultButton2, "Information RS2TC")Exit SubEnd IfElseMsgBox("objNamDe is missing or empty.", MsgBoxStyle.DefaultButton2, "Information RS2TC")Exit SubEnd IfNext

All of their code is stored in a single file called Custom.vb, and it is not stored in source control. Yes, people overwrite each other's code all the time, and it causes endless problems.

Nick writes:

I really wish we'd stop letting engineers code without supervision. Someone should at least tell them about early returns.

[Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments