A long while back, an anonymous reader sent in a block of code that, at first glance, looked like well-written VB6 code implementing some fairly complex products catalog. There was no background or remarks with the submission (which, by the way, is very helpful), so I kinda just tossed it in the "Look-at-this-later" folder. I finally got around to checking it out discovered why it was sent in ... I'll leave it as an exersize for the reader to find this same reason ...
'find product groups for the current system Set product_groups_node = xmldom.SelectNodes("/root/systems[@type=" & SystemType & "]/product_group") For Each product_group_node in product_groups_node IsValidGroup = True 'validate that the user has access to the group If IsValidGroup Then IsValidGroup = _ customer.CanAccessProductGroup( product_group_node.selectSingleNode("@group_code").Value ) 'ED: Snip 6 further validations 'and that there are avaiable products in the group If IsValidGroup Then IsValidGroup = _ product_group_node.selectNodes("product[@quantity > 0]").length > 0 'add products and product group If IsValidGroup Then 'build the product group Set product_group = New Catalog.ProductGroup 'ED: Snip 15 lines lines 'add the products For Each product_node In product_group_node.selectNodes("product") 'validate that the price is not above credit limit lpos = InStr(product_node.xml, "base_price") + 12 rpos = InStr(lpos,product_group_node.xml,"""") If CSng(Mid(product_group_node.xml, lpos, rpos - lpos)) <= customer.CreditLimit Then product_group.AddProduct _ product_group.selectSingleNode("@product_number").Value, _ product_group.selectSingleNode("@base_price").Value, _ product_group.selectSingleNode("@product_desc").Value End If Next 'add it to the user's catalog userCatalog.AddProductGroup product_group End If Next
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!