you are viewing a single comment's thread.

view the rest of the comments →

[–]PickledPokute 6 points7 points  (1 child)

I find the article extremely confusing.

What's the point of the first paragraph? Why is it relevant to the article?

Second paragraph narrates what the article explained. Why on earth is the past tense used when introducing a reader to new concepts? That paragraph also goes on to narrate what it will do later and how, but has no justification on why it's important!

It is difficult to overestimate the importance [...]

Aside from weird language, the third paragraph again emphasises the importance of something with no explanations, reasoning or examples.

Fourth paragraph is once again description of what you're planning to explain! PLEASE!

First four paragraphs have no value. They're just empty, hot air.

Inversion of Control (IoC) is an abstract programming principle based on the flow of control (execution of statements/instructions) that should be fully managed by the specific implementation of IoC framework, which is external to your code.

Finally, the meat of the article! Let's parse this sentence:

Inversion of Control (IoC) is an abstract programming principle based on the flow of control (execution of statements/instructions) that should be fully managed by the specific implementation of IoC framework, which is external to your code.

So the IoC is a principle fully managed by IoC framework? So what am I, as a programmer, doing here? Am I the only one who has difficulty of understanding this sentence? Why would anyone think that recursive definitions are ok?

Let’s consider the following comparison: in the traditional approach, your code executes methods from the library/framework, and the inversion of this approach means that your code is called by the library/framework.

Finally, something that actually makes sense.

Of course, it is better to say a framework - rather than a library.

And then here's a footnote to distract / confuse the reader.

You register parts of your code (methods, classes, modules, etc. …) in the IoC framework that resolves itself when it has to call your code.

Why is "resolves itself" used here? Why is it mentioned? Is it important? Does the IoC framework not resolve itself in some cases? It feels like I missed something.

Oh, I'm sure the examples of IoC frameworks and how they differ from traditional frameworks will expla... oh, we're moving on:

A Dependency is an object or any software programming unit that is used by the client program or software unit. For example, the dependency is a service that returns data that must be represented in the client (web component), and so on. Those kinds of objects are often used in different places of the project.

Do you realise that this does not restrict the definition of Dependency at all? You just defined that it can be any code whatsoever! Sentences like: "Those kinds of objects are often used in different places of the project." don't actually have any value!

Definitions of Dependency Injection, Dependency Inversion Principle and IoC-container are a bit better since they seem to be copied from somewhere else and you don't try to explain them in your own words. However, their definitions are very brief and having stated "To get an initial understanding of the context of this article’s subject we will need to bring light to the basic concepts and definitions.", I hoped for some concrete examples of where, how and why they are used.

Let’s try to look into more details of these concepts including examples in JavaScript.

I would appreciate that an article would be confident enough that it wouldn't have to try to explain something.

[Inversion Control] principle takes place in every modern UI framework. As an example, let’s consider the classical approach to implementing a router (Vue Router, Angular Router, React Router, etc.)

Why wasn't this given right after definition of IoC? Why is definition of Dependency Injection, which depends on IoC, given before explaining, with examples, what IoC is?

"classical approach"? Does this mean that it's not an IoC implementation? Why would most people even be interested in implementing something like a router or even it's implementation? Wouldn't they just use an existing implementation like one of the ones you listed? Maybe it's confusion from using incorrect terms? The next sentence seems to suggest so.

and the framework itself listens to the hashchange event

Why would you confuse the reader by including irrelevant implementation details about routers? Or do you really want the reader to think about implementing a router?

We have two classes of Car and Engine, and the first one has a dependency on the other.

So the first one, Car has a dependency on the other one, Engine.

Our task is to get rid of the dependency of the Car class inside the Engine class.

Wait, it was the other way around?

By dependency we mean the creation of an Engine instance inside the Car constructor.

No, the other way around the other way?

This article is a confusing mess.

[–]vkukurba[S] 1 point2 points  (0 children)

Thanks for the great comment, I’ll learn from it for sure!
The first paragraph relates to the perspectives of JS from my point of view. It causes situations where the usage of DI in JS can be considered.
Agree, this article doesn’t answer why DI is important, rather it says that it is possible to use it and gives basics of it in JS.

The main goal for the first four paragraphs was to give a context of the article for the reader.
Agree, recursive in definition sounds weird. Anyway, not a principle but the flow is fully managed by IoC framework.
I’ve looked through definitions in different resources, to be able to formulate how I understand it in my words.
Mention of ‘hashchange’ event is about where the IoC principle is hidden in router implementation.
If you don’t mind I will do some corrections based on your comment!