News for hackers. Stuff that matters.
Re:“A closure is a poor man’s object; an object is a poor ma... by scarface74 on Monday May 01, 2017 @10:30AM (#14237675)
And the other alternative, because an object still usually needs some type of values would be:

class Foo { Foo(string bar) { _bar = bar; } //Foo is the constructor }

The benefit being that once an object is created, it is guaranteed to be in a valid state.

But by classical OO an object represents state + behavior. So why not do both?

Assign the value in the constructor to guarantee that the object is always in a valid state and use a property (if the object is an entity as opposed to a value object), when it needs to change?

Re:“A closure is a poor man’s object; an object is a poor ma... by lacampbell on Monday May 01, 2017 @07:36PM (#14242750)
Why is it changing? have the method name reflect that domain reason, not reflecting the mechanical details of which internal fields need to change.