Is it correct that homeitem
should be declared inside the OnLoad
method and overgiven to all the render methods instead of just declaring it as a global variable and accessing it by all the render methods?
public partial class Default : Page
{
/// <summary>
/// Initializes the module.
/// </summary>
/// <param name="e">
/// The event arguments.
/// </param>
protected override void OnLoad(EventArgs e)
{
var homeItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath);
// some code...
this.RenderHomeIcon(homeItem);
this.RenderFacebookTags();
this.RenderLanguageEntries();
this.RenderServiceNavigation(homeItem);
this.RenderMainNavigation();
this.RenderCallToActionItems(homeItem, isHomeItem);
this.RenderFooterMainNavigation(homeItem);
this.RenderContact(homeItem);
this.RenderFooterCulture(homeItem);
if (isHomeItem)
{
this.InterfererToolbar(homeItem);
this.RenderWebcamViews(homeItem);
webcam.Visible = true;
}
// some more code...
}
}
I'd just like to know what is correct / standard so I can stick to that!
Default
. I'd be more worried about the nameDefault
, the huge number of pointlessthis.
suffixes and the length of the method (how much code is in// some code...
and// some more code...
), than choosing between passinghomeItem
as a parameter versus making it a field.this.
's.