title: What should be the standard coding pattern for Sitecore
body: <p>Using Sitecore 8.0, MVC, VS2015<br>
  I managed to generate the footer content as desired, for a practice site, but would like to know the standard way of doing things. The question is simple, but tried to explain in detail. Please bear with that :)</p>
  
  <p>Requirement: The footer should display Office addresses and they should be editable by the Content author.
  <a href="https://i.stack.imgur.com/JqQDf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JqQDf.png" alt="enter image description here"></a>
  <strong>Sitecore Template :</strong> Location, Telephone 1, Telephone 2, IsActive(type-checkbox).<br>
  <strong>Datasource :</strong> A folder with items of the above template.<br>
  <strong>Code:</strong>     </p>
  
  <pre><code>    public class FooterViewModel 
          {
              public List&lt;Sitecore.Data.Items.Item&gt; Addresses { get; set; }
          }  
  
      public class FooterController : Controller
          {
              public ActionResult Footer()
              {
                  var datasource = RenderingContext.Current.Rendering.Item;
                  FooterViewModel viewModel = new FooterViewModel();            
                  viewModel.Addresses = new List&lt;Item&gt;();
  
              if(datasource != null &amp;&amp; datasource.HasChildren &amp;&amp; datasource.Children.Count &gt; 0)
                  {
                      foreach(Item address in datasource.Children)
                      {
                          if (address["IsActive"] == "1")
                              viewModel.Addresses.Add(address);
                      }
                  }
  
                  return View("~/Views/Shared/Footer.cshtml", viewModel);            
              }
          }
  </code></pre>
  
  <p>Rendering the html using a Sitecore Controller Rendering<br>
  <strong>cshtml:</strong>  </p>
  
  <pre><code>@using Sitecore.Mvc
  @using Sitecore.Mvc.Presentation
  @model Democore.Models.FooterViewModel
  
  &lt;div&gt;
      @foreach (var address in Model.Addresses)
      {
          &lt;div&gt;
              &lt;h3&gt;@Html.Sitecore().Field("Location", address)&lt;/h3&gt;
              &lt;ul&gt;         
                  &lt;li&gt;
                      @Html.Sitecore().Field("Telephone 1", address) 
                  &lt;/li&gt;
                  &lt;li&gt;
                      @Html.Sitecore().Field("Telephone 2", address) 
                  &lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
      }  
  &lt;/div&gt;    
  &lt;div&gt;
      &lt;p&gt;&amp;copy Copyright @DateTime.Now.Year. All rights reserved&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here are my questions. (..well all 3 are more or less similar)   </p>
  
  <ol>
  <li><p>How to better this code/structure (or) in which case might it fail. </p></li>
  <li><p>I did not like the way I hardcoded the field names in controller &amp;
      cshtml. What if the author changes the field names. How to tackle
      that.</p></li>
  <li>How does it work in a real scenario, say for eg if author
      wants to show a third phone number. Will they contact the developer?
      Because that requires a change in design &amp; code too right?</li>
  </ol>