Skip to main content

Posts

Showing posts with the label .Net

SOLID Principles in Software Development

  The SOLID principle was introduced by Robert C. Martin, also known as Uncle Bob and it is a coding standard in programming. This principle is an acronym of the five principles which is given below- Single Responsibility Principle (SRP) Open/Closed Principle Liskov’s Substitution Principle (LSP) Interface Segregation Principle (ISP) Dependency Inversion Principle (DIP) Single Responsibility Principle:  A class should have only one reason to change This  means every class should have a single responsibility or purpose. The class shall be updated only when a the behavior for this single responsibility changes. For E.g. If a class is responsible for login logic, then that is all it should do. Any other similar functionalities like Registration or Change Password should be implemented separately. As such, only when a change is required in Login logic will cause the class to be updated. If we keep updating a class for adding features which are not related to a single purpose, it makes the

How to push items linked in rendering data sources to next workflow state in Sitecore

Workflow implementation is important for content governance. When content author updates a page in Sitecore experience editor, Sitecore notifies content author to submit the page to push it to next workflow state.  But what about the rendering data sources present on the page. Do they get pushed to next workflow state or not?  Sitecore does push the rendering data source items present on page to next workflow state if you have the below setting set to true in your configs (which is true by default Sitecore 8.2 onwards) -  <setting name="WebEdit.AffectWorkflowForDatasourceItems" value="true" patch:source="Sitecore.ExperienceEditor.config"/> However, that's not all. Some of the rendering data sources may be dependent on other items (we will call them linked items), especially for container renderings (which act as container for other data items). There is no setting in Sitecore OOB that can push the linked items to next workflow state. Content auth

Custom Buttons in Sitecore Experience Editor

Experience editor gives WYSIWYG (What you see is what you get) experience to content authors in Sitecore. Most of the fields defined in templates for components are directly editable in the experience editor mode including images, text, links and many others (Thanks to the Sitecore field renderers implemented in the view!) However, there are scenarios in which some of your fields won’t be easily editable on the page in the experience editor. For example, if you want to provide spacing or width options in a component to content author, they are not directly editable within experience editor like the images and text. Such fields are usually created using droplinks or check boxes. In such cases, it is desirable to create a custom button that will let you edit such fields. This custom button will be visible in experience editor when user clicks on the rendering. On clicking this custom button, a dialog containing the fields that we want to edit in experience editor will open up.  Steps to

Sitecore Link Database Quick Tips

The Link database saves all links between Sitecore items across the databases (core, master, web) and across the language versions. This database helps to find out not only the list of items, which the specific item refers to but also the items which refer this item. For example, a page created from a specific template contains a reference to that template and vice versa.  In content editor, this database is used in “Navigate -> Links“. or when u delete an item, it asks what you should do with the existing links to the item to be deleted -  The link database is primarily a table (dbo.Links) within our core db configured as - < LinkDatabase type = "Sitecore.Data.$(database).$(database)LinkDatabase, Sitecore.Kernel" >        < param connectionStringName = "core" /> </ LinkDatabase > Link db gets updated on following events - item:saved item:deleted item:copied item:versionRemoved Link db can be rebuilt as - Same can be done programmatically as -

Clean Coding Principles in CSharp

A code shall be easy to read and understand. In this post, I am outlining basic principles  about clean coding after researching through expert recommended books, trainings and based on my experience. A common example to start with is a variable declaration like - int i  The above statement did not clarify the purpose of variable i. However,  the same variable can be declared as -  int pageNumber The moment we declared the variable as int pageNumber, our brain realized that the variable is going to store the value for number of pages. We have set the context in our brain now and it is ready to understand what the code is going to do next with these page numbers. This is one of the basic advantages of clean coding. Reasons for clean coding -  • Reading clean code is easier - Every code is revisited after certain amount of time either by the same or different developer who created it. In both the cases, if the code is unclean, its difficult to understand and update it. • To avoid s