# May I post this Huffman tree program with several files?

I have been working on implementing a Huffman tree encoding program in C++ for a hobby for a while now. I just finished up with the code and, since this is a learning project, I would love to put my code on here for tips and review. However, I want to make sure I'm within what the community here is ok with, especially since I have not used this site before. So I have a couple question before I post my code.

1. My full code is split across 9 different files. 8 of these are little classes that make the rest of my code easier to work with, and they are each 30-70 lines long. If I give a short explanation of what these classes do, can I leave these out and just post my main.cpp?

2. My main.cpp file is 386 lines long. Is this too long? About 100 of these lines are just opening files, and error handling, while passing on the actual nitty-grittys on to other lower level functions. Should I exclude them from the post to make it shorter and easier to read, or should I include them to make the call hierarchy more clear?

As a general rule, we prefer to see: Your full code, unedited, exactly as it appears in your IDE. Code Review has an extended 65,535 character limit. Unless you're getting close to exceeding that, your code isn't too long.

With code split across multiple files, it is generally best to use separate code blocks in your question, with a title for each so people can easily navigate them.

A few hundred lines of code is not out-of-the-ordinary for this site, don't worry about it.

As an example on how to structure your post, take this question of mine which is split across 7 code modules.

• I don't agree fully about the full part. It is alright to leave some parts out (as long as it doesn't make the code "examplish" or hypothetical) – Simon Forsberg Dec 20 '15 at 0:19
• @SimonForsberg but being able to run the code aids reviewers. – Caridorc Apr 4 '17 at 17:49
• @Caridorc It helps, definitely, but it's not a requirement. – Simon Forsberg Apr 4 '17 at 21:54

My full code is split across 9 different files. 8 of these are little classes that make the rest of my code easier to work with, and they are each 30-70 lines long. If I give a short explanation of what these classes do, can I leave these out and just post my main.cpp?

Yes, you can leave those parts out. I would recommend linking to the full code on a Github repository or similar, so that people who want to take a look at that part can do so. If you leave them out, it definitely helps to give a short explanation of what they do.

My main.cpp file is 386 lines long. Is this too long? About 100 of these lines are just opening files, and error handling, while passing on the actual nitty-grittys on to other lower level functions. Should I exclude them from the post to make it shorter and easier to read, or should I include them to make the call hierarchy more clear?

386 lines doesn't sound too long to me. When posting this code, it is important that you don't strip it down too much so that it is "easier to read". Unlike Stack Overflow where "minimal examples" are the norm, we want full context.

In general, when having several classes, it is perfectly okay to leave entire classes out from the question itself. When posting only one class, it is usually alright to leave entire methods out. But avoid stripping code away from methods when posting site to Code Review, as doing so makes your code look like hypothetical code or example code - which is off-topic here.

While you can leave out certain sections of your code, you should post full files/classes in a single review. It is not uncommon for several related classes to be posted on this site for review. For the optimal experience, post a section of related code, probably main.cpp and a few of the help classes that do the most work. You can then post the other part in a separate question after you get some answers and improve it based on the feedback.