Sitecore Helix – Converting existing Sitecore solution into Helix standards

Helix is a set of overall design principles and conventions for Sitecore development. With the evolution of Sitecore itself and large enterprise solutions growing as per company’s business, there is a requirement to define a standard which simplifies the Sitecore development as well maintenance.

Helix is most buzzed word you will hear nowadays. Most of the Sitecore solutions provider has adopted this standard principle while delivering new and all upcoming Sitecore Web Applications. It is little hard to move from the traditional development (vary by person to person) to Helix standards. But once you are familiar with the terms/Standards, Believe me – You will likely love it. There is a well written documentation on  Helix, Habitat – An example solution based on Helix standards which you can refer as example of Helix, And there are many courses/presentation going on Helix.

We talked about how Helix is changing the whole way we develop the Sitecore web application. What about websites already build on Sitecore before we even heard about Helix? I recently got a chance to work on an existing website build on sitecore to make required changes so that solution become more maintainable and as per new standards for future development. I considered one of the thing to reach our goal is to convert it to Helix standards. Based on my experience doing this, We will be talking about

  • Should we convert existing websites to Helix standards?
    • No, What are the reasons for not doing?
    • Yes, How we can do that?

Should we convert existing websites to Helix Standards?

No, Unless you are willing to convert whole application into Helix standards. which generally does not seems to be possible. You will ask why?, Let’s see what are the reasons of not converting existing websites to Helix standards

What are the reasons for not doing?

Although, Helix gives many benefits, I found below points which were stopping me to perform this conversion into Helix standards:

  • Limited Business Context:
    instead-of-i-dont-know
    In a large organization, where an application gets growing over several years of span time, It is very difficult to find out the person who has the complete business context. It is very difficult to understand the business context from application from mid way, we might not know the actual reasons for some of the implementations. The biggest risk of the limited business context is, while conversion we may break the functionalities unknowingly. For ex: Miss some of the code while conversion, Miss some of the references, Miss some of the hard coded IDs & Paths, Miss some Datasource related changes in Sitecore Items due to new Structure/Items, We cleanup some of the unwanted things which is there for future development etc.
  • Limited Time:
    your-time-is-limited-so-dont-waste-it-living-someones-life-steve-jobs-1-728
    As website is already developed and serving business need, we might not get the time as much as we develop a new website. Converting existing web application to Helix standards requires huge amount of time as much as new development from scratch we can say. So, with the limited time duration, we might end up doing mix of traditional and Helix standards. Which is not a good solution from the eye of a good solution architect.
  • Limited Knowledge of Helix:
    quote-integrity-without-knowledge-is-weak-and-useless-and-knowledge-without-integrity-is-dangerous-and-samuel-johnson-95971While working along with different set of people in different teams (In house team, Consultant team etc.), It is very difficult to set the rules and expectations. Although, there are set of rules and recommendations mentioned in Helix standards, One may act differently. For ex: One developer created Foundation for few set of feature, few will create Feature for same, others may argue that it should be in Project and rest just doesn’t follow Helix standards and place everything except Feature/Foundation/Project. This will again end up in duplicate, inconsistent, difficult to understand code/structure.
  • Not adding business value:
    cartoon-why_vision_is_imp
    Spending so much time, money, and efforts and at the end not getting direct business value might not impress to many business people. And i think it is right too at some point of time. Q: What business value it will add? Ans: More development in standard way, Less efforts and time  going forward, and maintainability. Q: What business value it will add right now? Ans: can’t think off.

These are the several factors to keep in mind before jumping in converting everything into Helix standards. But if knowing all these points, we really wanted to convert the existing Sitecore website eventually into Helix standards, we can do in below way.

How we can do that?

Considering fact that we can not start developing existing websites in Helix standards along side existing website. It will than become a development from scratch which is going to take many months, and with this separate development to convert existing website to Helix standard, there will also be some modification and new feature in existing website. Merging these new feature along way with new development is not going to be an easy job.

The approach we can take:

  • Create a blank structure as per Helix standards. https://www.npmjs.com/package/generator-helix. It is now also available as Visual Studio template https://github.com/LaubPlusCo/LaubPlusCo.Helix.VsTemplates
  • Add one empty project application which can act as a heart. No need to jump to Feature and Foundation at this stage.
  • Create a Foundation project named Legacy. Why Foundation and not Feature/Project layer for this purpose?

    Ans: The reason why I’ve put it into Foundation layer is because we can also start implementing new features etc. but we need to make sure that the “old” project still works. So basically we have the Vanila Sitecore instance at the bottom, on top there is the old project and on top of that we can implement new stuff and/or move stuff out of the old project Also one point why it’s not in the Project layer is because, of the references. If you convert part of it into Feature Layer, you cannot have a reference to the Project Layer. But you can have one to the Foundation Layer. Thanks to @nadinelendzian for discussion on this.

  • Put everything from old solution under this Legacy Foundation project.
  • Make sure at this point everything is working fine as it was.
  • Eventually start separating out functionality into different Feature/Foundation/Project layer.

