Dariusz Mydlarz

Dariusz Mydlarz

Java, Distributed Systems & Software Engineering

How to Specify Exact Node Version for a npm Project? 🙀

In order to ensure specific version of node used in the npm project you can add entry to package.json and create .npmrc file.

Continue...

How To Exclude Scala Tests With Tagging?

If you want to disable certain types of tests with Scala you can use tags.

Continue...

How Do I Make Mocking Lot Easier?

Do you find configuring mocks for your tests a bit painful? I was there for a very long time.
Now I found a solution that makes it a lot easier and I would like to share it with you.

Continue...

Elegant Objects in a Simple Example

I believe that maintainability is a key feature of the code you produce. It is good when your code works. But it is even better when it is maintainable in the long run. For many years I was not happy with my code. I was learning about encapsulation, SOLID principles and immutability. But none of this lessons taught me as much as reading Yegor Bugayenko blog and - what is more - his book. In this blog post, I want to give you a short example which shows his point of view so you can grasp the idea.

Continue...

Hystrix Circuit Breaker - Three Key Parameters

In one of the previous posts I have briefly described what is the Hystrix Circuit Breaker and why it’s worth to consider using it. Now I go more into details and explain what are the key parameters and how they affect its behavior.

Continue...

Event Bus - Decouple Your Classes Easily

Very often you might hear that it is good to have classes highly cohesive & loosely coupled. For many people, it may mean something a little bit different. So more important than just hearing to the slogan, is to have practical examples of what it actually means. In order to achieve loose coupling you should consider event bus at the beginning.

Continue...

Hystrix Circuit Breaker - 101

  • Hystrix is a neat Circuit Breaker provided by Netflix.
  • In order to protect external calls use the below code at simplest cases.
public class ForecastCommand extends HystrixCommand<Forecast> {
    private final String city;

    public CommandHelloWorld(String city) {
        super(HystrixCommandGroupKey.Factory.asKey("ForecastService"));
        this.city = city;
    }

    @Override
    protected String run() {
        return forecastService.forecastFor(city);
    }
};

void itCanBeUsedLike() {
    ForecastCommand command = new ForecastCommand("Krakow");
    String s = command.execute();
    Future<String> s = command.queue();
    Observable<String> s = command.observe();
}
  • That way when a resource (forecastService) is unavailable for a reason, Hystrix will eventually stop calling it making your responses faster. And preventing downstream service from an exhaustion.
Continue...

Switch Case Should Be Banned

  • I believe that switch-case construction is overused.
  • Every time you branch execution depending on switch-case you’re doing something wrong.
  • Instead of that you should move the logic into classes and rely on polymorphism.
Continue...
<< page 1 of 2 >>