<?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: Those pesky indexers!</title>
	<atom:link href="http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Mon, 07 May 2012 07:05: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: Reshef Mann</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-22</link>
		<dc:creator>Reshef Mann</dc:creator>
		<pubDate>Sun, 05 Oct 2008 06:24:21 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-22</guid>
		<description>On a monorail project I did I used the Castle dictionary adapter http://www.castleproject.org/components/dictionaryadapter/basics.html
to handle this exact issue.</description>
		<content:encoded><![CDATA[<p>On a monorail project I did I used the Castle dictionary adapter <a href="http://www.castleproject.org/components/dictionaryadapter/basics.html" rel="nofollow">http://www.castleproject.org/components/dictionaryadapter/basics.html</a><br />
to handle this exact issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Sheldon</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-21</link>
		<dc:creator>Steve Sheldon</dc:creator>
		<pubDate>Fri, 03 Oct 2008 18:41:20 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-21</guid>
		<description>I see what you are doing, and I have to think about this a bit.

I hate referencing anything with a hardcoded string.  Configuration settings, dictionary, whatever.  In such cases I&#039;ll use constants, or wrap it kind of like you did.  I do this with configurationmanager calls all the time.

</description>
		<content:encoded><![CDATA[<p>I see what you are doing, and I have to think about this a bit.</p>
<p>I hate referencing anything with a hardcoded string.  Configuration settings, dictionary, whatever.  In such cases I&#8217;ll use constants, or wrap it kind of like you did.  I do this with configurationmanager calls all the time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mbratton</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-20</link>
		<dc:creator>mbratton</dc:creator>
		<pubDate>Fri, 03 Oct 2008 14:46:35 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-20</guid>
		<description>@Fregas:

One the goals to this was to have a single interface to interact with the view page. In the approach of using a ModelBinder and a typed viewpage, I have two different methods of interacting with the view (depending on if I&#039;m retrieving information or sending information).

On top of that, I have to write additional classes for the ModelBinder and if I need to use more than one object to send to the view, I&#039;m writing wrapper objects that exist only because I&#039;m wanting to interact with the model in a way that isn&#039;t natively supported. At that point I feel like I&#039;d be losing the advantage of what you&#039;re prosposing here, as there isn&#039;t too much difference conceptually between writing a wrapper for multiple objects and what I&#039;ve posted above.

Not saying my way is better, but I don&#039;t really think the level of effort involved is greater than the proposed alternative. Additionally, all code dealing with it is located in one place.</description>
		<content:encoded><![CDATA[<p>@Fregas:</p>
<p>One the goals to this was to have a single interface to interact with the view page. In the approach of using a ModelBinder and a typed viewpage, I have two different methods of interacting with the view (depending on if I&#8217;m retrieving information or sending information).</p>
<p>On top of that, I have to write additional classes for the ModelBinder and if I need to use more than one object to send to the view, I&#8217;m writing wrapper objects that exist only because I&#8217;m wanting to interact with the model in a way that isn&#8217;t natively supported. At that point I feel like I&#8217;d be losing the advantage of what you&#8217;re prosposing here, as there isn&#8217;t too much difference conceptually between writing a wrapper for multiple objects and what I&#8217;ve posted above.</p>
<p>Not saying my way is better, but I don&#8217;t really think the level of effort involved is greater than the proposed alternative. Additionally, all code dealing with it is located in one place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fregas</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-19</link>
		<dc:creator>Fregas</dc:creator>
		<pubDate>Fri, 03 Oct 2008 12:53:39 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-19</guid>
		<description>I have to agree with Chris C is that this looks like a lot of work.  I think you&#039;re doing it the hard way.  I don&#039;t use the dictionaries at all.  MVC ViewData and Views have a strongly typed option using generics, so thats what I use.  Rather than making an &quot;AddUserView&quot; that wraps the dictionary, I would bind my view directly to one or more model/business objects.  So for example, if I have an array of product objects I want to display, I would simply declare my viewpage like such:

public partial class AddUser: ViewPage&lt;User&gt;

Then in my controller, I add the user to its view like so:

this.ViewData.Model = _userRepository.GetUser(id);
return View();

If there is more then one object I need to pass, I do something similar and make a very small wrapper class.  So if I had to pass a User and an array of Photos for example, I might already have a User object and a Photo object in my domain, and wrap them like this:

public class AddUserModel
{
  public User User {get;set;}
  public Photo[] Photos {get;set;}
}

then change my view to do this:

public partial class AddUser: ViewPage&lt;AddUserModel&gt;

similar to what you&#039;re doing, but less work because I&#039;m using existing business objects rather than making a wrapper around all the ViewData dictionary stuff.
</description>
		<content:encoded><![CDATA[<p>I have to agree with Chris C is that this looks like a lot of work.  I think you&#8217;re doing it the hard way.  I don&#8217;t use the dictionaries at all.  MVC ViewData and Views have a strongly typed option using generics, so thats what I use.  Rather than making an &#8220;AddUserView&#8221; that wraps the dictionary, I would bind my view directly to one or more model/business objects.  So for example, if I have an array of product objects I want to display, I would simply declare my viewpage like such:</p>
<p>public partial class AddUser: ViewPage<user></p>
<p>Then in my controller, I add the user to its view like so:</p>
<p>this.ViewData.Model = _userRepository.GetUser(id);<br />
return View();</p>
<p>If there is more then one object I need to pass, I do something similar and make a very small wrapper class.  So if I had to pass a User and an array of Photos for example, I might already have a User object and a Photo object in my domain, and wrap them like this:</p>
<p>public class AddUserModel<br />
{<br />
  public User User {get;set;}<br />
  public Photo[] Photos {get;set;}<br />
}</p>
<p>then change my view to do this:</p>
<p>public partial class AddUser: ViewPage<addusermodel></p>
<p>similar to what you&#8217;re doing, but less work because I&#8217;m using existing business objects rather than making a wrapper around all the ViewData dictionary stuff.<br />
</addusermodel></user></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Nijhof</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-18</link>
		<dc:creator>Mark Nijhof</dc:creator>
		<pubDate>Fri, 03 Oct 2008 07:27:19 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-18</guid>
		<description>I like what you have done, it may be a little bit more work to create but definitely easier to maintain. And no more confusion about what certain fields are called.</description>
		<content:encoded><![CDATA[<p>I like what you have done, it may be a little bit more work to create but definitely easier to maintain. And no more confusion about what certain fields are called.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Reynolds</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-17</link>
		<dc:creator>Bryan Reynolds</dc:creator>
		<pubDate>Fri, 03 Oct 2008 07:17:26 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-17</guid>
		<description>Great article.  I agree that the ModelBinder is a potential solution in some cases. </description>
		<content:encoded><![CDATA[<p>Great article.  I agree that the ModelBinder is a potential solution in some cases. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mbratton</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-16</link>
		<dc:creator>mbratton</dc:creator>
		<pubDate>Fri, 03 Oct 2008 02:08:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-16</guid>
		<description>@Chris C:

Yeah I&#039;ve looked at Binders... they look cool. The point of what I have here was supposed to be that you use one instance (in this case AddUserView) to either pull values from the form or send values to viewdata. 

Also, this was before we moved everything to preview 5. ;)

In terms of actual work, like most classes once it&#039;s set up it&#039;s a simple matter of leveraging the functionality. Plus it simplified things for the developers I&#039;ve been mentoring on ASP.NET MVC ... just create a view, inherit from this class and then all access is pretty much the same. Get and Set. I find that repeatable patterns help people when they&#039;re first learning something.

I&#039;ve no doubt that this could be better implemented, or there are better approaches, though, but it worked for us. :D</description>
		<content:encoded><![CDATA[<p>@Chris C:</p>
<p>Yeah I&#8217;ve looked at Binders&#8230; they look cool. The point of what I have here was supposed to be that you use one instance (in this case AddUserView) to either pull values from the form or send values to viewdata. </p>
<p>Also, this was before we moved everything to preview 5. <img src='http://lostechies.com/marcusbratton/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>In terms of actual work, like most classes once it&#8217;s set up it&#8217;s a simple matter of leveraging the functionality. Plus it simplified things for the developers I&#8217;ve been mentoring on ASP.NET MVC &#8230; just create a view, inherit from this class and then all access is pretty much the same. Get and Set. I find that repeatable patterns help people when they&#8217;re first learning something.</p>
<p>I&#8217;ve no doubt that this could be better implemented, or there are better approaches, though, but it worked for us. <img src='http://lostechies.com/marcusbratton/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jimmy Bogard</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-15</link>
		<dc:creator>Jimmy Bogard</dc:creator>
		<pubDate>Fri, 03 Oct 2008 01:52:05 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-15</guid>
		<description>Believe it or not, I recently saw a large codebase where every method parameter was a NameValueCollection.</description>
		<content:encoded><![CDATA[<p>Believe it or not, I recently saw a large codebase where every method parameter was a NameValueCollection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris C</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-14</link>
		<dc:creator>Chris C</dc:creator>
		<pubDate>Thu, 02 Oct 2008 23:42:04 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-14</guid>
		<description>That seems like alot of work but I get where you&#039;re coming from.  Have you looked at using the ModelBinder stuff? I wrote a stupid little automagical wiring thingy here: http://panteravb.com/blog/posts/2008/10/2/imodelbinder-with-autobinder.ashx, it&#039;s nothing great but saves me a lot of typing.</description>
		<content:encoded><![CDATA[<p>That seems like alot of work but I get where you&#8217;re coming from.  Have you looked at using the ModelBinder stuff? I wrote a stupid little automagical wiring thingy here: <a href="http://panteravb.com/blog/posts/2008/10/2/imodelbinder-with-autobinder.ashx" rel="nofollow">http://panteravb.com/blog/posts/2008/10/2/imodelbinder-with-autobinder.ashx</a>, it&#8217;s nothing great but saves me a lot of typing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tasarım</title>
		<link>http://lostechies.com/marcusbratton/2008/10/02/those-pesky-indexers/#comment-13</link>
		<dc:creator>tasarım</dc:creator>
		<pubDate>Thu, 02 Oct 2008 21:57:45 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2008/10/02/those-pesky-indexers.aspx#comment-13</guid>
		<description>Well you are actually right that is the FAULT of lazy programmers(including me and 90% of them). But code seems interesting</description>
		<content:encoded><![CDATA[<p>Well you are actually right that is the FAULT of lazy programmers(including me and 90% of them). But code seems interesting</p>
]]></content:encoded>
	</item>
</channel>
</rss>
