But it is a good tool to have.

Image for post
Image for post

Many students learn at the university the principles of object-oriented programming, and they are told that object-oriented is one of the crucial crystals of knowledge that they need to possess in order to find a good job in the industry, they graduate from the university thinking that object-oriented is the best paradigm there is and they should apply it everywhere, many of them don’t know that object-oriented isn’t perfect and has its weaknesses, here we are going to review some of them.

Object-Oriented Programming

Object-oriented programming focuses at modeling the world by objects, objects are models for entities that represent what are…

Command & Query separation in the world of object-oriented.

Image for post
Image for post

What is CQS/CQRS (Command & Query Separation)?

First, let’s agree that each method of a class can do one or both things:

  1. It can mutate a private value of the class (hence you tell the object to mutate it, therefore it is also called a “Command”).
  2. It can return an object/value as a result or additional data (hence you want to query the object to tell you something).

Let’s see some examples (TypeScript):

Don’t worry about the long class, you can instantly skip to the methods explanation right beneath it.

Example MyNumber class written with TypeScript

Let’s look at methods by category:


You can see…


Lifelong learner…

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