Live data from Hacker News

One of the Best Bits of Programming Advice I ever Got

objology.blogspot.com

51–60 of 94 posts

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

#52
Well, this is one of my reasons for python over Java as a programming language. There are some procedures that don't fit naturally into a class or object and I should be allowed write functions for them. I was a OOP fan, when i learnt c++, but when i learnt java was put-off by its' requirement of needing a class. I am learning Haskell now, and am a little infatuated with FP, but not sure will enjoy using it a couple of years down the line. I understand the Manager class has some state and methods, but just can't digest the idea of a separate class. To overextend the metaphor, i guess, that's one of the reasons i have shied away in my career from becoming a manager.:-P

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

#53

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…

[deleted]

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

#54

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?

George Orwell's five rules of effective writing come to mind: http://www.pickthebrain.com/blog/george-orwells-5-rules-for-...

And people so often substitute longer words, (e.g. 'myself' instead of 'me') when they want to sound professional.

"I hit myself" => OK "Please contact myself" => WRONG.

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

#56
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"...?

From the OP: "The fact that every single MVC implementation in the world has had a different role for Controller ought to tell us something about how well that idea fit."

We were just discussing this yesterday: http://news.ycombinator.com/item?id=3036153.

A favorite principle: when you can't find a good name for something, it's often a sign that the concept you're trying to name isn't appropriate.

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

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

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

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

#58

Earlier quoted context omitted.

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

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 constraint verification (for example), my preference is to have a container (e.g. vector) of Constraint and just run find_if() to see when Constraint::Valid(environment) returns false. Then it's a class called ConstraintVerificationUtil and it has a single static method: VerifyList.

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

#59
post #56
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"...?

From the OP: "The fact that every single MVC implementation in the world has had a different role for Controller ought to tell us something about how well that idea fit." We were just discussing this yesterday: http://news.ycombinator.com/item?id=3036153 . A favorite principle: when you can't find a good name for something, it's often a sign that the concept you're trying to name isn't appropriate.

What I still don't understand is, what would I put in place of the Controller? Events are raised by the user, these are all fired off and I want to handle them in the same place in the same way.

I certainly don't want event handling code all over the application just because this means I can then have noun-only classes?

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

#60

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…

[deleted]
Post reply on HN