What are the cons of some code like this:
public class Class1 { public object Property1 { set { // Check some invariant , and null // throw exceptions if not satisfied // do some more complex logic //return value } } }
The con would be that if you are doing excessive logic that takes a great period of time, and/or has side effects which don’t logically flow from the setting of the property, you are going to have a pretty convoluted class design.
Methods are traditionally used to indicate that an action with consequence is being performed, not properties. While you definitely can have logic in them, having too much might give the wrong impression of what you are trying to do, which is assign a value, as opposed to perform an operation.
In the end, it all depends on what ‘do some more complex logic’ means.