DEV Community

Discussion on: What is bad code?

 
stereobooster profile image
stereobooster • Edited

Yes, I know that this thread is addressed to my reference to chess. But what you try to say to me? This is how I see it:

  • Me: Post a link to the video which says that chess is outside of NP-complete field
  • You: Apparently chess is not NP-complete. Here is a link.
  • Me: Yes. Chess is not NP-complete, because... Your link mentions PSPACE-complete, the difference between PSPACE and NP is...
  • You: ...But this all depends, because for endgames situation is different...
  • Me: Yes, but we are talking about classes of complexity so we should compare worst cases ¯\_(ツ)_/¯

Where this going?

Thread Thread
 
codemouse92 profile image
Jason C. McDonald

The overarching point is, you said "you can't prove that X chess move is best." And I just proved that, actually, yes, you can in some cases.

Thread Thread
 
stereobooster profile image
stereobooster

I mean obviously in some case it is provable, like one move before checkmate. But I talked about general case, the same way as you talk about worst case in big O notation...

Thread Thread
 
codemouse92 profile image
Jason C. McDonald • Edited

Yes, and if we go alllllllllllll the way back to the original topic of the article, some "bad code" situations are provable. It is not entirely subjective.

And the chess analogy mirrors that.

Which is my point.

Thread Thread
 
stereobooster profile image
stereobooster • Edited

True like this one

A second pass on this. THIS is bad code because it is ambiguous to the reader.

8 / 2(2 + 2)

There's a big internet argument as to whether it's 1 or 16, and it is bad code because there are multiple justifiable results from it, and the next person to come on the code may have a different interpretation.



but to me this seems like outlier, rather than typical example
Thread Thread
 
codemouse92 profile image
Jason C. McDonald • Edited

I provided you an entire list of quantifiably "bad code" principles in my other comment. None of them are outliers, IME; I've yet to find a single contradiction to any of them in any discussion about coding practice. :)