Skip to main content

Posts

Retry logic - revisited

My previous blog post gave a very short description of Polly  and that we were going to use it at work. The Polly library expose a set of options how to make your software more resilient. The most common (my guess) is a simple retry functionality, retry calling e.g. the database x number of times (x can also be indefinitely). Other options are timeouts, cache functionality, fallbacks and a couple more.  Our demand, however, didn’t exactly fit into the retry policy of Polly. We wanted to try x number of times (e.g. five times with two seconds of sleep between tries), then sleep for some time (e.g. 30 or 60 seconds) and then try again five times. Repeat until success. Also, we only wanted to log first time there is an error, and then when the try was successful (after retries, not if successful on first attempt).  using System; using Microsoft.Extensions.Logging; using Polly; using Polly.Retry; namespace R...

Retry logic

Implementing retry logic (e.g. when calling another module with a REST API) can be a bit of a mess. You start at one place in your code and everything looks nice, then after a while a need for configuration develops, and then retry-logic is needed somewhere else. On top of that, software is developed in different teams. At my work we are examining Polly  ("Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.") to see if that framework can help us. So far, I have just made simple tests and it looks promising. Stay tuned. 

Using a Brother QL-800 label printer

I'm currently working on a software project that will use a Brother QL-800 label printer. I chose to printer thanks to the presence of SDK documentation since I’m going to write a .NET Core WPF application that will handle the printer. The application is very simple, four input fields that shall be printed.  The SDK works well, it does what it’s supposed to do. The general feeling is that Brother actually created an SDK that was intended to be used. My approach was to create a template in Brother’s P-touch Editor software, and use the template (adding data to template) when printing. It’s probably possible to dynamically create the label in the API, but using a template is fast and easy. Every text field in the template is assigned an Object Name (e.g. “FieldName”). The object name is later used when printing. Below is a snippet of code which will print a label (29mm x 90mm) containing four text fields. using bpac; using System; name...

Linq ForEach with index

Once you start using Linq in .NET you never go back... Even simple tasks as looping a list of items you still use Linq. But what happens when you actually need the index variable you get for free when using for-loop? Assume a list of objects: var values = new List<int>() { 2, 3, 4, 0x100, 74, 0xFFFF, 0x0F0F }; To iterate the list and having an index do the following: values.Select((x, i) => new { item = x, index = i }) .ToList() .ForEach(obj => { int value = obj.item; int valueIndex = obj.index; }); See also my answer on Stack Overflow .

How to manage a project going bad

An interesting article on InfoWorld called "How to salvage a (nearly) hopeless software project " discuss how to rescue a software project that is not delivering the expected. When is it better to create a complete new software than fixing the old one? How shall old, no longer supported, hardware or software dependencies be handled? The article gives a few pointers, but much of the essence seems to be deal with it and do the best of the situation...

How to test a REST API

You have implemented the perfect REST API and now it's finally time to test it, but how? For some time I have used Fiddler and liked it. It's pretty simple to use for the basic tasks like sending a POST request and watching the result. The application feels a little crowded with functionality but can probably do a lot of things that I haven't discovered yet. And there's that growingly annoying thing with applications, they have to be installed... An alternative is Postman . This is a Chrome application, simple to use and have all the functionality I have needed so far. Postman has become my favourite and I will probably remove Fiddler from my machine.

New blog address

The blog's address is now blog.ribbing.net (the old address still works). During the change to the new address, my blog list disappeared. A warning this would happen could have been nice... So I need to add blogs to the list, and I found a couple of new blogs that I previously hadn't seen. The list will be updated.

The skills of a business architect

Important skills of a business architect includes communication, leadership and analysis. At least was that the result of a workshop in Las Vegas hosted by Jeff Scott. I think that the skills can be applied to software architects also, especially analysis and vision. What was the best skill? Get'er'done'er .

Test your JavaScript

Microsoft provides a way of testing JavaScript libraries automatically. The project is called BrowserSwarm and works lite this: Whenever you update your code on GitHub BrowserSwarm automatically start a test run. The result is a test report with issues (if any). Read more at InfoWorld . As mentioned in the article, a very easy way of testing an entire web page is to use Microsoft's modern.IE.

Ten Ways to Kill An Enterprise Architecture Practice

Ten ways how to not do Enterprise Architecture . I personally like number two, "set no goals": "Set no goals. Allow individual architects to find their own architecture opportunities and to do them any way they want.   Encourage cowboy architecture." Too many projects doesn't have a well defined goal, or the goal change during the project's life cycle.

R

Investigating a yet one more computer language. R is a language for statistical computing and graphics, it also features an environment. R can be used to manipulate and display statistical data. Check out the official web or a short introduction at InfoWorld .

When to use a graph database

Interested in graph databases? Here's an article with an example when to use a graph database rather then a traditional relationship database. After studying graph databases I realize that the choice of an RDBMS that I often do isn't necessarily based on the fact that RDBMS is the best choice. RDBMS is such an integral part of my backbone I don't think of anything else. A very good quote from the article is: You wouldn't use only one data structure for every type of data in memory, why would you do that just because you're storing the data? More on the subject: Graph databases on Wikipedia Neo4j Introduction to Graph Databases

The God element

In mid March of 2013 the God particle was confirmed to exist to the joy of many scientists. In software architecture, the God element has been around for years, and in contrast to the particle, the element is fairly easy to spot. The God element 1 is an element with a lot of connections to other objects in the system, the element is in the center of attention and is often called “manager”. The problem with this design is that the manager is responsible for all the functionality, the manager is the entire system and the other objects merely acts as e.g. data providers. Another problem is that it may lead to a complex system that is difficult to maintain, the manager does too much. Performance, reliability and scalability are key quality attributes that are effected by this type of design. The solution is to spread out the responsibilities among the elements. Software Systems Architecture 1 gives a guideline: "if you find more than 50% of your system's respons...

A couple of new books

My pile of books is getting larger. In today's mail was a package with the following books: The process of software architecture, Peter Eeles and Peter Cripps The trusted advisor fieldbook, Charles H. Green and Andrea P. Howe The pyramid principle, Barbara Minto Writing winning business proposals, Richard C. Freed, Joseph D. Romano and Shervin Freed Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin I'm going to start with The pyramid principle, I definitely need to enhance my writing and I hope to get some pointers in writing short, solid and understandable.