Note that there are some explanatory texts on larger screens.

plurals
  1. POIn a strongly-typed world, why isn't ASP.NET MVC's fragile dependency on naming conventions frowned upon?
    text
    copied!<p>Since forever, strongly-typed objects have been a foundation of object-oriented programming. Fast-forward to 5 minutes ago, when working with the Entity Framework and MVC3, I was forced to add this to my Web.config:</p> <pre><code>&lt;connectionStrings&gt; &lt;add name="_MY_EXACT_CLASS_NAME_DbContext" connectionString="Data Source=blahblah.../&gt; &lt;/connectionStrings&gt; </code></pre> <p>Great, My entire application depends on an arbitrarily-chosen name in an XML attribute. Is this really what modern programming looks like? Misspelling a class name is a serious offense, one the compiler leads us directly into fixing, but in this case, I'll just get a runtime exception message. If Mr. aforementioned exception message in a good mood, he'll point me toward Mordor, and I'll trudge off toward another Mount Doom of wasted debugging hours to destroy the invisible One-Typo-To-Rule-Them-All.</p> <p>The same goes for Controllers:</p> <pre><code>routes.MapRoute("BE_CAREFUL","{controller}/{action}/{id}", new { controller = "ONE_FALSE_MOVE_AND", action = "BUT_I_SWEAR_IT_SAID_BUILD_SUCCEEDED" } ); </code></pre> <p>It seems like things come and go in waves. Strongly-typed objects had their day in the sun, and now we're all girl-next-door over the anonymous "var". I'll admit, being coy about your type stirs up a lot of sexy scenarios - especially knowing you don't have to do any setup work - but here's The Actual Question:</p> <p><strong>How do the forefathers of object-oriented programming feel about our "advancement" of their art by adding a bunch of wishy-washy, do-sorta-whatever anonymous constructs while at the same time creating fragile dependencies on naming conventions?</strong></p> <p>For all we know, MVC4 might suddenly require that all names be preceded by exactly 4.7 spaces followed by lolcat ASCII art. Why? Because yes, that's why. Take a moment and marvel at the fact that you just witnessed the birth of a naming convention. Obviously, this is seriously solid foundational material for a flagship framework.</p> <p>So, if there's one thing I want my entire codebase to both functionally and philosophically depend on, there's nothing more mission-critical to the mathematic logic of programming than..... Microsoft's® English-Language Naming Conventions!</p> <pre><code>&lt;/sarcasm&gt; &lt;/griping&gt; &lt;!-- resume enjoying all of MVC's amazing features, after eating any humble pie served up in the comments --&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload