alt.net – Tea-Driven Development https://blog.mattwynne.net Matt Wynne taking it one tea at a time Wed, 21 Aug 2019 13:07:17 +0000 en-US hourly 1 https://wordpress.org/?v=6.2 165828820 Avoid Spaghetti Execution with the Judicious use of Inline Scripting https://blog.mattwynne.net/2007/10/30/avoid-spaghetti-execution-with-the-judicious-use-of-inline-scripting/ https://blog.mattwynne.net/2007/10/30/avoid-spaghetti-execution-with-the-judicious-use-of-inline-scripting/#respond Tue, 30 Oct 2007 08:55:03 +0000 http://blog.mattwynne.net/2007/10/30/avoid-spaghetti-execution-with-the-judicious-use-of-inline-scripting/ Continue reading "Avoid Spaghetti Execution with the Judicious use of Inline Scripting"

]]>
Rob Conery has kicked up a bit of a stink posting about the use of inline scripting in modern ASP.NET apps.

I may post more on this subject when I have time, but I had to just weigh in with my support for disciplined use of this technique, which can save you hundreds of pointless lines of code and execution cycles in a large app if used wisely.

One trick we use is to replace all those silly asp:LinkButton tags with a good ole anchor tag, and a call to a special utility class called LinkBuilder which knows how the site’s URLs hang together, like so:

<a href="<%= LinkBuilder.Show(catalogueItem) %>">Cancel</a>

This sort of markup can hardly be acused of being spaghetti code (the LinkBuilder method has a single line inside it), and means that we avoid what you might call ‘spaghetti execution’ when you actually come to spin the thing up.

Think about what a sequence diagram of the equivalent use of an asp:LinkButton with a wired OnClick event would look like. Eugh.

]]>
https://blog.mattwynne.net/2007/10/30/avoid-spaghetti-execution-with-the-judicious-use-of-inline-scripting/feed/ 0 23