It is always tempting to write a static function. We can call them from anywhere directly without having to inject/initialize/prepare their wrapping class. But we should never do it. In fact, they should just not even exist in any programming language.

1. They Are Not Testable

Suppose we have this method in class Test:

public void doSomething() {
var a = 1;
var b = 2;
var c = MyClass.myStaticFunction(a, b);
return a + b + c;
}

Now, our myStaticFunction calls a database, perform some validations and does an ugly computation of a and b with some database results. …


(a sample github project with all the examples is given at the end)

1. Validate with jackson (obvious way)

The obvious way to validate json is by mapping to a typed object through serialization (here with the most popular lib for that in java: jackson):

public class MyJsonClassTest {

public static class MyJsonClass {

private String myProperty;

public String getMyProperty() {
return myProperty;
}
}

@Test
public void validateMyJsonClass()
throws JsonProcessingException {
String json =
"{\n"
+ " \"myProperty\": \"a value\"\n"
+ "}";
MyJsonClass myJsonClass = new ObjectMapper()
.readValue(json, MyJsonClass.class);
assertThat(myJsonClass.getMyProperty())
.isEqualTo("a value");
}
}

Pros:

  1. You know exactly what you manipulate in your code;
  2. You…

My previous article was trying to stimulate interest in software development, especially to scientists. The end goal is to use the enormous computing power available like you use your hands or your brain. To use the large amount of cloud servers as an extension of your thoughts. For those convinced, now it’s time to explore why most of us fail to use this great potential.

The Complexity of Software

One of the best known developers at Microsoft, Scott Hanselman, warns us to Stop saying learning to code is easy:

When we tell folks — kids or otherwise — that programming is easy, what will…


If you are a scientist wanting to do real science and make money out of that, this post is for you.

8 years ago, I choose to become a software developer after finishing two degrees in mathematics & physics and I hope you will do the same.

Why do we need more scientists?

We can ask the question to the first computer scientist that builds the first digital computer:

“We shall need a great number of mathematicians of ability” because “there will probably be a great deal of work of this kind to be done”

— Alan Turing [http://www.turingarchive.org/viewer/?id=149&title=18]

During a talk Robert C. Martin told…


Testing some failover scenarios and replication parameters in a sandbox environment before going into prod or buying new machines is common sense. Here is a quick tutorial on how I do it with docker.

Starting With a docker-compose File

I would not recommend using containers to hold any persistent data in production (see this good article from Paul Bakker at Netflix, section: Data stores and Kubernetes). However, it is really useful to test ideas and concepts.

The Maria bitnami image provides a good start by providing a docker-compose file with the replication already set up. …


Combine the best text editor with the best document preparation system: edit in LaTeX with VSCode!

Here is a quick reminder how to install and use LaTex with VSCode.

  1. First you need TexLive: go to https://www.tug.org/texlive/acquire-netinstall.html and click on the .exe download for Windows:

2. Once download is finished, click on the .exe and follow the steps:


Here is a quick reminder how to create and connect a custom domain to a firebase web application hosted in firebase hosting plan. These hosting plans are free and give you a ssl certificate for free, the best offer on the market right now (MS Azure charge 80$/month for the same thing for instance).

  1. Go to Namecheap.com and search for your domain (mine is random-generator.recipes):

2. Click on the cart and proceed to checkout (don’t buy a certificate, Google Firebase will give you one free):


Most of the time, I don’t want to play around with frameworks/databases/libs and so on, while I’m working and billing a client. I want to do some experimentation at my home before launching an idea in a real and bigger project.

I share this method with many developers. In fact, most of the software that don’t have a community version are gone for good now. You can’t ask the community to pay thousands of dollars for exercising on your framework in case they need it sometime…

I had trouble the other day playing around the Oracle Database version of my…


Why waiting 15 minutes when you can wait 5 seconds for the exact same query in Oracle? Or asked more cleverly: why an oracle C# data access provider would ask you this stupid question?

I recently wrote a simple “InsertMany<T>(IList<T> list)” function to “Bulk insert” inside an Oracle table. I really don’t know why I would insert any other way since my benchmarks show always a time improvement ranging between 5 and 150 times depending if I use plain ADO.NET or if I glue Entity Framework around my query.

It seems you need to pay to get this performance without…


I was puzzled by a very peculiar problem the other day: I wanted to read the manifest information from an assembly (dll). In C#, this is pretty straigthforward:

var assembly = Assembly.Load(“your-library.dll”);

Unfortunatly, this method load the assembly in RAM. So if you want to read the same assembly both in 64 bits and 32 bits in the same program you’ll end up with a pretty bad runtime error. Same thing if you want to read multiple assemblies build for multiple processor architectures different from your main program… Why would you do that? Well, as part of a DevOps process…

Guillaume Blanchet

Currently working with Viagénie inc. in Quebec. Interested in devops, operation research and software development. c.v.: https://gblanchet.azurewebsites.net/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store