Live data from Hacker News

One of the Best Bits of Programming Advice I ever Got

objology.blogspot.com

61–70 of 94 posts

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

#61

Earlier quoted context omitted.

You're suggesting I call them "StateSynchronizer" or "ConstraintVerifier"?

No, I suggest you name it after what it actually does. "Controller" is a role that's only defined in terms of what it interacts with. It's essentially a declaration of rank with other types; it doesn't say anything about what functionality the class provides. If I'm looking at the components of the software, and I want some code to do X, or wonder what a class Y does, what does "Controller" tell me? If you're doing c…

"Controller" says to me that it's the where all the events are dealt with, so I can have one single place where events are handled.

As for "ConstraintVerificationUtil", I personally feel that things that end in -Util are definitely worse than things that end in -er. Maybe that is just personal preference.

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

#62
post #41

Earlier quoted context omitted.

Is there a collection of suggestions from Stephen King? I love picking up small pieces of advice from respectable writers, and he is undoubtedly one of them.

Stephen King's On Writing: A Memoir of the Craft .

Most of the book is his less-than-riveting autobiography.

The ~16 pages which are in fact about writing ("Toolbox") are worth more than the cover price.

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

#63
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.

Ruby does this with mixin modules :)

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

#65
post #30
post #14

Earlier quoted context omitted.

I was going to write basically the same thing. I used to combine data and action in the same classes but recently have begun refactoring them out into separate data and "-er" classes. Maybe somewhere an OOP purist is frowning, but I really prefer this naming convention. My FlowchartShape class included methods for formatting and positioning. I now have a FlowchartShapeFormatter class and a FlowchartShapePositioner cl…

Agreed. The reason I end up with some '-er' classes is to separate out immutable definitions and the classes that work on the definitions. In your example, by making the FlowchartShape a simple definition class, you can then write that to a file or send it over the network as a snapshot of the state of the -er classes. If the article's advice was taken, you'd end up renaming WebServer to be WebPage, but then would ha…

It doesn't seem like it'd be any more difficult to write the FlowchartShape to a file or send it across the network if it had additional methods on it to manipulate and use its state, so I'm not sure what's gained by making two+ separate classes... what am I missing?

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

#66
post #41

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?

Is there a collection of suggestions from Stephen King? I love picking up small pieces of advice from respectable writers, and he is undoubtedly one of them.

Someone else mentioned Stephen King's (enjoyable) book. If you're after more "small bits of advice from respectable writers" you should look into Lawrence Block's books, specifically "Telling Lies for Fun and Profit" which I keep coming back to whenever I'm stuck.

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

#67
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.

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...

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

#68
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.

     interface ICopyable {...}

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

#69
The most correct program (in terms of maintainability and evolution -- as well as mathematical correctness) approximates the most orthogonal program.

In term of modeling it with objects that contain state, this may mean having objects that have a varying degree of state (unless you choose other purer approaches).

But it's naive to think that all classes should be a noun. Everything should be an abstraction that models the solution. However, nouns that end with 'er' do tend to have a little bit of state that seem unorthogonal. But I guess my point is that that's the wrong way to look at it. Better to think about it in terms of DRY. Some 'manager' or 'controller' classes violate DRY (whereas it's rare for 'connection' classes to). But not all 'manager' or 'controller' classes do.

Post reply on HN