{"id":6720,"date":"2012-11-02T08:26:42","date_gmt":"2012-11-02T13:26:42","guid":{"rendered":"http:\/\/bobbeaty.com\/wp\/?p=6720"},"modified":"2012-11-02T08:44:18","modified_gmt":"2012-11-02T13:44:18","slug":"fixing-more-code-monkey-bugs","status":"publish","type":"post","link":"https:\/\/bobbeaty.com\/wp\/archives\/6720","title":{"rendered":"Fixing More Code Monkey Bugs"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/bobbeaty.com\/wp\/wp-content\/uploads\/2007\/09\/bug.gif\" alt=\"bug.gif\" title=\"bug.gif\" border=\"0\" width=\"128\" height=\"115\" style=\"float:right; margin-left:10px;\" \/><\/p>\n<p>This morning I came in and saw that we were having serious Production problems - and they were in the code, and it was effecting UAT as well. Now I'm not a prude\u2026 I get that code goes into Production with bugs - heck, I've done it, and I'll likely do it again in the next month. But I'm here to fix it, and to the <strong><em>best<\/em><\/strong> of my abilities, I test the code <em>before<\/em> I go home with a quick run. But last night was <em>ugly<\/em>.<\/p>\n<p>I guess I wasn't <em>really<\/em> surprised that I had problems this morning\u2026 I was having problems last night getting a test to run. The Code Monkeys on the team have been fiddling with a lot of things - specifically the Salesforce endpoints, and while I think that's <em>great<\/em>, it's a little frustrating when there are folks trying to get things done with Salesforce, and others trying to refactor and hope it's not breaking anything.<\/p>\n<p>But that was last night, and I <em>thought<\/em> I had it all behind me. But evidently not. In the refactoring, they have employed the <a href=\"https:\/\/github.com\/intridea\/hashie\">Hashie<\/a> gem, and while it's nice, it's also a little tricky. They wanted to base their conversion of our \"container based objects\" from a Hash to something based on the Hashie::Trash which is a <em>transforming Hash<\/em>. However, that, in turn, it turns out, is based on the Hashie::Dash - or <strong><em>defined<\/em><\/strong> Hash.<\/p>\n<p>This means that if you haven't defined the possible entries for the Dash, then you can't add it. That's nice, to keep \"junk\" out, but if you miss one in the code, then all of a sudden, working code becomes very <em>uncorking<\/em> code all because of this restriction. I think they <em>thought<\/em> they planned for that, but they left off a critical component. A very necessary subclassed method:<\/p>\n<pre class=\"ruby\" style=\"font-family:monospace;\">  <span style=\"color:#9966CC; font-weight:bold;\">def<\/span> assert_property_exists!<span style=\"color:#006600; font-weight:bold;\">&#40;<\/span>property<span style=\"color:#006600; font-weight:bold;\">&#41;<\/span>\n    <span style=\"color:#9966CC; font-weight:bold;\">unless<\/span> <span style=\"color:#0000FF; font-weight:bold;\">self<\/span>.<span style=\"color:#9966CC; font-weight:bold;\">class<\/span>.<span style=\"color:#9900CC;\">property<\/span>?<span style=\"color:#006600; font-weight:bold;\">&#40;<\/span>property<span style=\"color:#006600; font-weight:bold;\">&#41;<\/span>\n      Thrash.<span style=\"color:#9900CC;\">property<\/span><span style=\"color:#006600; font-weight:bold;\">&#40;<\/span>property.<span style=\"color:#9900CC;\">to_s<\/span><span style=\"color:#006600; font-weight:bold;\">&#41;<\/span>\n    <span style=\"color:#9966CC; font-weight:bold;\">end<\/span>\n  <span style=\"color:#9966CC; font-weight:bold;\">end<\/span><\/pre>\n<p>This code simply makes sure that if the new property <em>isn't there<\/em>, it's <em>created<\/em>. This isn't what the Hashie::Dash is all about, but it's what we needed because we're constantly adding attributes to the Merchant, and we want to avail ourselves of the mapping in the Hashie::Trash, but <strong><em>not<\/em><\/strong> the restrictions of the Hashie::Dash.<\/p>\n<p>What's annoying about all this is that I'm the one finding this out.<\/p>\n<p>I'm not the one championing the Hashie gem. I'm not the one working it into the code. I'm not the one writing tests for any of this. But I'm the one that picks up the pieces and fixes it and re-runs production and UAT to make sure we have <em>something<\/em> for the day.<\/p>\n<p>It's hard being this guy when I'm working with a group of Code Monkeys that are as careless as they are. If I'm finding my own bugs, then that's on me. My fault - totally. But when I'm finding things that I would have checked - and they <strong><em>should have<\/em><\/strong> checked, and it's causing the project to look bad, then it's annoying. Too much of this, and I'm really getting frosted.<\/p>\n<p>Unfortunately, I'm not their manager. I'm not their boss. So I can do <strong><em>nothing<\/em><\/strong> about it. Not a single, bloody, thing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This morning I came in and saw that we were having serious Production problems &#8211; and they were in the code, and it was effecting UAT as well. Now I&#8217;m not a prude\u2026 I get that code goes into Production with bugs &#8211; heck, I&#8217;ve done it, and I&#8217;ll likely do it again in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[],"class_list":["post-6720","post","type-post","status-publish","format-standard","hentry","category-coding","category-cube-life"],"_links":{"self":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/comments?post=6720"}],"version-history":[{"count":2,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6720\/revisions"}],"predecessor-version":[{"id":6722,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6720\/revisions\/6722"}],"wp:attachment":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/media?parent=6720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/categories?post=6720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/tags?post=6720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}