Please find below images as an example:

Before Helix

Sitecore Content Tree

old-1
Content
old-2.1
Layouts
old-2
Renderings
old-3
Templates

Visual Studio Solution
NonHelixVS

After Helix

Sitecore Content Tree

new-1
Renderings
new-2
Layouts
new-3
Templates

Visual Studio Solution
HelixVS

These are some of the example of how an existing solution can be converted to Helix standards gradually.

Again it is my personal view, If you have some other thoughts on converting existing Sitecore websites to Helix standards, I would love to hear that.

I love Helix 🙂

 

Advertisements

Setting up Habitat without having Visual Studio installed on server

Have you started checking Habitat architecture? If no, this is the best time to get started as Sitecore is evolving faster than it used to and customers are also asking competitive and best enterprise solutions. In this case sometime it becomes difficult to manage your project architecture specially in a big project/team. So, why not look at Habitat? an example provided by Sitecore as a best practice for Sitecore projects based on Helix architecture.

There are many resources available on how to setup Habitat for sitecore correctly like
https://github.com/Sitecore/Habitat (source code)
https://github.com/Sitecore/Habitat/wiki/01-Getting-Started (Geting started guide)
https://www.youtube.com/watch?v=FNqKZN9DH5I (step by step video tutorial on how to setup Habitat for Sitecore)

I ran into a situation where i needed to setup a Habitat on a plain server where i won’t find IIS, Visual Studio etc. installed.

So, lets get on a tour on setting up Habitat without VS installed, Issues which we might face and solutions.

  1. Install plain Sitecore: first step first. Install a plain Sitecore 8.2 Update 1 on which we will setup Habitat. We will use this later
  2. Clone/Download Habitat project: Clone the Habitat repository or download zip from https://github.com/Sitecore/Habitat.
  3. Node.Js: Install latest Node.Js from https://nodejs.org/en/
  4. Perform all the steps specified in https://github.com/Sitecore/Habitat/wiki/01-Getting-Started until step 5. Or you can follow the video tutorial https://www.youtube.com/watch?v=FNqKZN9DH5I
  5. Now, we have arrived at the step to build and publish the solution to the Habitat Sitecore website we installed in the beginning.
  6. Without having Visual Studio installed, we cannot use Task Runner Explorer of VS. So, we have to use command window to run gulp command.

Now, you will start encountering the issues when trying to run gulp commands using command prompt. Some of issues and solutions are mentioned below:

  1. Go to the project directory where you have cloned the habitat project or downloaded and unzipped a project.
  2. Run npm gulp command in that directory on to command window.
  3. Now, if you have not installed all the required modules properly from npm and try to execute gulp task like gulp default, then it will start giving error. In my case it was cannot find module gulp-msbuild. so rather running npm gulp command in project directory, run npm install command so that it will install all the required plugins along with gulp.
  4. I tried to run the default task specified in gulpfile.js using gulp default command. And i got the error saying gulp is not recognized as internal or external command. You required gulp-cli package to be installed to run gulp command from command window. So, if it is missing and you are facing this issue than run npm install -g gulp-cli command. Now once you have installed this package you can run the gulp command as gulp default from the command window.
  5. Running gulp default command again, You may face error saying Nuget package installation failed. As VS is not installed, Nuget will not be installed by default.So, you have to install Nuget command line from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe or https://docs.nuget.org/consume/command-line-reference/.
  6. Running gulp default command again, Nuget package installation will get complete but you may face error saying Build Failed. As VS is not installed on server. So, you will required to install MSBuild tool. You can find it here: https://www.microsoft.com/en-in/download/details.aspx?id=48159
  7. Running gulp default command again, i got error saying MSBuild – microsoft.webapplication.targets was not found issue even though we have installed MSBuild tool on the server. To resolve this, i just copied C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications folder from local to the server and tried run command again.
  8. Encountered error stdout maxbuffer exceeded, error in build gulp task.
    So, i come to know that there must be something tricky with MSBuild. It is missing something that generally shifts with VS in our local machine. I found a solution as per: http://nickberardi.com/a-net-build-server-without-visual-studio. We need to perform third step from the link, which says copy both the below folders from your local machine to server:

    • C:\Program Files (x86)\MSBuild
    • C:\Program Files (x86)\Reference Assemblies

    Between those two directories MSBuild and Reference Assemblies you have most everything you need to complete any build that Visual Studio can do by it self. And the above steps while simple, but not obvious, provide a nice clean build server that doesn’t require Visual Studio to operate.

Keep reading Helixian.