Monday, June 30, 2014

When you're not allowed to translate blocks in EPiServer 7

If you find yourself not able to translate blocks in EPiServer 7, you might not have marked the language you're working with as available. 
The block you want to translate will look like this, as you can see the translate button is disabled. 



How to set the language as available: 

1) Go to the startpage

2) Click on "Tools" -> "Language settings":












3) Select the language:

















Now, if you return to your block, you'll see that the translate button is enabled and you can translate the block:


Thursday, June 26, 2014

My new pet project: Putting Norway on the map of computer science


In the beginning on May, Arialdo Martini posted this on Twitter:
I answered him...

An entire conversation followed...

And finally, a great idea!
Arialdo and I are now in the process of starting a new project. A project where we dig into the work of Norwegian computer scientists, looking at how they were able to change the way we think about computing. And maybe we will get an idea of what the world would have looked like if these brilliant minds had decided to do something entirely different.

We will be creating a public git repository where we gather all our research, so you are welcome to contribute to this project if you'd like. It's time to honour the men who have made our jobs possible, and we're starting with Kristen Nygaard and Ole-Johan Dahl.

Sunday, June 22, 2014

Behind the scenes of "Release shipment" in EPiServer Commerce

Working with EPiServer Commerce, one thing you quickly realize is that you spend more time debugging than you do developing. And some of the bugs can be a real pain to figure out.

I ran into a bug last week where nothing happened when the customer clicked on "Release Shipment" on the order. They clicked the button, and not a thing happened.


The only error i found was a javascript error "Workflow generated an exception, please look at the previous error for more details". However, there was no "previous error", so I had no way of knowing what was failing and there was nothing in the logs...

Decompiling the Mediachase.Commerce assemblies, I found that the method called when you click "Release Shipment" is DoCommand(...) in Mediachase.Commerce.Manager.Order.CommandHandlers.PurchaseOrderHandlers.ReleaseShipmentHandler. This method validates a couple of things such as the authorized payment amount, that the item is in stock etc. The most important part, however, is that the method changes the status of the order to be "Released" by calling the ReleaseOrderShipment(...) method in Mediachase.Commerce.Orders.Managers. After the status is changed, the RecalculatePurchaseOrderWorkflow is called (Note: I've also seen this workflow being called by the name PurchaseOrderRecalculateWorkflow, just to make the confusion complete).

So what does the RecalculatePurchaseOrderWorkflow / PurchaseOrderRecalculateWorkflow do? If you're using the standard workflows, it contains the following activities:
  • ValidateLineItemsActivity
  • GetFulfillmentWarehouseActivity
  • CheckInventoryActivity
  • ProcessShipmentsActivity
  • RemoveDiscountsActivity
  • CalculateTotalsActivity
  • CalculateDiscountsActivity
  • CalculateTaxActivity
  • CalculateTotalsActivity
  • CalculatePurchaseOrderStatusActivity
In my case, the CalculateDiscountsActivity was missing a null check, and that was what caused all the trouble. How did I find out which activity was the troublemaker? I added logging to the catch block of the try/catch of all the Execute methods in the activites, and retrieved the error message from the log.

I cannot believe the amount of exceptions being swallowed by the Commerce workflows. Any developer working with Commerce projects should make sure they go through all the activities and add some logging. It will make your life a lot easier in the future!

Update: 
I've received notice that the CalculateDiscountActivity should only run when the order is a cart and not a purchase order. This of course makes sense as the payment has already begun processing for orders. The Execute method of your CalculateDiscountActivity should then look somewhat like this:
   protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            try
            {
                ValidateRuntime();

                if (OrderGroup is Orders.Cart) // Do not calculate discounts for Purchase Orders as the payment has already been done
                {
                    InitMarketingContext();
                    CalculateDiscounts();
                }
                return ActivityExecutionStatus.Closed;
            }
            catch (Exception e)
            {
                _logger.Error(e.Message, e);
                // An unhandled exception occured.  Throw it back to the WorkflowRuntime.
                throw;
            }
        }

Wednesday, June 11, 2014

Dear developer, could you please do a quality assessment of how we use your software?

Quality assessments (QA) in software development are a way of ensuring that the software being developed lives up to the expected standards. The methods of assessing, the tools used and the criteria measured are varied, some find checklists to be sufficient while others need complex workflows. Whatever your method of assessment is, the most important part is that the quality assessment is done by a different team than the ones who developed the software.

