Injection causing poor performance (ASP.NET MVC)

I'm not very good with dependency injection, so I really appreciate your feedback on the following.

It (Dependency Injection / IOC) was used in a web application at my company.

The current programming guide at our company hates this app as it doesn't like linq, entity framework and dependency injection (everything that goes into the app). Together, he believes, they contribute to keeping the application slow and fragile.

He blames the IOC container for perceived poor performance in most cases, and today said the words: "I'm not sure, but he (the IOC container) has to use reflection, which is very bad."

It also discourages the use of interfaces (as it does file definition lookups, which is more difficult for an interface in Visual Studio) and uses that as another reason for bash IOC containers in general.

I recently discovered the SOLID principles and the above opinions just don't fit me with me, so I would like to know what experienced developers think and if there is any facts to support any of the opinions regarding programming.

Thanks for reading.

+3


source to share


2 answers


I've never experienced performance issues caused by dependency injection and I would ignore that.

Separating dependencies between code, especially nasties, like calls to the database in an interface, is not a problem.

However, using LINQ to SQL can result in less performance than code in a stored procedure managed by SQL Server.



This should be balanced against the problem of the code in your database. SQL is less powerful and difficult to refactor because you cannot call another stored procedure without using dynamic SQL. Also, the code in your database may not be under source control. I've seen projects suffer badly because there was too much code in the database.

Personally, I would use linq for sql, but am not afraid to use a stored procedure for heavy work or poorly performing function.

I would be wary of people who don't like a certain technology but don't support it with sound arguments. People tend to prefer the technology in which they are most experienced.

+4


source


This is the type of discussion that you cannot win unless you change your perspective.

Computers don't mind what code they run. They are probably even "happier" with what we will call "spaghetti" code because there are fewer access paths to go through.

But we don't write code for computers .

All these architectural guidelines like SOLID principles, all these tools like IoC containers or ORMs, all these third, fourth and fifth generation computer languages ​​were not designed for computers, but for us software developers.

Simply because the human mind is not a CPU.

So we need all of these tools to keep track of what we are developing and to ensure that what we write can be converted into runtime safe code. Taking this to an extreme, your programming output shouldn't even allow you to enjoy writing in C # or VB, but to force you to write assembly code. Then you get unbeatable performance! (But most likely this is an error due to runtime errors).



The correct perspective is to talk about maintainable code, because code is always evolving. And there are often deadlines. Not a computer, but we must understand what we are doing. We share the concern because we can only understand one problem at a time. We use tools to generate SQL because we cannot enter hundreds of SQL statements without errors, let alone modify them in a reasonable amount of time if the database changes. We use IoC containers because we forget about dependencies or object lifecycles.

Balance really versus supported code .

Once this is clear, there is a common point from which you can take performance measurements. If the tool dramatically increases the time to market at the expense of a slight degradation in performance, this may be acceptable. Even users will understand this.


(I did this a little wider than your closest question, msteel9999 answers what's in place).

+2


source







All Articles