Does using multiple namespaces weigh more?

Asked

Viewed 69 times

5

Let’s say I have these namespaces:

use
    DataTables\Editor,
    DataTables\Editor\Field;
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

But I only really use 2 of them:

use
    DataTables\Editor,
    DataTables\Editor\Field;
    //DataTables\Editor\Format,
    //DataTables\Editor\Mjoin,
    //DataTables\Editor\Options,
    //DataTables\Editor\Upload,
    //DataTables\Editor\Validate;

As seen above, I don’t need them. So there is a considerable loss by leaving the other 5 namespaces even if I don’t use?

  • 3

    I might add in your question, whether this also weighs for . NET?

  • 3

    But then I would expand the question and it could possibly be closed. You can also ask a question here https://answall.com/questions/ask

  • 1

    For C#: https://answall.com/q/16563/101

  • @bigown The coolest is to see that I myself have answered something about it. ( and had forgotten )

  • @Paulohdsousa is, I had voted for her

  • 1

    @Miltonnascimento Has the answer solved your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.

Show 1 more comment

1 answer

6

In the execution of the code itself does not weigh because it is only a facility to write the code without having to enter the whole name.

It weighs slightly more to interpret the code since it has to make a complete analysis of what is there and that will not be used for anything. So I would take it not only for the performance that is a derisory gain, but to decrease the size of the code and make it a little easier to read and understand, because the fact that there is something there may convey the idea that the namespace is being used.

And it’s not just the analysis of the text of use, at the time of choosing what to use it will have to scan the tables names of all namespaces, so it weighs a little, it’s not just the text to parse.

And you still have a chance to end up creating a conflict for no reason by providing classes that will not be used but may have the same name as some other namespace with potential for use.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.