Live data from Hacker News

One of the Best Bits of Programming Advice I ever Got

objology.blogspot.com

71–80 of 94 posts

Re: One of the Best Bits of Programming Advice I ever Got

#71

Earlier quoted context omitted.

A simple counter that can be manipulated with two buttons "Up" or "Down": https://github.com/HeinrichApfelmus/reactive-banana/blob/mas... main = start $ do f counter] actuate network This doesn't look like good UI code to me. It seems to use too many advanced FP concepts that have nothing to do with the task at hand. Are you sure this is better than the OO approach? Why?

This doesn't look like good UI code to me. It replaces a mutable counter (that could potentially be changed anywhere in the program) by a definition of the counter that describes all possible changes it can have during its lifetime: counter = accumD 0 $ ((+1) So, we have a counter that has an initial value of one. Over time, 1 can be added and 1 can be subtracted, namely when repsectively an eup or edown event occurs…

> Being able to capture all possible 'state mutations' of a value in one assignment is good.

I think there's a duality here. If there are 20 buttons, each of which can affect some of 30 counters, then the Haskell code would say "this counter is affected by these buttons", while imperative/OO code would say "this button affects these counters". It's not obvious to me that the former way of organizing code is better.

Re: One of the Best Bits of Programming Advice I ever Got

#73
post #68

Earlier quoted context omitted.

Yeah, but good luck trying to reuse the same basic instructions to scan non-paper objects without multiple inheritance.

interface ICopyable {...}

Back in the days at PARC, that was "IXeroxable".

Re: One of the Best Bits of Programming Advice I ever Got

#74
post #20

Amazing how small linguistic changes can cause large semantic shifts. Comparable to the post's rule: in English, a few rules I've picked up are - avoid words ending in "ly" (suffix weakens concepts; suggestion from Stephen King) - never start a sentence with "I" and otherwise minimize its use - "but" negates everything that came before - avoid "to be" Any other such suggestions, in natural or artificial languages?

Avoid the passive voice.

Geoffrey K Pullum has a delightful article tearing Strunk and White's prescription and examples to pieces. While there's some truth to the advice, it is often simplistically presented and ludicrously overapplied (uh, I mean, "style guides often present it simplistically, and editors often overapply it"). There's plenty of room for the passive voice, and even more so when you consider what Strunk and White consider to be passive even though it isn't.

http://chronicle.com/article/50-Years-of-Stupid-Grammar/2549...

Re: One of the Best Bits of Programming Advice I ever Got

#75
post #6

I generally accept the point made in the article, but what should I use in place of "Controller"? If using MVC I generally call it "ApplicationController" or "SimpleController". Should it be "Application", "ApplicationControl"...?

what do the controllers actually do? Synchronize state? Verify that constraints are met?

Arcade games are a good analogy for MVC. The controller is the joystick, buttons, etc. The view is the CRT screen. The model represents the game state.

Re: One of the Best Bits of Programming Advice I ever Got

#76
post #74
post #20

Earlier quoted context omitted.

Avoid the passive voice.

Geoffrey K Pullum has a delightful article tearing Strunk and White's prescription and examples to pieces. While there's some truth to the advice, it is often simplistically presented and ludicrously overapplied (uh, I mean, "style guides often present it simplistically, and editors often overapply it"). There's plenty of room for the passive voice, and even more so when you consider what Strunk and White consider to…

whats humorous is that Strunk and White use the passive voice in their recommendation to not use it!

Re: One of the Best Bits of Programming Advice I ever Got

#77
post #40
post #15

I am unconvinced. Any absolute deserves close scrutiny, and "real nouns only" is an absolute. In this case, it fails my test. I find that many things I work with (especially huge Java libraries) tend to have convoluted and difficult-to-understand webs of classes with the most confusing pieces named things like "FooManager" or "FooController". So the author of this piece is reacting to a genuine excess. But Travis is…

I think there is a more fundamental misunderstanding in OO than bad naming convention. You are right about the usefulness of -er named objects -- but then again, are they really objects, or just functionality wrapped into a wrongly chosen language construct? Following your example, you could have implemented the strategy pattern into DatabaseConnection to freely inject functionality into the object when X happens. As…

There are many times when the objects really do have both data and behavior -- glancing at the real code that was the basis of my example, I see that the LoggingDatabaseConnection has real state (the place to log to) and the pool flushing one has real state (keeps track of open cursors so they can be auto-closed when it is returned to the pool).

Of course, you also could be (and I was) using a deficient language like Java which doesn't HAVE any way to use a function or lambda. But I agree with you: a simple lambda a better solution where it is available.

And this kind of use is quite far from what Alan Kay intended when he designed SmallTalk. The original idea was that the objects would correspond to real-world entities. I would contend that since then OOP has evolved, and now the key idea of an object is the pairing of data and methods. Choosing the abstractions which will make the code most readable is one of the great challenges of programming well, and I find that just going for the nouns every time is NOT the best answer.

Re: One of the Best Bits of Programming Advice I ever Got

#78
post #35

Earlier quoted context omitted.

I think in the author’s ideal world, we would not have Photocopier, Scanner, and Eraser objects, but rather a Paper object that can copy, scan, and erase itself.

Yeah, but good luck trying to reuse the same basic instructions to scan non-paper objects without multiple inheritance.

See: Mixins, Traits, Apects. Whatever your language wants to call them, they're fundamentally the same, and solve the issue you're raising.

Re: One of the Best Bits of Programming Advice I ever Got

#79
post #67
post #20

Earlier quoted context omitted.

Avoid the passive voice.

There are reasons to use variants of the passive voice. Using Wikipedia's NPOV [1] approach with speaking with people is very useful in attempting to agree on fact first so emotion is avoided for charged situations/discussions. [1] https://secure.wikimedia.org/wikipedia/en/wiki/Wikipedia:Neu...

Scientific reporting also benefits greatly from use of the passive voice.

Re: One of the Best Bits of Programming Advice I ever Got

#80

Amazing how small linguistic changes can cause large semantic shifts. Comparable to the post's rule: in English, a few rules I've picked up are - avoid words ending in "ly" (suffix weakens concepts; suggestion from Stephen King) - never start a sentence with "I" and otherwise minimize its use - "but" negates everything that came before - avoid "to be" Any other such suggestions, in natural or artificial languages?

"I can' let you do that, Dave"

There are plenty of times to use "I" at the start of a sentence. Told by my boss "we're out of power converters", it's natural and correct to simply say/write "I will get some at Toshi station on the way in". Trying to find a sentence to say the same thing without starting with "I" is unnecessarily torturous.

Post reply on HN