{"id":119,"date":"2007-04-10T11:26:45","date_gmt":"2007-04-10T11:26:45","guid":{"rendered":"http:\/\/quinert.com\/blog\/xml-rss2.php?itemid=28"},"modified":"2007-04-10T11:26:45","modified_gmt":"2007-04-10T11:26:45","slug":"more-joys-of-vendorscript","status":"publish","type":"post","link":"http:\/\/www.software-testing.com.au\/blog\/2007\/04\/10\/more-joys-of-vendorscript\/","title":{"rendered":"More Joys of Vendorscript"},"content":{"rendered":"<p>Someone recently suggested to me that the selection of VBScript for an automation language is because it&#8217;s easier for testers.  This is slightly rant-y, but I promise there are a few helpful tips in here just to make up for a mild dose of language-warring.<\/p>\n<p><b>Exhibit A.<\/b><\/p>\n<p>I can understand that there\u00e2\u20ac\u2122s a chance that a tester (if they came from a business role) might have some familiarity with VBScript as a result of writing office macros, but really&#8230;<\/p>\n<p>Which would you rather write (and read)?<\/p>\n<pre><br \/>\nDim newList<br \/>\nnewListNextItem = 0<br \/>\n<br \/>\nFor i=1 to ubound(list)<br \/>\n    Redim newList(newListNextItem)<br \/>\n    newList(newListSize) = list(i).getROProperty(\u00e2\u20ac\u0153text\u00e2\u20ac\u009d)<br \/>\n    newListNextItem = newListNextItem+1<br \/>\nNext i<br \/>\n<\/pre>\n<p>\nOR<\/p>\n<pre><br \/>\nlist.each do | item |<br \/>\n  newList.push item.text<br \/>\nend<br \/>\n<\/pre>\n<p>Of course, you <i>can<\/i> (and probably should) implement your own class to do something like the above.  Below is how things might look if do.<\/p>\n<pre><br \/>\nSet newList = new dynamicList<br \/>\nwhile list.hasNextItem do<br \/>\n  newList.add(list.nextItem)<br \/>\nend while<br \/>\n<\/pre>\n<p>You will, however, quickly encounter the issue detailed in exhibit C.<\/p>\n<p><b>Exhibit B.<\/b><\/p>\n<p>Is it easier to have to change the way that you assign a variable based upon the type of the thing being assigned?<\/p>\n<p><code><br \/>\na=\"Fred\"<br \/>\nSet b=New Fred<br \/>\nc=a<br \/>\nSet c=b<br \/>\n<\/code><\/p>\n<p>OR<\/p>\n<p><code><br \/>\na=\"Fred\"<br \/>\nb=Fred.new<br \/>\nc=a<br \/>\nc=b<br \/>\n<\/code><\/p>\n<p>The net effect of this is to have functions which need to be aware of exactly what kind of thing they are returning, then have them do this:<\/p>\n<pre><br \/>\nIf isObject(a) then<br \/>\n   Set functionReturnValue = a<br \/>\nElse<br \/>\n   FunctionReturnValue = a<br \/>\nEnd if<br \/>\n<\/pre>\n<p><b>Exhibit C.<\/b><\/p>\n<p>We include a reference to file B from file A<\/p>\n<p>File A contains:<\/p>\n<p><code><br \/>\nSet a = New a<br \/>\n<\/code><\/p>\n<p>File B contains:<\/p>\n<p><code><br \/>\nClass A<br \/>\nEnd Class<br \/>\n<\/code><\/p>\n<p>For some reason this doesn\u00e2\u20ac\u2122t work, so just to check, we try a different method to include our Class definition.  Now we are told that the class already exists.<\/p>\n<p>But wait, if you somehow thought to create a special factory function to give you an instance of the class, it all works.<\/p>\n<p>So now we change File B to:<\/p>\n<pre><br \/>\nFunction newA<br \/>\n   Set newA = New A<br \/>\nEnd Function<br \/>\n<br \/>\nClass A<br \/>\nEnd Class<br \/>\n<\/pre>\n<p>Now why didn\u00e2\u20ac\u2122t I think of that?<\/p>\n<p>Rant off.  I\u00e2\u20ac\u2122ll be working with different languages and tools for a while now\u00e2\u20ac\u00a6But do we really have to suffer this as testers?  I&#8217;ve never spent so much time in a debugger, ever.  Productivity tool?  I leave that to you to decide.<\/p>\n<p>And in case you didn&#8217;t read this the first time around, discover the joys of Visual Basic over here:<\/p>\n<p><a href=\"http:\/\/adamv.com\/dev\/articles\/hatevbs\/vbscript\">http:\/\/adamv.com\/dev\/articles\/hatevbs\/vbscript<\/a><br \/>\nTerry Horwath has also done some further investigation of the namespace issue (Exhibit C) <a href=\"http:\/\/www.sqaforums.com\/showflat.php?Cat=0&#038;Number=348942&#038;page=0&#038;fpart=2&#038;vc=1\">over at SQA Forums<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Someone recently suggested to me that the selection of VBScript for an automation language is because it&#8217;s easier for testers. This is slightly rant-y, but I promise there are a few helpful tips in here just to make up for a mild dose of language-warring. Exhibit A. I can understand that there\u00e2\u20ac\u2122s a chance that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,30,34,36],"tags":[130,88],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-ruby","category-software-testing","category-test-automation","category-test-tools","tag-ruby","tag-vbscript"],"_links":{"self":[{"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":0,"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.software-testing.com.au\/blog\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}