The most important skill (of a good programmer)

Being programmer(*) is hard.

Being a good programmer is, of course, even harder. Unlike countless other jobs where the daily work is a routine, and being good at your job is to be efficient at that routine, being programmer is all about constantly learning and doing new things. Being a good programmer is about being fast at learning, and doing new things well. The process might stay for a while, but the content of the job is constantly changing. (If you keep doing same content over and over again, you are doing it wrong)

Continue reading “The most important skill (of a good programmer)”

Optimizing T-SQL COUNT

This is a continuation of my previous post about paging in SQL Server. When it comes to paging, you would naturally want to know the total number of rows satisfying, so you can display some nice, useful information to your end-users.

You would think, well, it’s just a count, and a simple query like this would be enough:

SELECT COUNT(Id) FROM MySecretTable

There should be nothing to worry about, right? Actually, there is.

Let’s get back to the example in previous post – we have to count the total number of orders in that big table.

SELECT COUNT(ObjectId) FROM OrderGroup_PurchaseOrder

Because ObjectId is the clustered index of OrderGroup_PurchaseOrder, I did expect it to be use that index and be pretty fast. But does it? To my surprises, no.

Continue reading “Optimizing T-SQL COUNT”

Beware of unwanted subscriptions

Updated December 23rd 2017: My wife talked with JustFab UK over the phone last week, and they told her to write an email to them. They promised to refund all of the monthly subscriptions, which they did, today. We are of course happy to get our money back, and I think JustFab UK appears to less “scam-y” then they does before , so I updated this post title to reflect that. Still, beware of your unwanted subscriptions.

The original post as below:

Later tonight I was checking my bank statements – to see how much I have spent and how much I still have in my account – well, for the upcoming Holiday seasons, of course.

And this got my attention:

Normally I would assume this is my wife using my credit card buying something. She did that before, and I was unhappy about it, but she didn’t stop doing that. But there was something telling I might have seen this before, it must be some kind of Déjà vu.

So I checked a little further back, and realized there was a similar transaction last month

Continue reading “Beware of unwanted subscriptions”

Fixing error MSB4036: The “GetReferenceNearestTargetFrameworkTask” task was not found

When you build a project with MSBUILD Tools 2017 and getting “MSB4036: The “GetReferenceNearestTargetFrameworkTask” task was not found” error, you probably need to update your MSBUILD Tools components.

Download the latest version of MSBUILD tools from https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017, run it, choose Modify and then select “Web development build tools” and “.NET Core build tools”.

If you are getting error CS8107: Feature ‘default literal’ is not available in C# 7.0. Please use language version 7.1 or greater.

or

error CS8107: Feature ‘leading digit separator’ is not available in C# 7.0. Please use language version 7.2 or greater.

You need to add <LangVersion>7.2</LangVersion> to your project file(s). Unless you specifically set up your project, Visual Studio 2017 uses the “C# latest major version (default)” option for C# language, which means you can use only up to C# 7.0:

You can either select C# 7.2 explicitly, or by adding <LangVersion>7.2</LangVersion> to .csproj file manually.

Note that C# 7.2 is not supported with the vanilla version of Visual Studio 2017. When it was released, Visual Studio 2017 only supports C# 7.0. Supports for C# 7.1, and later, 7.2, were introduced in later updates: 15.3 and 15.4, respectively. At this time of this update, 15.6.1 is available and I personally recommend to upgrade to latest version possible.

Make sure to add it to both debug and release configuration. It’s likely that you will run your server builds on release.

The art of paging

No this is not really “art” – I’m just trying to have a more clickbait title. It’s more about understanding what you have at your disposal and use them for your benefits – in this case – how new SQL statement can drastically improve your performance.

In this blogpost we will look into paging feature of SQL Server. in Commerce we usually work with large set of data – millions of rows are fairly common, and it’s natural to load data by page. There is no point loading thousands, or even millions of rows in one go. First it’s not practical to display all of them. Second you’ll likely end up with an timeout exception and/or an out of memory exception. Even if you are lucky enough to get through, it’s still able to take your SQL Server instance to a knee, and transferring that much data over network will be another bottleneck for your system. So my friends, the best practice for loading data is to do it by batches, and to not load everything at once.

Continue reading “The art of paging”

Fixing a stored procedure

At Episerver development team, we understand the importance of good performance. Who would not like a lightning fast website? We work hard to ensure the framework is fast, and we seize (almost) every opportunity to make it faster.

You know in Commerce 10.2 we introduced a new cart mode – serializable cart, and it’s proven to bring great performance compared to the “old/traditional” approach. Our own tests showed an improvement of 3-5x times faster. But can it be even faster? Probably yes.

And actually we did some improvements in later versions. In the scope of this blog post, we will just focus into a specific aspect – and to learn a little more about SQL Server performance optimization.

Continue reading “Fixing a stored procedure”

Lessons learned from a “boring” Black Friday

This Black Friday, I was in a task force, ready to help high profile DXC Commerce customers to cope with a peak in traffic. It turned out to be boring – there was no moment I could be a hero and “save the day”. Things went surprisingly smooth, even for websites which were struggling with last Black Friday. I went home and was little dissatisfied, but deep down, I know it was a huge success. The hard work from us (Commerce development team), them (the partner development teams), and Managed Services has been well paid off.

Use the latest version

You have heard me saying this, and you will probably hear from me again: Please, use the latest version possible. There is no reason to stay with an old version. This is a little truth: I hurt a little deep inside whenever I read a question on world asking a question about Commerce 7.5, or even 8.x. You should be using at least 10.8 by now, if not 11.x.

Continue reading “Lessons learned from a “boring” Black Friday”

Please, rebuild your database indexes, now

I will make it quick and to the point: if you are expecting a lot of customers visiting your site tomorrow (and you should) for Black Friday, you should rebuild your database indexes, now.

On average, it will help you to serve more customers and they will be happier with a more responsive, faster website. On best cases it will help prevent catastrophes.

Continue reading “Please, rebuild your database indexes, now”

Read only Catalog UI – part 1

https://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2015/6/read-only-catalog/

A while back, we had this question on World. It’s not uncommon to update the catalog data by an external system, mostly from a PIM – Product information management system. In such cases, it might not make senses to enable editing in Catalog UI. You might need the new UI for the other parts, such as Marketing UI, but you wouldn’t want the editors to accidentally update the product information – because those would be lost, anyway.

Is there away to do it? Yes, there is.

Continue reading “Read only Catalog UI – part 1”

Beware of IContentLoader.GetChildren() for CatalogContent

This is more of a self-to-note.

If you are using IContentLoader.GetChildren<T>(ContentReference), one important thing to remember is this uses the current preferred language. Normally when you get children of a catalog, or a node, that would not be a problem, because a catalog entity – node or entry, will be available in every language supported by the catalog. So if you just want to get the children references, the language is not important. (Note that, if you just need the children references, IRelationRepository should be a faster, more lightweight way to go, but that’s another story). If you want to get children in a specific language – which is the most common case, you know that you can use the other overload of GetChildren<T>(ContentReference, ILanguageSelector) , where you can specify the language you want to load.

Continue reading “Beware of IContentLoader.GetChildren() for CatalogContent”