Specification and Performance

I played around a specification template to process and contain business logic in our C # / mvc application. So far, so good. I have a question, though, since we will be creating several specification objects on the heap, will this affect performance in any way, say, create helper methods to process business logic? Thanks!

+6
source share
2 answers

I have a question, though, since we will be creating several specification objects on the heap, will this affect performance in any way, for example, create helper methods to process business logic?

Of course, this will affect performance, every line of code that you write, and the design you make affects performance anyway. It is unlikely to make sense to be a bottleneck in your application or to take care, as this is almost certainly a case of premature optimization. These days, you should just focus on modeling your domain correctly and writing extremely clear and supported code. Pay more attention to developer productivity than machine performance. CPU processes are cheap and almost limitless. Development cycles are not cheap and not unlimited in supply.

But only you can know if this will affect the actual use of your application on real data by profiling. We do not know this and cannot know, because we do not know your domain, do not know your users, do not know what performance you expect, etc. And even if we knew these things, t give you as many answers as possible, as you can give yourself, trying to profiler from the shelf and see what your application actually does.

+5
source

since we will create several specification objects on the heap, this will affect performance in some way

Most design templates divert some of the overhead for design cleanliness - this is no exception. In general, the amount of memory that is added to the specifications is very minimal (usually a few links and what it is). In addition, they typically add a few extra method calls against user logic.

Speaking of which, I would not try to optimize this prematurely. The overhead here is incredibly small, so I would really doubt that it would be noticeable in any real application.

+2
source

Source: https://habr.com/ru/post/891483/


All Articles