Thursday, August 29, 2019

Why Automation test is not worth investing?

It is a vicious cycle.

Here is the thing. Why automation test suite not worth investing? Most of us may debate but CIO don't have time to seek return of investment or audit the whole investment. It is just another brick in the wall.


This explains why?

  • We hire consultant to do the job. 
  • Consulting or contractor create Automation suite and automate it.
  • It keep adding more and more functionality.
  • It create a big giant pack.


  1. Problem 1. A big suite is not enough to run on time. Consume a whole day because automation tester doesn't understand the architecture. They have less idea about performance or coding on daily basis.
  2. Problem 2. If it automation suite yield no results on time. It is futile
  3. Problem 3. No one has time to look into this. No one wants to do parallel programming or identify the sweet and simple solution to meet objective. Per say think about regression that runs and yield results in just no time. Add to release pipeline.
  4. Problem 4. Agile is fragile. So is our functional domain. Changes are radical. Automation Suite is not actual production copy or real time match. It fails the whole objective.
  5. Problem 5. No one looks into it. No one question. If question it is taken care for given point of time and later the same old story. 


Bottom line is it automation test suite should be devops and ingrain in the process.

Tuesday, August 27, 2019

Chaining the C# null coalescing ?? Operator

Simple example

string partner = Request.QueryString["GoogleId"] ?? 
                 Request.QueryString["PartnerId"] ?? 
                 Request.QueryString["UserKey"] ?? 
                 string.Empty;

How to make internal class assembly exposed to specific assembly use InternalsVisibleTo

Important thing to note, internal assembly if stronly typed then you have to mention the public key as well.

Assembly A- A.dll  have internal class = I
Assembly B- B.dll can access internal class .

In Assembly A , .net go to property file and update this line

assembly: InternalsVisibleTo("A.I")

Performance Optimization:SItecore 9.2 Content Delivery Server

After migrating website from sitecore 8.2.1 to sitecore 9.2 I noticed my application was extremely slow. The only place I could search for an issues , is sitecore log app_data/logs . The initial reaction after looking at it was seeing whole lot of different log files.

The first reaction was to look at this logs closely. I found there were lot of exception around Xdb to Xconnect which is kind of real problem. Then later I realised Redis cache is playing up. Then I found there is no need of Email EXM manager as I'm not using it. I even created config patch to remove unnecessary log files which is not adding any value. One of the kind was performance log counter that sits under app_data diagnostic folder. Health Monitor an all.
https://doc.sitecore.com/developers/91/platform-administration-and-architecture/en/content-delivery--cd-.html







Thursday, August 22, 2019

Glass Mapper V5 for sitecore 9.2 breaking change SitecoreChildren Islazy is not lazy any more

    public partial interface ICategoryFolderEntity
    {
        /// 
        /// Gets list of category in this folder
        /// 
        [SitecoreChildren()]
        IEnumerable CategoryList { get; }
    }
public partial class CategoryFolderEntity : ICategoryFolderEntity
    {
        /// 
        /// Gets list of category in this folder
        /// 
        [SitecoreChildren]
        public virtual IEnumerable CategoryList { get; set; }
    }

No need of
[SitecoreChildren(IsLazy = false)]
Just  [SitecoreChildren]
And virtual IEnumerable CategoryList
Remember Virtual

Reference:

https://sitecore.stackexchange.com/questions/16530/after-upgrading-to-glass-mapper-5-unable-to-globally-enable-lazy-loading

Tuesday, August 20, 2019

Sitecore 8.2 Migration to sitecore 9.2 DLL Hell

While we migrate sitecore mvc .net solution, one need to be very careful with following set of dlls that might conflict with version and you end up spending time to do patching the version in web.config or in app.config files.



Here is the key:-


Sitecore 8.2 per say have .Net framework 4.5.2 and all the dependency dll must match otherwise you might end up seeing these kind of exception every time. Indeed you're deep down the rabbit hole.

Before you start, take note of all version of below dlls in your vanilla sitecore installation /bin folder sitecore 9.2 -.Net framework 4.7.1 / 4.7.2

Even sitecore documentation doesn't give you the summary for the version of dll it supports, the way  they have compatibility tables for all platform dependencies. Similarly it is good to have those dll version dependencies with which they have constructed the sitecore framework.

Go in this order and ensure your webapps and project library have consistent dll across:-

