Looking for input on my current project

Hey everybody,

I've started a new mini-project recently, more for exercise than anything else, but I'd like to get some opinions on it in its current state. The project is a custom dictionary/wordlist creator that will take a large dictionary file and create a new, shorter version of it, based on certain parameters. For example, you will be able to specify min/max password length, whether or not to include special characters, etc. I'd like to know if the code that I have so far is okay; I have everything stuffed into one class, but I don't see any way to split it up. I'd love to know if I'm doing anything wrong, or if there are better ways to do things. If any part of the code can be optimized, I'd love to know how. Please tell me everything that's wrong with the code, and if anything can be done better! Thanks!

Here's the link to the project on github:

https://github.com/jheinz1999/wlcreator/
closed account (48T7M4Gy)
Why would anybody want to get involved in password hacking?
That's irrelevant; I came here asking for input on the code of my project, not the reasons behind creating it. As I stated previously, this is merely an exercise. If you have any input on the code itself, including style, and general "correctness" I'd love to hear it. Thanks.
* There are no include guards in the header files.
* The header files #include source files.
* Header files contain non-inline function definitions.
* Many source files don't #include the proper headers, probably because of the second bullet point above.
* parsed in CheckArgs seems to have the sole purpose of not having to use an else clause at the end of the if/else chain (adding ~17 lines of useless code.)
* Skipping the first level of indentation in functions makes them harder to read.
* if statements have inconsistent indentation.
* hasNums would be more efficient if it were implemented with find_first_of as you did in hasChars.
* One monolithic class to do everything in the program doesn't speak well to separation of concerns.
* Names of methods should not reflect internal representation of data. What happens when you change that representation?
Thanks so much cire. I was unaware that including source files in headers was bad practice. Are you saying that it would be best to include all files in main.cpp? As for the fourth bullet point, is it not a better idea to #include everything required by the program in main.cpp? If not, why not? Is it not redundant to include the same headers in multiple files throughout your project? Also, can you see any way that the PasswordNarrower class can be split? When I think of it as an object, the only things that I can think would be to make checkArgs() a standalone function, and maybe to make a Password class that contains the functions hasChars() and hasNums(). Thanks again for your help!
Thanks so much cire. I was unaware that including source files in headers was bad practice. Are you saying that it would be best to include all files in main.cpp?

No. If you're using an IDE, all source files should be added to the project. If you're using the command line, you should enumerate all source files when you invoke the compiler/linker.

There's some useful info at:
http://www.umich.edu/~eecs381/handouts/CppHeaderFileGuidelines.pdf


Is it not redundant to include the same headers in multiple files throughout your project?

No, it's not. If a compilation unit hasn't changed, there is no reason to re-compile it. If we include everything in one file, everything must be recompiled whenever any change is made.


Also, can you see any way that the PasswordNarrower class can be split? When I think of it as an object, the only things that I can think would be to make checkArgs() a standalone function, and maybe to make a Password class that contains the functions hasChars() and hasNums().
CheckArgs definitely is a stretch of logic as a member of PasswordNarrower. I don't see making a class just for hasChars and hasNums. On the other hand, they look like reasonable candidates for stand-alone functions.




Thanks cire, if you didn't respond I probably would have made these same mistakes until I found a job in the field! You've really been a great help. I've made all of the changes you've pointed out. I'll continue on this mini-project for awhile, and I'll be sure to post to the forums if I run into any problems. Thanks!
Topic archived. No new replies allowed.