Thursday, April 24, 2014

Comparing asp to

Oh the Joy of .net and object orientation in general:


Compare the old asp way.   Just functions with single return values:



if rules("isafirstname",firstname) = true and rules("isasurname",wholename(0)) = true then

     transmute =("L-CAPNAMEINIT{_}"&propercase(firstname)& " " & propercase(wholename(0)))

elseif rules("isafirstname",firstname) = true then

     transmute =("L-CAPFIRSTNAMEINIT{_}"&propercase(firstname))

end if


So I would wind up stuffing a load of data into the return string and then reassembling it in the calling function.


First go on Tuples today.  Seems to me a sort-of “quick fire” multi-return type where you don’t want to go the whole hog of returning a struct.


Dim foundRows = boysnames.Select("name = '" & Replace(username, "'", "''") & "'")


If foundRows.Length >= 1 Then

   Return New Tuple(Of Boolean, String, String)(True, foundRows.CopyToDataTable.Rows(0).Item("friendlyname").ToString, "Found in Boy's Names Table")

End If


Return New Tuple(Of Boolean, String, String)(False, "", "")


How cool is that?


If there are any old farts like me still debating wether to go for .net and object orientation in general.  The answer has to be “do it now!”.


No comments:

Post a Comment

Distributed Backlink Service

Wouldn't it be great to work together and create a "distributed search engine" with the index spread across thousands of peer...