--Thoughts? Ideas? Suggestions.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
The project is an MMORPG emulator. It's a port of an existing project written in C#, so I expect parity on size of the codebase, but maybe less. I should say that I haven't gotten everything written yet; I'm trying to set up a reasonable pattern for organization before spending any more time on a potential dead-end port.There'll be a few hundred types at the bare minimum, and probably only 20 - 25% of those could be grouped together, file-wise i.e. instead of having a hundred of those types in a hundred files, it could be condensed to, say, 10 files with 10 types each. That would be grouping by relationship.
--
I don't need to put every single one in the same package. There's definitely a ton of stuff I could package up that doesn't have a circular dependency. Here's an example of my current plight:- there's a server struct and a client struct to handle the listening and handling of individual client connections- there's a packet manager, which holds a list of functions to handle different packets- there's N number of packet handlers, and in most cases, N number of packet responders (code to send a response to a request)So, to me, it makes a lot of sense to put the server/client structs at the top level, because they aren't networking-specific. The packets and packet manager are definitely related to networking, so I have them tentatively organized under a 'network' folder. For the packet handlers and responders, they're down further in another directory to handle just those.For one of the packet handlers, it's a little over thirty lines of code. There's over a hundred packet handlers I'll need to implement, many of them that will be double or triple the amount of code. I really don't fancy having to shove them all back into a single file. This isn't the only place where there's a lot of units all related to each other. It's an emulator for a game, so each player/character type will have tons of abilities, etc. Is the only solution besides a custom toolchain to have tens to hundreds (because there's no feasible way to do it in less files) with thousands of lines per file?It just seems asinine that basic folder organization isn't possible.
On Wednesday, January 29, 2014 10:18:24 PM UTC-5, Jesse McNelis wrote:On Thu, Jan 30, 2014 at 2:16 PM, Toby Lawrence <tobias....@gmail.com> wrote:--
The project is an MMORPG emulator. It's a port of an existing project written in C#, so I expect parity on size of the codebase, but maybe less. I should say that I haven't gotten everything written yet; I'm trying to set up a reasonable pattern for organization before spending any more time on a potential dead-end port.There'll be a few hundred types at the bare minimum, and probably only 20 - 25% of those could be grouped together, file-wise i.e. instead of having a hundred of those types in a hundred files, it could be condensed to, say, 10 files with 10 types each. That would be grouping by relationship.Why do you need to put all the types in a single package?If you've got hundreds of types they're probably not all similar enough in functionality to be in the same package.
=====================
http://jessta.id.au
For one of the packet handlers, it's a little over thirty lines of code. There's over a hundred packet handlers I'll need to implement, many of them that will be double or triple the amount of code. I really don't fancy having to shove them all back into a single file.
This isn't the only place where there's a lot of units all related to each other. It's an emulator for a game, so each player/character type will have tons of abilities, etc. Is the only solution besides a custom toolchain to have tens to hundreds (because there's no feasible way to do it in less files) with thousands of lines per file?
It just seems asinine that basic folder organization isn't possible.
I don't need to put every single one in the same package. There's definitely a ton of stuff I could package up that doesn't have a circular dependency. Here's an example of my current plight:- there's a server struct and a client struct to handle the listening and handling of individual client connections- there's a packet manager, which holds a list of functions to handle different packets- there's N number of packet handlers, and in most cases, N number of packet responders (code to send a response to a request)So, to me, it makes a lot of sense to put the server/client structs at the top level, because they aren't networking-specific. The packets and packet manager are definitely related to networking, so I have them tentatively organized under a 'network' folder. For the packet handlers and responders, they're down further in another directory to handle just those.For one of the packet handlers, it's a little over thirty lines of code. There's over a hundred packet handlers I'll need to implement, many of them that will be double or triple the amount of code. I really don't fancy having to shove them all back into a single file. This isn't the only place where there's a lot of units all related to each other. It's an emulator for a game, so each player/character type will have tons of abilities, etc. Is the only solution besides a custom toolchain to have tens to hundreds (because there's no feasible way to do it in less files) with thousands of lines per file?It just seems asinine that basic folder organization isn't possible.
In Go you can implement an interface without even mentioning it at the implementation site. Leverage this to avoid circular dependencies.
Interesting approach. I'm pretty sure Go doesn't have it, but the particular project I'm porting leveraged C#'s attribute system and reflection to dynamically find packet handlers at run time and link them up, Obviously I have to still solve problems like cyclic imports, and what not, but boy do I wish Go had that sort of thing. Not the biggest deal in systems programming, I suppose.For the time begin, I've been going the interface route. It's a little more stubbing-out work, but, so far, so good. I'm trying to at least get to the point where it supports basic functionality.
After reading everyone's responses and thinking about it, it was a bit of premature optimization to be so worried when the code was still a drawing on a napkin, so to speak.
I appreciate everyone's thoughts on the subject, though. It was aggravating at first, but now it feels weirdly good to be using this interface approach. I also realized that this lends itself very well to being able to mock objects for testing without complicated reflection or anything. I imagine that will make designing tests much, much easier.