Are partial methods considered harmful?

In C # 3.0, Microsoft introduced support for what are called partial methods .

Do you use them? Can you describe how and why?

Do you find using partial methods a good programming practice or not?

+3
source share
6 answers

Partial methods are primarily useful for extending the behavior of the code generated by the tool, at no cost both in estimating runtime and in visible user code where such extensibility is not used.

, , , ( ). , , , , , . , API. ref/out, /, , . , , .

, , , , ( ​​ , , ). , , , API, .

+10

, (). , .

+1

, . , .

#if/#endif , Compact Framework, , .

, - # if/# endif. , LINQ, .

, , LINQ . linq, , , lib DLL, . .

+1

# VB C ++, , . - , WPF. .

, , - . , class BigForm BigForm-BillingInfo.cs, BigForm-ShippingInfo.cs BigForm-LineItems.cs. , ( ..).

0

- , , , -. , -, , , ( ..).

, , silverlight, :)

//, , . , .

0

Microsoft " ". , , BASIC Turbo Pascal. Microsoft . , , : - , , , . - .

CACM, . . , , , .

, . Microsoft Eary . , , .

The trade-off comes down to: do you want enough rope to hang yourself, or do you want to be forced to rewrite parts of your architecture to satisfy the rigidity of the language? A disciplined team can write good code in any environment, and there is no universal correct answer.

Let's get back to quesiton on hand: I don't think partial methods are a great language feature, but if they are necessary for LINQ to work, they definitely deserve tolerance.

-2
source

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


All Articles