At Epinova we have had structured quality assessments as a part of our projects for a couple of years now. Whenever we're closing in on a deadline, a developer who has not been part of the project goes through the whole codebase to see if the quality is acceptable. So in our case, a quality assessment includes a quite extensive code review. It also contains criteria covering the security and setup of all environments, user experience, accessability, performance etc. The list goes on and on. Not to mention, we have several different types of quality assessments: Backend, frontend and javascript. Each one is conducted as a deadline is getting nearer. This means that before a deadline, the developers have set aside time to fix any issues found during the assessments, making sure any areas not living up to the standards are improved before deadline.

These quality assessments have become part of our project pipeline and I think all the developers appreciate the feedback and a confirmation of their code meeting the standards it should. I wish we had some statistics on how the quality of our projects have improved after we introduced assessments to our project routines, but sadly we don't have any numbers to show of. I mean, how do you measure quality? Is quality represented by the number of bugs reported? The happiness of the customer? Or maybe the cyclomatic complexity of the codebase? It's very difficult to measure, but we're sure about one thing: The quality of our projects, however we measure it, have improved dramatically after introducing quality assessments.

Our quality assessment tool

I recently encountered a very different quality assessment than the ones I've described above. A customer asked me to do an assessment of how they were using the software I had developed for them. Now, this is a very interesting scenario. As a developer, you make quite a lot of assumptions as to how the customer will use your software. Note: The customer, in my world, is usually the editor and administrator of a website or commerce site, it's not the visitor. I don't think I'm able to count the number of times I've thought "Nah, the customer won't do that" only to realize that the customer in fact does exactly the opposite of what you imagined. And this becomes very clear when you're doing a quality assessment of how the customer is using your software.

In this particular case, there was one feature that was completely untouched. Why was that? Was it to complicated for them to use? Or did they not need it?

Another feature was used a lot more than what I had expected, and in some cases it served an entirely different purpose than what had been planned. Was there any risk involved with doing this? And how had this happened?

These are all very interesting questions, and the answers are very useful for a developer trying to map out how this customer is different from the previous customer he worked with. Needless to say, the report was also very useful for the customer as they received pointers as to how they could solve certain challenges or use the software more efficiently. So if you find yourself unsure of how a customer is using your software, I would look into the possibility of doing an assessment of the work they have put into it. My guess is, you will be surprised!


Tuesday, June 10, 2014

In a NDC Oslo state of mind

I'm still in a NDC Oslo state of mind. The conference flew by so fast, my mind is still full of exciting ideas I can't wait to try out and presentations I haven't had the chance to see yet. Every year I look forward to developers from all over the world visiting my city, seeing all the querky things they tweet about our slightly strange country, and finally meeting all those people I'm used to seeing in my feed every day. And I love the energy of the conference! Being surrounded by knowledge, seeing your heros up on the stage, inspiring me to take action and become a better version of myself.

But this year was different. This year I found my own name of the speakers list and that added a whole new dimension to the experience. I'm extremely grateful and honoured to be accepted as a speaker, I still find myself having a hard time believing it. The nerves were definitely present before my presentation, especially as Scott Hanselman, Douglas Crockford and Scott Meyers spoke in the same slot as me. At one point I was imagining myself all alone in room 6, but guess what? One by one, people showed up to see my presentation. Thanks, everyone! If you missed my talk, you can watch the video here: http://vimeo.com/97349265

As I was so wrapped up in my own presentation on the first day of the conference and exhausted the second day, the amount of information I managed to take in was a little bit limited. But I did see some great presentations you should check out:

How I hacked myself to Norway - by Troy Hunt
This was probably the best presentations I saw live during the conference. Showing the audience how easy it is to gain access to information you shouldn't have access to, mixing in a lot of humour, made this presentations very entertaining and useful.

Developing in a decade - by Hadi Hariri
I love talks that make you think and give you an entirely new perspective of how you view the world. This was one of those talks for me. Why are we developers? Are we really changing the world for the better?

Seven ineffective coding habits of many programmers - by Kevlin Henney
Small habits that make a difference, how do you become more efficient? This talk is quite different from the usual 'efficiency' talks out there, and it's worth the watch!

Becoming an Outlier: Career Reboot for the Developer Mind - by Cory House
This was the most motivating presentation I saw during the conference. If I ever need a boost of inspiration and energy, this is the one I'll watch again.

Full stack web performance - by Nik Molnar
I'm quite annoyed that I didn't get to see this talk live, as there was so much buzz about it afterwards. So the first thing I did after a long rest after the conference was to watch it online. Throughout large parts of the talk I found myself thinking "Why has no one told me this before!?". Great talk!

These are just some of the presentations I recommend, I know I've yet to see a lot of the great ones and I'm really looking forward to it. Awesome conference, entertaining presentations and inspiring developers. I want more!

This came as a bit of a surprise!