Skip to main content

Sitecore - Module based approach

Okay so this is something I picked up from a recent developer group thingy and have been annoying my colleagues about this since then.
Instead of thinking Sitecore as one project (MVC) solution why not treat it like a module/deliverable based implementation.
I have created a sample solution which is here: https://bitbucket.org/ali_nahid/sckitchensync
 
The idea is pretty simple (Just like DDD pattern):
You get a rough idea of the entire implementation like what are the deliverable, functionalities etc etc and group them. Then just like the way you plan renderings on your page you plan bunch of different modules to implement in your solution.
In my case I divided my sitecore implementation into the following modules:
1.      The core:
This module contains the layouts and core renderings. In my case
1 standard layout that just defines the top level placeholders. Like header, footer, content etc.
And a “_MainContent” rendering that defines the other placeholders like bodycontent, bannerimage
And obviously the header, footer type of things that are going to be pretty much same throughout the entire site.
I’d give this task to “Gru” the evil genius.
2.      The Meta:
This module only handles the meta content (google meta, facebook meta, perhaps some GA code etc) of the site.
Let’s say “donny” the minion does it.
3.      The Navigation:
This module handles anything to do with site navigation like top navigation menu, breadcrumb, footer menu etc.
Let’s say “dave” the minion does it.
4.      The Imagery:
This module handles thing like “Banner”, Background, Carousel etc.
Let’s say “carl” the one eyed minion does it.
Each of these modules deal with their own set of sitecore renderings.
Interesting thing about this approach is these modules are MVC projects of its own. Sitecore is not restricting you from doing so. Who said only one MVC project for one sitecore website?
Ofcourse the "Domain POCOs" and "Service" and "Repository" layer concept exists as it is. And you can either separate them as per module or have them in their own projects is a personal preference.
 
Visualizing the above description:

instead of doing this:


We do this:


The few pros about this approach I could think of are:
1.      It can be very efficient in doing something like the following:
So you deliver a basic site with “Core, Navigation” module. Then you install/put “Imagery” Module. Then “The fancy” looking landing page module. And so on.  Each of these deliverable are independent to each other. So very less chance of breaking one while delivering the new feature because they’re all separate set of dlls.
 
2.     Easy to distribute work:
As per description each minion can take care of and be responsible for each module. This can come in handy to track progress.
3.      Once done maintaining becomes easier:
Because if something goes wrong or some changes required to make to the, for example Imagery module, you only look into “KitchenSync.Imagery.MVC” project as opposed to be bombarded by a massive MVC project.
4.      Creates a repository of re-usable components/modules. So there can be “Oakton sitecore repository” where you can search and download a module.
For example you need a navigation on your project download the navigation module from the repository.. you probably will need to made the tweak in the cshtml file to match the markup but the logic of how the navigation work remains the same. As a result you save yourself from creating bunch of sitecore renderings and classes.
5.      If gets follow through then this approach enforces a consistent culture of naming convention, field definition etc.
For example, on a page there’re often commonly 2 fields that exists. A summary and a description. Some calls it Short Description, Long Description and some calls it Summary and Description. Why not agree to one. They both mean the same.
6.      Testing is easier too. As you are testing one module at a time.
 
If you’re worried about how you launch it with IIS if there’re multiple MVC projects in the implementation, that’s not an issue either. So this is what I have done:
I have a typical sitecore installation which my IIS is pointing to and I am treating it as publish directory. My build settings puts the dlls to the publish directory /bin location so they become available to sitecore.
Then a simple powershell script copies the views to the publish directory’s Views accordingly. This script can be hooked to a VS post publish (I still don’t know how to do it)

So what you think? Worth it not Worth it? 

Comments

Popular posts from this blog

The story of a Hack Job

"So, you have hacked it" -- Few days ago one of the guys at work passed me this comment on a random discussion about something I built. I paused for a moment and pondered: Do I reply defending how that's not a hack. OR Do I just not bother I picked the second option for 2 reasons: It was late. It probably isn't worth defending the "hack vs" topic as the comment passed was out of context. So I chose the next best action and replied "Yep, sure did and it is working great.". I felt like Batman in the moment. In this post I will rant about the knowledge gap around hacking and then describe about one of the components of my home automation project (really, this is the main reason for this post) and use that as an example how hacking is cool and does not always mean bad. But first lets align on my definition of hacking: People use this term in good and bad, both ways. For example: "He/she did a hack job" -- Yeah, that probably...

Kubectl using SSH tunnel for TKG K8s Clusters

We know SSH'ing and probably many knows about SSH tunnel. The way, in my opinion, these 2 (SSH and SSH tunnel) are different to me (and I am in favor of SSH Tunnel) is how I use it. From tooling perspective I would almost always do tunnel instead of direct ssh.  In this post I will describe how to do SSH tunnel for kubectl to interact with remote kubernetes cluster (Specifically Tanzu Kubernetes Grid aka TKG cluster). Get the project ready to go from my github:  https://github.com/alinahid477/vsphere-with-tanzu-wizard Topics Backstory SSH tunnel for TKG Clusters using Docker container Technical stuff: Tunnel through Bastion for TKG K8s cluster Technical stuff: SSH Tunnel for Kubectl for remote K8s Clusters (same with or without docker) Technical stuff: Explain me this A famous quote from Darth Vader himself: "Feel the power of SSH Tunnel" Backstory Why ssh or ssh tunnel? The below diagram shows in what scenario a SSH or SSH Tunnel almost becomes a necessity. Let's st...

CKA Exam; May 2024: My take on it and cheat sheet

So, I finally got the little green tick of having CKA certification in my certification list. I put off this exam for so long that it seriously became not funny anymore. The internet has quite literally way more than 1000 posts on this topic. But what harm would one more post cause? So here's mine. I will write it from my perspective. I am writing this post just in case if anyone benefits from it, as I predict there could be many on the same boat as me. Background: Kubernetes, modern application architecture, DevSecOps etc are not new territory for me. In fact, I think I am fairly versed in K8s and related tech stack. But due my own imposter syndrome I have been putting off sitting the CKA exam. However, last week I thought about the CKA as "just another approval for my skills" and got the nudge to sit the exam.  Here's what I did till the day I sat for the exam. (Everybody is different but the below worked for me the best) The preparation: As I have been working with...

A CQRS Microservice Architecture - My Way

Microservice Architecture is the new trend in the industry. When I thought of building a decisioning engine to work as my personal assistant I decided to design it as a swarm of Microservices. The most compelling selling point about Microservice Architecture which resonated well for me was its ease of maintainability and that's a big factor for a hobby project like this which has a lot of custom logic programmed into it and requires a lot of frequent changes. In theory, Microservice should fit right in. I tried doing it in the Monolithic way and I failed !!. So, will Microservices solve it for me? Let's find out. In this post I will do it in the "Software Engineering" way. Background: Few weeks ago I created a wifi controlled water system that I can control via my Home Assistant (using my phone even if I am on the other side of the planet, like Batman). And this is working great for me. Read about that here: Smart wifi controlled irrigation system . Bu...