Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When I encounter OO beginners, I often have them check out the SOLID principles:

http://en.m.wikipedia.org/wiki/Solid_(object-oriented_design...

I think this person is violating at least 4 of them.



I feel OO is so much prone to be misused it's not even funny, exactly because of this.

Or creating a "Human" class inheriting from Body, Arm, Leg, Head

Inheritance also makes TDD a pain in the behind (my opinion) it's not even funny.


OO is a very hard art. It took me a good 10 years to be effective at it. But, I learned in the 90s, when there was a lot less knowledge available. These days, it should be a lot easier - so many good resources.

Anyway, I would love to try other ways of doing it. I see functional programming often sold as the better alternative. However, I've never seen a large code base written entirely in functional language.

Anyone have an examples of large functional programs code bases that are good to learn from?


As another mentioned, GHC is a good example. Another one that might be a bit better to look at is xmonad. It's only a little over 1kLOC and is a fully functional window manager.


GHC is written in Haskell. I don't know the line count, but I understand it to be a large project.


It was around 140K LoC as of 2011. [1]

[1] http://www.aosabook.org/en/ghc.html

EDIT: I see another poster arrived at a conclusion of 200KLoC from the same source. I'm guessing the discrepancy is about the ~40KLoC which comprise the runtime system.


Line count ~140,000, according to this: http://www.aosabook.org/en/ghc.html

And of course with more abstraction and less boilerplate, one line gets more done on average.

(Fixed the number above - read 139... as 199...)


Much like most things in life, it takes practice and intelligence.

The negative aspects are primarily because people haven't practiced enough or are being idiots.

TDD is absolutely fine with OO. We have no problems with ~2 million lines of C#. It works pretty well to be honest. If you're finding something hard to test, it's usually broken in some way and usually because concerns aren't separated properly.


"The negative aspects are primarily because people haven't practiced enough or are being idiots."

Oh, I forgot, OO is perfect. Way to be condescending.

"TDD is absolutely fine with OO"

I don't mean OO in general (and it makes it easier in some aspects) I mean inheritance.

The more your inheritance is deep the more the classes down the hierarchy (does that inherit the most) will have non trivial testing. Because of all the dependencies/initializations/creation of the parents. Oh I am sure I'm doing wrong and I have to use a VisitatorSingletonFactory I wouldn't have had a problem and "I'm being an idiot", of course.

And surely, the problem is not usually within the codebase, but in external libraries/utilities, those that you need to interface in order for your system to do things.


Sorry if I came across as condescending.

Agree with respect to inheritance.

I tend not to find any terrible libraries these days. I think people have developed some clue in the last decade.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: