Raja
Raja

Reputation: 3618

Classes and Files VB .Net

I have close to 150 reference tables and I am working on the service which would get the reference lists. I am trying to write a code generator and would like to know if there are any performance related problems if I have multiple classes in one file. I know that it would be difficult to maintain one huge file. But I am more concerned over performance than maintenance.

Any suggestions are most welcome.

Thanks in advance.

Regards,

Raja

Upvotes: 3

Views: 92

Answers (2)

Bradley Uffner
Bradley Uffner

Reputation: 17001

To the best of my knowledge there is no performance penalty or benefit to placing more than one class in a file.

There would be a maintenance cost associated with it, as it could make the class you want to edit harder to find.

Upvotes: 2

Jon Skeet
Jon Skeet

Reputation: 1503519

It'll make no difference to the compiled code. I do this all the time in Protocol Buffers with the generated code - admittedly that's C#, but it's the same principle.

It may well make Visual Studio slow if you ever open that generated code file, e.g. for debugging, but that's a different matter. (I believe Visual Studio on its own isn't too bad, but I seem to remember that Resharper slows down with big files. Apologies to Jetbrains if I'm misremembering this!)

From the point of view of making the generated code easier to include in project files etc, it's handy to have just a few large files rather than lots of small ones, so it sounds to me like you're doing the right thing.

Upvotes: 5

Related Questions