Live data from Hacker News

Is abstraction overrated in programming? Chess, interviews and OOP

quora.com

21–30 of 149 posts

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#21

Reminds me of an old contest - the 8 Queens problem, posed by Byte Magazine in the '80s as a programming contest. All the solutions presented started by declaring an 8X8 board, with a 1 or 0 in each cell to represent a queen. Then there was some two-dimensional iteration over the board, testing if any queen was on the same row, column or diagonal as any other. I'd dismissed that solution as inefficient from the start…

dont think because its easy for you, it must be easy for everybody else. that thought held me back for quite a while until i recognized it was bogus.

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#22
post #13

The OP has translated the interviewers question of "design a readable and maintainable abstraction for a chessboard" into "design the most space-optimized chessboard possible", then wonders why the interviewer doesn't like his solution.

Yeah during reading this i was wondering how someone can miss the point to that kind of degree. The point was to test for an understanding of object-oriented design. Yet he talks about how awesomely space effiencient his implmementation is compared to using objects.

But the interviewers seemed to also miss the ball, making irrelevant and false objections.

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#23
post #16

I’m a bit concerned with the bitboard representation. What happens when a pawn takes another piece? Edit: The above is what I would say if someone presented this approach in an interview.

I'd like to see the rest of this implemented. What does this global functions look like? Are they swamped with if statements "I hope not" or are you storing some game logic in structs to replace polymorphism. I don't disagree with with the compact pawn struct as a starting point but to further prove your point I would love to see the rest / pseudo code.

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#25
post #22
post #13

The OP has translated the interviewers question of "design a readable and maintainable abstraction for a chessboard" into "design the most space-optimized chessboard possible", then wonders why the interviewer doesn't like his solution.

Yeah during reading this i was wondering how someone can miss the point to that kind of degree. The point was to test for an understanding of object-oriented design. Yet he talks about how awesomely space effiencient his implmementation is compared to using objects. But the interviewers seemed to also miss the ball, making irrelevant and false objections.

It's a poor choice of scenario for an interview, because no-one who knew anything about writing chess software would ever write that sort of OO code. If the point was to test for an understanding of OO design, wouldn't it be a good idea to provide a problem where OO design was appropriate?

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#26

I have no idea what abstraction actually is. It seems to me it's never abstraction unless it leads to complicated designs for the simplest problems. I've been accused of hating abstraction because I wrote in C instead and programmed out my own concepts -- instead of just using a ready-made framework with ill-fitting ones (Qt in that case). A much better term than abstraction to me is "semantic compression" (got that…

Instead of "semantic compression" I use "chunking". https://en.wikipedia.org/wiki/Chunking_(psychology)

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#27
It seems nuts to me that anyone would expect the Queen class to extend Bishop just because they happen to move diagonally. A Queen "IS NOT A" Bishop.

If anything, specify traits that define the movement of the pieces and have each piece extend that trait (with the Queen extending both CAN_MOVE_DIAGONALLY and CAN_MOVE_LATERALLY).

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#29
post #9
post #3

Oh Dear Lord. Programming IS abstraction. In fact, that's pretty much ALL programming is: using, defining, and implementing abstractions.

A definition which doesn't differentiate is a definition which provides no information. If your terminology is broad enough to encompass everything, it's also too broad to tell you anything.

Defining a function is already a mechanism of abstraction. You take a snippet of code and give it a name. Usually you generalize by adding parameters. Maybe you can even make it generic (C++ templates, Java Generics, Haskell typeclasses, etc). Removing the abstraction of a function means to inline the code. You could do that manually (copy&paste).

I wrote more on this here: http://beza1e1.tuxen.de/precise_abstractions.html

Abstracting is not everything there is to programming, but modern code consists nearly completely of abstractions.

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#30
I can relate to the pain of going through an interview knowing that the interviewer is expecting a specific approach/answer (an OO answer!) that my hard-won experience has already long ruled out. And morals and/or my sense of identity — and/or a fear that the Gods are watching — refuses to allow me to play the interviewer’s game (at my own practical loss).
Post reply on HN