JS: Object oriented design
Theory: Fluent Interface
A Domain Specific Language is a language specialized for a particular application domain. The structure of such a language reflects the specifics of the tasks solved with its help. A prime example of such a language is the jQuery, library, which most programmers are familiar with (or at least have heard of). You can use it to control the display and behavior of webpages:
Here, the DSL is created using Fluent Interface. With this way of organizing code, the processing looks like a chain of methods in a row. From the technical side, there are two ways to create such an interface.
This
The first method is based on returning this from methods that are involved in building chains. this is a reference to the object in whose context the method is called, and therefore it can be returned as a normal value.
This method has one serious disadvantage – the object changes. This means that you can't just re-use a collection object for different samples, because they'll begin to overlap.
In practice, a different approach is often used, which we were introduced to in the last course. All you need to do is add some functionality to the OOP, i.e., don't return this, but rather create a new object of the same type with the updated collection.
Each call now returns a new object. This code is much safer to use and allows new collections to be reused without issue. Changing one will not automatically change all the others.

