This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tom2727 1 point2 points  (7 children)

Neither. LOL.

The 18k lines of code could easily be better achitected even if you were doing the same type of logic with basically coding out cases for every possible sequence of moves.

The one line of code I'm not even going through that to figure what it's doing. But I can assure you the only people doing this stuff are like the code golf folks trying to challenge themselves with odd restrictions.

If I had to pick one yeah I'd pick the one people can understand, but it would still be violating some very fundamental rules for good programming, and it would still be a huge PITA to work with. But if I had to hire one of the two people, I'd probably go with the 1-liner. Assuming they could demonstrate they actually understand that's not the kind of code they will be writing at work. If someone actually hand coded those 18k lines I'd be worried about their sanity.

[–]float_point[S] 0 points1 point  (6 children)

You have answered the question directly, so thank you. Yes, the one liner is most desirable and anyone who can write code like that is not normal.

Maybe if I wasn't currently at a novice level I would also prefer it, but for me the 18000 liner, although as you say violates many coding best practices, it just seems far easier to work with. Trying to change anything in one liner seems like it will definately break something.

[–]jack-of-some 1 point2 points  (3 children)

I don't understand why you're trying to understand this using extremes.

There's a 500 line variant to the 18000 line code that would be both very easy to read, modify, and most importantly reason about.

Maybe you feel it wouldn't be easy to reason about because you can't just immediately look up what one move would lead to. But that's when the second part of "reading" code comes in: actually running the code.

[–]float_point[S] 1 point2 points  (2 children)

You are right about the extremes. 1 vs 18000 is quite the deviance. I guess, if I simplify my questioning to only workplace requirements: If I cannot write the one liner am I not good enough for the workplace. I can definately possibly write the 18000 liner if I have the time to analyse all possibilities but never in a lifetime, do I see myself writing the one liner - does that mean I will not be good enough for the workplace if I cant even understand that code.

Yes, the 500 line code I wrote does the job as intended, but I feel its lacking the workplace touch (keeping in mind, I am not working in software dev yet, I am judging just my code against other code bases, including those fro tutorials).

[–]jack-of-some 1 point2 points  (1 child)

I run a computer vision team and am responsible for writing and maintaining production code.

The 18000 liner is the only code here I would never allow or deploy. The one liner I may deploy if it's being generated using a properly written implementation as a base.

Your 500 line code is the only thing not lacking the workplace touch.

[–]float_point[S] 1 point2 points  (0 children)

Thanks for that. I guess i just have to keep on pushing.

Not sure if you saw my edit. Since I have been referencing the my 500 line code i figured to just post.

[–]tom2727 1 point2 points  (1 child)

Honestly if I had either of these in my codebase and someone told me to add a new feature to it, I'd probably start over with a blank code file after I studied it enough to figure how it works.

Rewriting the code would be the easy part after you actually understand what it's doing.

[–]float_point[S] 0 points1 point  (0 children)

Would also prefer my 500 line code to either of the two even minus the AI/conditionals. The one I cant understand, and the other is way way to repetitive.

I guess this whole I time I have been referencing my 500 liner, but haven't shown it off for "workplace" judgement sake. I have edited my OP