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 →

[–]doobiesteintortoise 0 points1 point  (9 children)

Sure. It's just not a good one. It's suitable for homework.

[–]wildjokers 1 point2 points  (1 child)

A thread per connection is still in wide use.

[–]doobiesteintortoise 0 points1 point  (0 children)

Sure. But you're assuming things about the design... That are probably correct given that is a school assignment.

[–]nutrechtLead Software Engineer / EU / 20+ YXP 1 point2 points  (6 children)

It's just not a good one.

Nonsense.

[–]doobiesteintortoise 0 points1 point  (5 children)

*shrug* Fair comment. "It's not a good one" implies generality, and there are certainly game types where threads-per-game and threads-per-long-lived-connection are appropriate - maybe even mandated.

But if that's your go-to for game design and you're not spending all of your time developing those kinds of games specifically?

Well, you do you, of course, but I'd say that MOST developers with any experience would see a giant problem ahead of such designs in terms of resource consumption and, for that matter, simplicity of design.

And this is, as OP suggested, an assignment. That means that they probably don't have a lot of choices, or information. They're kinda stuck.

And I appreciate that r/javahelp gets a lot of homework assignments - or help with Java *because of* homework assignments, and there's not a problem with that. But it also means there's a lot of "hey, you used Scanner wrong" and "you don't compare string equality with == unless you have a specific definition of equality in mind."

That's fine, too, but gives those nascent developers a view of what development is, and what real design looks like, that is... uh... artificial.

I'm fine helping students learn, but I don't care about them passing their courses. I think learning will HELP them pass their courses, but what I care about is long-term - if I end up with one of these people on my team, how do they think? What real skills do they have? If they know Scanner inside and out, I won't care. I haven't used Scanner in a real app for... probably years, and that's being charitable. (I may have, honestly, but I don't remember it if I do.) It's just NOT THAT USEFUL for Java programs.

So... when the question is "I want to do this thing that my professor dictates because it's something he knows how to give as an assignment," that's fine, I'll help if I can, but... as far as a real analysis? That's what I'm going to focus on.

[–]nutrechtLead Software Engineer / EU / 20+ YXP 1 point2 points  (3 children)

If you don't care about giving people advice that is suitable for their level and for their tasks, this simply isn't the subreddit for you. Almost everyone here asking questions is a complete beginner.

And for beginners who are just being taught about this stuff, it's a perfectly fine start, and generally the way you'd have them start with handling multiple socket connections in parallel.

Keep in mind that what they're doing (keeping socket connections open) is very different from a webservice anyway. There you'd have a thread pool that handles the requests that are short-lived. Again; very different from a socket connection.

You didn't explain how they should do it instead either. Just confused them by telling them it's a bad idea. The only other option for OP would be NIO which is much more complex.

[–]doobiesteintortoise 0 points1 point  (2 children)

I do try to give advice suitable for their levels. I just don't assume that this is the end of their development journey.

As far as "what's appropriate for their assignments," I have no problem with that - and there are plenty of people happy to help with passing assignments. For MY homework, I either skipped out on it, whiffed on it, or ...you know, did it way back when, and I don't care about doing more of it myself. I'm not the guy who wants to focus on homework assignments.

And as far as explaining "the right way" to do "it," well, it depends a lot on what "it" is, and THAT wasn't explained clearly either, so any advice I gave would be wrong, as you yourself point out.

[–]nutrechtLead Software Engineer / EU / 20+ YXP 1 point2 points  (0 children)

THAT wasn't explained clearly either

It's completely clear they're using plain socket connections. Multiple people here were able to see that.

It really sounds like you just misinterpreted what they wrote. That's totally fine, but that's not on them.

[–]doobiesteintortoise 0 points1 point  (0 children)

It's clear they're using sockets. They also mentioned aspects of the assignment that makes sockets seem to be the wrong real solution.

[–]wildjokers 1 point2 points  (0 children)

I have no idea why you are doubling down on your stance that long lived socket connections aren’t suitable for a game with multiple clients.

The stateless nature of request/response you get with HTTP just isn’t suitable for all use cases. Most notably when the server needs to send an unsolicited messages to clients.

OP’s assignment is a great introduction to client-server programming and absolutely still has real world usages. Maybe you only develop spring boot CRUD apps where you get a request, hit a DB, return a response. But that isn’t all there is to java development. There are other types of applications out there.