DevDisasters

The Storray Engine

As an independent .NET consultant, Steve was often called in to help smaller development teams transition to the platform. A client asked him to help rebuild some "core technologies" in .NET so the company could offer it as a service to their clients. The first "technology" they wanted to upgrade was something called the Storray Engine.

Simple Arrays
At the requirements meeting, the brain behind the engine gave a quick summary: "It's like having the benefit of a database without ever having to use SQL, ADO or any of that stuff; just simple arrays," he explained. Then they dove into the code. First, they looked at the FindProducts.asp page. The beauty of it, the programmer explained, was that all you needed to do was include a single file, and you had access to all the products and could easily manipulate them with simple array functions:

<!-->include virtual="/Code/Storray
	Engine/Data/PRODS.asp" -->

Steve was curious how this include file might work, so they took a look:

<%
Dim PRODS(487, 7)

... 
PRODS(14,0) = "Black & Decker"
PRODS(14,1) = "Auto Tape Measure"
PRODS(14,2) = "ATM100"
PRODS(14,3) = "/imgs/bd_atm100.gif"
PRODS(14,4) = "<p>Extend and 
	retract with the push of a 
	button</p><ul><li>Blade ... " 
PRODS(14,5) = "21.99"
PRODS(14,6) = "2"
PRODS(14,7) = "True"
...

PRODS(212,0) = "DeWalt"
PRODS(212,1) = "Heavy-Duty XRP 18V 
	Cordless Combo Kit"
PRODS(212,2) = "DC6KTGA"
PRODS(212,3) = "/img/dw_dc6ktg.gif"
PRODS(212,4) = "<p>This 6 pc. tool 
	set comes with our top of the 
	line 18V XRP ..."
PRODS(212,5) = "599.99"
PRODS(212,6) = "84"
PRODS(212,7) = "True"
%>

Hard-Coded "Database"
Steve was aghast -- and a little upset. All of the data -- the names, pricing, categories and everything one would expect in a database -- was hard coded into a VBScript/ASP code file. Steve was trying to keep his cool and figure out a professional exit strategy, but he just had to ask about maintenance. "Maintaining is just as easy," the brain explained. "All you need to know is arrays."

The rest of the Products Maintenance page contained a few array manipulation functions and a call to a save function. "All the real work is in the Core libraries," said the programmer.

Function STORRAYLIB_SaveArray _
		(name, ByRef storray)

	Dim fso, textfile, fileName, i, j

	Set fso = Server.CreateObject(_
		"Scripting.FileSystemObject")

	fileName = Server.MapPath( _
		"/Code/StorrayEngine/Data/" & _
		name & ".asp", True)
	Set file = fso.CreateTextFile(_
		fileName)

	file.WriteLine "<" & "%" & vbCrlf 
	file.WriteLine _
		"Dim STORRAY_" & name & "(" & _
		UBound(storray, 1) & _
		"," & UBound(storray, 2) & _
		")" & vbCrLf

	For i = 0 To UBound(storray, 1)
		For j = 0 To UBound(storray, 2)
			file.Write _
				"STORRAY_" & name & "(" & _
				i & "," & j & ") = " & _
				"""" & Replace(Replace( _
				storray(i,j),"""",""""""),_
				vbCrLf,"") & """" & vbCrLf
		Next
	Next

As Steve gawked at the wonder that was the Storray Engine, the programmer commented, "Yeah, I just can't figure out how to bring this into .NET. I'm thinking of using classes instead, but man, it's hard to compile stuff at run time!"

About the Author

Alex Papadimoulis lives in Berea, Ohio. The principal member of Inedo, LLC, he uses his 10 years of IT experience to bring custom software solutions to small- and mid-sized businesses and to help other software development organizations utilize best practices in their products. On the Internet, Alex can usually be found answering questions in various newsgroups and posting some rather interesting real-life examples of how not to program on his Web site TheDailyWTF.com. You can contact Alex directly via email at [email protected].,

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube