<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Expressive Code: Good Variable Names Instead Of Magic Values And Calculations</title>
	<atom:link href="http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/</link>
	<description>Better Than Yesterday</description>
	<lastBuildDate>Fri, 17 May 2013 03:30:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Ufuk Kayserilioglu</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-860</link>
		<dc:creator>Ufuk Kayserilioglu</dc:creator>
		<pubDate>Sun, 25 Apr 2010 10:45:23 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-860</guid>
		<description>I am all for the more readable code; however, the two versions of the code do not produce the same output. In the first one, for the second DrawLine call you have a &quot;ClientRectangle.Width&quot;. In the more readable version that gets changed to &quot;right&quot;, which actually stands for &quot;ClientRectangle.Width - 1&quot;.

Am I missing something?</description>
		<content:encoded><![CDATA[<p>I am all for the more readable code; however, the two versions of the code do not produce the same output. In the first one, for the second DrawLine call you have a &#8220;ClientRectangle.Width&#8221;. In the more readable version that gets changed to &#8220;right&#8221;, which actually stands for &#8220;ClientRectangle.Width &#8211; 1&#8243;.</p>
<p>Am I missing something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Hare</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-859</link>
		<dc:creator>Andrew Hare</dc:creator>
		<pubDate>Fri, 23 Apr 2010 12:33:55 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-859</guid>
		<description>This is really good advice as magic values really hurt the readability and maintainability of your code.  I would argue that this is a hallmark of a declarative style of coding (being more expressive and ultimately more readable).  I wrote a similar article myself (http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/) that focused more on method names than variable names but the concept is the same - declarative code is better for everyone!</description>
		<content:encoded><![CDATA[<p>This is really good advice as magic values really hurt the readability and maintainability of your code.  I would argue that this is a hallmark of a declarative style of coding (being more expressive and ultimately more readable).  I wrote a similar article myself (<a href="http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/" rel="nofollow">http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/</a>) that focused more on method names than variable names but the concept is the same &#8211; declarative code is better for everyone!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: derick.bailey</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-858</link>
		<dc:creator>derick.bailey</dc:creator>
		<pubDate>Thu, 22 Apr 2010 18:53:13 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-858</guid>
		<description>@dave-ilsw

if i was drawing a line along the bottom of the button, then yes it would matter and it should have a -1 on the bottom variable. but in this case, i am only drawing on the left, top, and right borders so it doesn&#039;t matter.</description>
		<content:encoded><![CDATA[<p>@dave-ilsw</p>
<p>if i was drawing a line along the bottom of the button, then yes it would matter and it should have a -1 on the bottom variable. but in this case, i am only drawing on the left, top, and right borders so it doesn&#8217;t matter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Sonmez</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-857</link>
		<dc:creator>John Sonmez</dc:creator>
		<pubDate>Thu, 22 Apr 2010 18:18:56 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-857</guid>
		<description>@David

I like that one.</description>
		<content:encoded><![CDATA[<p>@David</p>
<p>I like that one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Pendray</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-856</link>
		<dc:creator>David Pendray</dc:creator>
		<pubDate>Thu, 22 Apr 2010 17:39:22 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-856</guid>
		<description>Is 8 extra setup lines excessive? If not, I&#039;d put forward:

            int left = 0;
            int right = ClientRectangle.Width - 1;
            int top = 0;
            int bottom = ClientRectangle.Height;

            var leftTop = new Point(left, top);
            var rightTop = new Point(right, top);
            var leftBottom = new Point(left, bottom);
            var rightBottom = new Point(right, bottom);

            graphics.DrawLines(outlinePen, new[] { leftBottom, 
                                                                             leftTop, 
                                                                             rightTop, 
                                                                             rightBottom });

With the final call reading: &quot;leftBottom to leftTop to RightTop to RightBottom&quot;.</description>
		<content:encoded><![CDATA[<p>Is 8 extra setup lines excessive? If not, I&#8217;d put forward:</p>
<p>            int left = 0;<br />
            int right = ClientRectangle.Width &#8211; 1;<br />
            int top = 0;<br />
            int bottom = ClientRectangle.Height;</p>
<p>            var leftTop = new Point(left, top);<br />
            var rightTop = new Point(right, top);<br />
            var leftBottom = new Point(left, bottom);<br />
            var rightBottom = new Point(right, bottom);</p>
<p>            graphics.DrawLines(outlinePen, new[] { leftBottom,<br />
                                                                             leftTop,<br />
                                                                             rightTop,<br />
                                                                             rightBottom });</p>
<p>With the final call reading: &#8220;leftBottom to leftTop to RightTop to RightBottom&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PatrickM</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-855</link>
		<dc:creator>PatrickM</dc:creator>
		<pubDate>Thu, 22 Apr 2010 17:07:18 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-855</guid>
		<description>That&#039;s one of the goals for the new syntax in C# 4.0:

If you have a method:
public void Do(string action, int time);

You can optionally call it this way:
Do(action: &quot;Execute&quot;, time: 5);

And by the way, the parameter ordering does not have to be the same as the definition:
Do(time: 5, action: &quot;Execute&quot;);

Regards,</description>
		<content:encoded><![CDATA[<p>That&#8217;s one of the goals for the new syntax in C# 4.0:</p>
<p>If you have a method:<br />
public void Do(string action, int time);</p>
<p>You can optionally call it this way:<br />
Do(action: &#8220;Execute&#8221;, time: 5);</p>
<p>And by the way, the parameter ordering does not have to be the same as the definition:<br />
Do(time: 5, action: &#8220;Execute&#8221;);</p>
<p>Regards,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dave-ilsw</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-854</link>
		<dc:creator>dave-ilsw</dc:creator>
		<pubDate>Thu, 22 Apr 2010 16:03:47 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-854</guid>
		<description>Should bottom subtract one from Height like right subtracts one from Width?</description>
		<content:encoded><![CDATA[<p>Should bottom subtract one from Height like right subtracts one from Width?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Sonmez</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-853</link>
		<dc:creator>John Sonmez</dc:creator>
		<pubDate>Thu, 22 Apr 2010 14:38:06 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-853</guid>
		<description>Whoops that was wierd, let me try one more time.

private class LineSegment
        {
            public int StartX { get; set; }
            public int EndX { get; set; }
            public int StartY { get; set; }
            public int EndY { get; set; }
        }

int left = 0;
            int right = ClientRectangle.Width - 1;
            int top = 0;
            int bottom = ClientRectangle.Height;


            IList&lt;LineSegment&gt; lineSegments = new List&lt;LineSegment&gt;
                                                  {{StartX = left, StartY = top, EndY = left, EndY = bottom},
                                                   {StartX = left, StartY = top, EndY = right, EndY = top},
                                                  {StartX = right, StartY = top, EndY = right, EndY = bottom}};

            foreach(var lineSegment in lineSegments)
            {
                graphics.DrawLine(outlinePen, lineSegment.StartX, lineSegment.StartY, lineSegment.EndX, lineSegment.EndY);
            }</description>
		<content:encoded><![CDATA[<p>Whoops that was wierd, let me try one more time.</p>
<p>private class LineSegment<br />
        {<br />
            public int StartX { get; set; }<br />
            public int EndX { get; set; }<br />
            public int StartY { get; set; }<br />
            public int EndY { get; set; }<br />
        }</p>
<p>int left = 0;<br />
            int right = ClientRectangle.Width &#8211; 1;<br />
            int top = 0;<br />
            int bottom = ClientRectangle.Height;</p>
<p>            IList
<linesegment> lineSegments = new List</linesegment>
<linesegment>
                                                  {{StartX = left, StartY = top, EndY = left, EndY = bottom},<br />
                                                   {StartX = left, StartY = top, EndY = right, EndY = top},<br />
                                                  {StartX = right, StartY = top, EndY = right, EndY = bottom}};</p>
<p>            foreach(var lineSegment in lineSegments)<br />
            {<br />
                graphics.DrawLine(outlinePen, lineSegment.StartX, lineSegment.StartY, lineSegment.EndX, lineSegment.EndY);<br />
            }</linesegment>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Sonmez</title>
		<link>http://lostechies.com/derickbailey/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations/#comment-852</link>
		<dc:creator>John Sonmez</dc:creator>
		<pubDate>Thu, 22 Apr 2010 14:32:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/22/expressive-code-good-variable-names-instead-of-magic-values-and-calculations.aspx#comment-852</guid>
		<description>Good example.  I have written the same code before and been confused, because I didn&#039;t do what you are suggesting here.

Here is an even clearer version at the cost of some more code:

 private class LineSegment
        {
            public int StartX { get; set; }
            public int EndX { get; set; }
            public int StartY { get; set; }
            public int EndY { get; set; }
        }

StartY, lineSegment.EndX, lineSegment.EndY);
            }

          </description>
		<content:encoded><![CDATA[<p>Good example.  I have written the same code before and been confused, because I didn&#8217;t do what you are suggesting here.</p>
<p>Here is an even clearer version at the cost of some more code:</p>
<p> private class LineSegment<br />
        {<br />
            public int StartX { get; set; }<br />
            public int EndX { get; set; }<br />
            public int StartY { get; set; }<br />
            public int EndY { get; set; }<br />
        }</p>
<p>StartY, lineSegment.EndX, lineSegment.EndY);<br />
            }</p>
]]></content:encoded>
	</item>
</channel>
</rss>
