Be a Pragmatic Developer


Each line of code should fight for existence.

Have you applied the “clean architecture” approach without a reason for it? Have you sprinkled presentation, domain and data folders everywhere, just because someone said so?

Then you probably weren’t being pragmatic.

You don’t always need 8+ architecture layers. As I said in the beginning. Each line of code should fight for existence.

Pragmatic

First, let’s take a look at the definition.

pragmatic /praɡˈmatɪk/

Dealing with things sensibly and realistically in a way that is based on practical rather than theoretical considerations.

It’s clear, but here is a definition that makes sense for developers.

Being pragmatic means favoring practical, effective solutions over theoretical ideals or strict adherence to rules or patterns.

Start being pragmatic

Have you considered that your application or your specific feature can be simplified? You don’t need interfaces which were added just for the sake of “abstraction”.

Your code should serve a purpose.

Let’s go through an example using Dart.

abstract class UserRepository {
  void login(String email, String password);
  void logout();
}

class UserRepositoryImpl implements UserRepository {
  UserRepositoryImpl();

  void login(String email, String password) {
    // TODO: implementation
  }

  void logout() {
    // TODO: implementation
  }
}

Why was this interface added in the first place?

It serves no purpose, so just remove it.

class UserRepository {
  UserRepository();

  void login(String email, String password) {
    // TODO: implementation
  }

  void logout() {
    // TODO: implementation
  }
}

You could argue for the sake of testability, but that is incorrect. Dart has an implicit interface on classes so there is no technical need for it. The interface only makes it harder to navigate your codebase.

Don’t apply patterns without a purpose.

Challenge your typical patterns.

Be a more pragmatic developer.

My name is Robert and I am co-founder of Hungrimind. A place to learn and get up to speed with Flutter and other technologies fast such as The Best Flutter Course and a Flutter Kit.

If you want to follow my work, you can find me on Twitter.