Sitecore Intrinsic Assembly Reference


  • Sitecore.Kernel
  • Sitecore.ContentSearch
  • Sitecore.ContentSearch.Linq
  • Sitecore.Mvc
  • Sitecore.Client
  • Sitecore.Analytics
  • Sitecore.Analytics.Model


.Net Framework Assembly Reference


  • System.Web.Mvc
  • System.Web.Http


The King's Newtonsoft.Json


  • Newtonsoft.Json (This one in specific would be challenge in terms of mvc vs Owin connectors). Slight version deviation would take much of your time.)


DI - Reference


  • Microsoft.Extensions.DependencyInjections.Abstractions

Identity Owin


  • Owin
  • Microsoft.Owin
Solr

  • SolrNet
If the version mismatch is handled correctly, the first hurdle of migration is through. Trust me most of the blogs out there talks about sitecore 9.2 installation and setup. They are good but no one has given the actual migration of .net solution that will haunt you when you get started. 

Once you are through with this DLL Hell! You then probably have to focus and deal with app_config patch that is specific to your application domain. There is a change which is more related to Xconnect vs XDB. 

In fact sitecore migration is really a painful task. Also the worst part is sitecore is going to end support for sitecore 8.2 soon. As an application architect one has to plan such migration meticulously otherwise your enterprise application which was developed with sitecore 8.x hoo haa! might become a legacy in no time.

Mainstream support for Sitecore 8.2 is going to end soon :disappointed: 

https://kb.sitecore.net/articles/641167

https://kb.sitecore.net/articles/087164

As an architect, it is no point to start any new project on .Net framework based cms as microsoft has put an end to .Net framework. They lately said .Net framework 4.8 is the last in its journey.

“The .NET Framework is on it’s last release — there will not be another one after 4.8”

https://devblogs.microsoft.com/dotnet/net-core-is-the-future-of-net/

https://betanews.com/2019/05/07/future-of-dotnet/

https://medium.com/@andy.watt83/the-net-framework-is-done-8aec3bbae12d



Sunday, August 18, 2019

Sitecore 8.2 to sitecore 9.2 migration: Not an easy task

Having said that sitecore 9.2 changes are far more different from sitecore 8.2 . If you look at the Kb site and even sitecore 9.2 xconnect, Identity server and so on. It comes with lot of changes which makes CD .net solution migration unbearable.

The main pain areas that would need tackle. I'm not talking about mongo db /Xdb or Xconnect , cms migration stuff. I'm talking about sitecore mvc .net solution what needs to be replatform. It  is huge effort. I wondered sometime , is it worth doing sitecore 8.2 to sitecore 9.2 migration or shall I wait for sitecore to reflatform its whole technology stack into .NET Core.


Pain areas:-


  • App_Config
  • Reference dll, mvc, kernel, dependency injection and so on.
  • Glass mapper version, if your are using it
  • TDS version
  • T4MVC template
  • MVC .net version
  • . Net Framework 4.5.2 to 4.7.2

Sitecore MVPs out there has done great job promoting sitecore 9 but coming to replatform whole existing site into sitecore 9 is huge task.

Then there are heaps of other minor stack of application architect that you might have to replatform or refactor.



Tuesday, August 6, 2019

C# Null Object Design pattern

public Customer GetByPhoneNumber(string phoneNumber)
{
  return _customerRepository
         .List(c => c.PhoneNumber == phoneNumber)
         .FirstOrDefault();
}

Problem with null


var customer = GetByPhoneNumber(phone);
 //Why null check this break design principle 
int orderCount = customer != null ? customer.OrderCount : 0;
decimal totalPurchase = customer != null ? customer.TotalPurchase : 0m;

Create NotFound Object Property



public class Customer
{
  public static Customer NotFound = 
     new Customer() { OrderCount=0, TotalSales=0m };
 
  // other properties and behavior
}

Final outcome No Null checks required


var customer = GetByPhoneNumber(phone);
int orderCount =  customer.OrderCount ;
decimal totalPurchase =customer.TotalPurchase;

Azure Devops Remote debugging Nuget package with Symbols in pipeline

Enable Remote Debugging in Azure Devops Pipeline

Enable remote debugging options in solution Visual studio options

Add task in nuget package build pipeline


Sunday, August 4, 2019

Azure Devops Engineering Code quality

High Level View

  • Code Analysis- Static vs Dynamic code analysis
  • Unit Testing / Code Coverage
  • Security :OWASP Top 10
  • Performance: Load Testing

Code Analysis

Static Code Analysis

LOC- Lind of code = Cyclomatic Complexity of code base(Visual Studio Code Metrics)