blakeembrey / code-problems

Common code and interview problems solved in multiple languages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

File extension overlap between languages

tclamb opened this issue · comments

When working on #60, a C++11 implementation of stack, the existing C implementation #50 already "laid claim" to the stack.h filename, so I chose to use the less idiomatic stack.hpp instead. Since C++11 isn't backward compatible with C++98, if somebody were to add an implementation in that, they'd have to use yet another extension, such as stack.hxx, stack.hh, or stack.h++.

The current organization structure probably won't scale well as more language implementations are added. For now, which files correspond to which language is fairly obvious. But as more files are added, this won't remain so clear. With multiple file solutions (which are idiomatic in some languages), the problem directories will end up fairly cluttered.

I propose individual directories within each problem for each language. The issue could also be partially solved with filename conventions, but in my opinion, that isn't self-documenting or clean. Thoughts?

I was thinking in the same thing. But I propose instead of split the problems by languages, it could continue in a problem name folder and inside, folders with the respective languages solution.

It sounds good, but I can't imagine that many solutions needing more than one file as I don't want to have incredibly detailed solutions here - that's what an actually library would be for. Should there be folders for for every language regardless of number of files to enforce consistency, or just folders for solutions that span multiple files?

Yeah, thinking in this way... I don't know any language that obligates use more than one file.
But in this idea about create folders just for solutions that span multiple files, sounds good to me.

@vhbsouza Exactly one folder per language within each problem folder, yes, I should have been more clear. :)

That is a good point. I also can't think of any language that requires more than one file, so perhaps enforcing a one-file per language limit? As long as the same extension(s) for each language is used across the repository, I think this would be sufficient.

My personal concern is C++ classes. These are typically divided up into the header (.h) file and the implementation (.cpp) file. This saves compilation time when only the implementation changes. But if these are all one-off solutions that don't belong in any real projects, this becomes a non-issue. I can just define everything in the header.

Should be resolved with the updated structure.