News for hackers. Stuff that matters.
Re:Why bad scientific code beats code following “best practi... by kilink on Sunday August 28, 2016 @07:54PM (#12379140)
I think the advice is more relevant in the context of the specific language; it's not universal.

In python you can go from attribute access to using a property (getter/setter) without breaking anything.

The same is not true in a language like Java where obj.foo is always a direct field access distinct from calling a method like obj.getFoo(), so going from public fields to getters is not backwards compatible and can be painful.

Re:Why bad scientific code beats code following “best practi... by superbatfish on Sunday August 28, 2016 @09:22PM (#12379418)
>In python you can go from attribute access to using a property (getter/setter) without breaking anything.

True, but that should be avoided if possible. Python 'properties' violate the principal of "explicit is better than implicit". Once you realize "Oops, I need an accessor function here", the lazy programmer says "Aww, grepping for all uses of .foo and replacing them with .getFoo() will take 20 minutes. Instead, I'll just redefine it as a property and no one will notice." If you care about quality, go the extra mile: make it clear to the people reading your code that a function is being called.

Properties are a kinda nice language feature, but they are so frequently misused that I think the language would have been better off without them. They encourage bad habits.

Re:Why bad scientific code beats code following “best practi... by qwertyuiop924 on Sunday August 28, 2016 @08:59PM (#12379351)
However, it's still a simple enough change that you shouldn't build getter/setters unless you're already pretty sure it'll be changed. OTOH, if you're using a language with generated getter/setters (ruby, smalltalk, lisp), just do it.
Re:Why bad scientific code beats code following “best practi... by sbov on Monday August 29, 2016 @01:00AM (#12380103)
Using find & sed is not painful.

I use getters and setters, but still think you will waste more time arguing about this issue, than leaving it be and finding out you have to change them down the line.

Edit: also, especially for getters, I like my accessors to be simple accessors. Hiding too much code behind them can be unpleasantly surprising, so as they deviate further from accessors I like to rename them - e.g. CalculateXxxx rather than GetXxx. Fewer surprises. Given that, I potentially have an issue with continuing to call it GetXXX or SetXXX in the face of certain changes.

Re:Why bad scientific code beats code following “best practi... by pitay on Monday August 29, 2016 @02:40AM (#12380395)
Using find & sed is not painful.

Using an IDE with an understanding of the language you have is even less painful. Having the IDE automatically refactor a public field to use getters and setters is a breeze with managed languages like Java and C#.

Re:Why bad scientific code beats code following “best practi... by imtringued on Monday August 29, 2016 @05:35AM (#12380890)
The same can be said about interal interfaces with only one implementation. If there is really a need for an interface then why not add it later until it's actually needed it instead of creating additional overhead for something we may never need?