I often find that attributes can be too large. Sometimes it feels like the attributes take up more of the screen than the code. It can make it hard to spot the method names.
Also, they are not reusable, so you can end up repeating your values a lot.
To counter this I considered creating my own attribute class, which inherits from the required
attribute, and just sets all the properties to the defaults I need.
However, in most cases attributes are sealed, putting a stop to my schemes.
Is there any alternative to large attributes?
As a random example of what I'm talking about:
[SoapDocumentMethod(
"http://services.acme.co.uk/account/Web/GetCustomerDetails/GetCustomerDetails",
RequestNamespace = "http://services.acme.co.uk/account/Web",
ResponseNamespace = "http://services.acme.co.uk/account/Web",
Use = SoapBindingUse.Literal,
ParameterStyle = SoapParameterStyle.Wrapped)]
public Response GetCustomerDetails(Request request)
{
//...
}
While it doesn't solve all your problems, you should be using constants for your repeated values, especially strings.
[SoapDocumentMethod(
URL, RequestNamespace = NAMESPACE, ResponseNamespace = NAMESPACE,
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public Response GetCustomerDetails(Request request)
{
//...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With