Do you think C # attributes (or similar mechanisms) are a good idea or are you discouraging their use?

I founded many designs and frameworks that have been using C # attributes for the past 4 or 5 years.

But lately, I see that many people openly impede their use or change their scope to reduce the need or use of them.

I found them a find, but now I'm starting to wonder what I am missing.

To clarify: Using a convention over configuration is becoming a basic principle that should be followed, especially in the field of ORM. This area allows you to map fields to a configuration file (XML), use an attribute, or have a general naming convention that maps directly to fields in database tables. I have no links to the quote, but I read some reaction against adding another attribute to the mix.

But I feel that in the three options I just listed, Attributes still make the most sense. The configuration file is harder to maintain, and a common naming protocol connects you to the implementation of the database field. Attributes are placed exactly where they are needed, and the implementation can change without disconnecting from where it is used.

+3
source share
7 answers

There are really two purposes for attributes: both things visible to the user and things emitted by the compiler.

I assume that you are talking about the visible attributes of the user.

In general, I would say that the user's visible attributes are not perfect.

#. DLINQ. , , , . . ( linq-to-sql).

, , . .

, - # , .

.

3 :

# 1 , .

+3

, . - , , . , , , .

. . , . , .

, , , , . ? /, .

+7

, " "; , " , ".

, , , . , - - , .

... , , . .

+4

, . , .

, , .

+2

ASP.NET MVC. , MVC . , -, , , MS, , MVC.

, () /, . , MVC , , MVC.

+1

, ASP.NET MVC - -, , . Framework, , . MVC - , . , , ActionFilter, . , .

0

, , , , .

. , DI (MEF - ) , .

I think it’s going crazy, adding that user-defined attributes can be crowded. I personally love to use attributes, but I try to minimize their use and use them only where they make the most sense.

0
source

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


All Articles