Anyone interested in giving feedback on program/app I created?

Pages: 123
Hello people!

I've asked around, quite some time ago, about a program I was working on : I've made a sort of console application (a mere program really) that does several things. The main features are:
-> It allows you to log in and out with several users with password check
-> Holds a calendar for each user
-> Keeps a list of reminder for each user (sort of sticky notes)
-> The console, on sleep, constantly displays the time in real time and the two elements above.

I'd like to know if some of you would be interested or willing to give feedback on my project (it would be wonderful to have feedback on my code too, I have the feeling it could be optimised still..).

I would be very grateful if you were :)
Let me know and I will post a link to my program.


Thanks in advance and I wish you all a good coding day!
Cheers,

Hugo.
Last edited on
Sure ...
@H00G0

I'm in, as well. Bring it on..

(Sounds like an interesting program.)
@kbw, @whitenite1, Thank you for your interest.

Here is the link to the archive containing both the program folder and the code
https://we.tl/t-nY3aDNXzHI

Note that the program will not work outside of its folder and that it is named MultiPorgram.
Please read the Readme.txt file for instruction on how to access the program.
The 'Program' folder contains said program and the 'Program code' contains all the files on
which the code is written (it's my VS 19 folder for this project).

Any and all feedback is more than welcome and I thank you so much in advance.

Have a good day / evening / night.

Hugo.
Is there a reason you posted all those binaries? I thought this was a code review?

1. Don't put using namespace ... in a header file.
2. Commands::MAX_COMMANDS can be constexpr.
3. Commands::logFile should be initialized in an initializer list, and don't call close on logfile in the destructor.
4. Don't check for an empty string with != "", use empty() or size().
5. Command::logfile should be std::ofstream.
6. Command:: userInfo, calendar and reminder are raw pointers---need to be wrapped in std::unique_ptr
7. class Command should disable copy.
8. You don't need to put return at the end of a function call (when it's obvious that you're going to return).

That's just class Command ...
Last edited on
@kbw Thank you! Some of this code I've written a while ago and I hadn't realised that had so much cleaning up to do...

Is there a reason you posted all those binaries? I thought this was a code review?
Well, I posted the entire folder in fear of forgetting some files, hence the presence of those binary files.

2. I wasn't familiar with constexpr and looked it up (I'm not quite up to date with c++ 11)
3. Should an initialiser list be used for any specific reason here, is it bad to initialise a file in a constructor and close it in a class destructor?
4. Oh yes, that makes sense, why did I not think of using those..
5. Another rookie mistake indeed..
6. That's another feature of c++ 11 I wasn't aware of, if I understand, the point of using those is to prevent memory leaks after the pointer is out of scope, is that correct?
7. What do you mean?
8. Oh yes, I used to do that all the time for void functions..

Thank you so much for your time kbw
3. Should an initialiser list be used for any specific reason here
A member object will be initialized before the main body of the constructor starts running.

In trying to initialize an fstream in the constructor body means you're initializing it twice. The way to initialize it once is to do it in the initializer list. That is true for all objects.

6. That's another feature of c++ 11 I wasn't aware of, if I understand, the point of using those is to prevent memory leaks after the pointer is out of scope, is that correct?
Yes

7. What do you mean?
Your class has raw ponters (that aren't initialized BTW). What will happen if the class is inadvertently copied? If you're lucky, they're null and nothing special will happen. But if they're not, both instances will point to the same values. When one is destroyed, does it delete the pointer or not?

To avoid this quandary, you can simply stop the class from being "copyable" by disabling the copy constructor and assignment operator.

8. Oh yes, I used to do that all the time for void functions..
Don't.
Thanks a lot @kbw

My best guess is to rebuild this from scratch, since you only pointed out at the mistakes in my Commands class.

Thanks so much for your time
If you are going to burn it all to the ground and build up from scratch consider taking some time planning out the class(es) you need/want, and how they are laid out and interact, on paper first.

Design flaws can be caught this way before a line of code is written.

Design before coding is a skill I am still learning the hard way myself.
@Furry Guy

Thanks for the insight, I think that's precisely what made my code messy when I first started working on this.

I basically started from scratch and piled up, I'm pretty bad at designing stuff since I often find things (I hadn't planned for) to add on the spot so working on paper sounds like a good thing to work on.

Thank you a lot, have a good day / afternoon / evening!
Changes will happen as you work on your program. Even a basic plan is better than none for keeping you on track.
Also, it never hurts to write out a "design document," as you did in your initial post. The "main features."

Knowing what your program is supposed to do in broad terms helps for designing classes and the other bits of code that glue it all together.
@Furry Guy

I see what you mean yes. At least, now that I've somewhat finished coding it and had all desired features implemented, I know what I want the program to do so it should be a little less messy (I hope)..
I've rewritten a few older projects that were badly spaghetti-coded.

Lots of refactoring shoving bits and pieces of code in and out of functions and classes to try to make the mess less of a hot mess.

Revising code with newer ideas later C++ standards introduced.

For instance:

Looping through a container (vector, C++ string, whatever) is easier to read and maintain now with auto instead of typing all the verbiage to get iterators.
Last edited on
I see what you mean about using more recent C++. The thing is that I'm self taught and learned with a book which was written quite some time ago and only contains C++ 2009 stuff.

Would you have any advice on some ressource or some elements of later versions of C++ I should focus on, to update my toolbox. You've mentioned auto, I already have to do so research on that one haha, are there any other like it that are handy?

EDIT: I think it's actually smarter if I look into new C++ and expand my knowledge of the more recent language than starting right now and just replicate what I did, even if it is less of a hot mess as you say haha

Thanks!
Last edited on
The thing is that I'm self taught

So am I, been trying to cram C++ into my brain since before there was C++98. I am a C++ programmer hobbyist. Learning and writing code for fun. Not one lick of formal school training.

One book? Really?

My programming library for C++ is several dozen books. None in hardcopy more recent than C++11. Most pre-C++11.

There are online resources, references and tutorials, that make the leap into modern C++. Sadly here at cplusplus is not one of them.

A technical oriented reference site that is good is: https://en.cppreference.com/w/

There are examples there, but most of the time they are not ones "for beginners."

A good, mostly up-to-date, tutorial, more for a true beginner than someone making the jump into newer language standards is: https://www.learncpp.com/

Now, about books. Multiple. As in More Than One.

https://isocpp.org/wiki/faq/how-to-learn-cpp#buy-several-books

If you are "into" digital eBooks (Amazon Kindle) there are several I could recommend.

For C++11/C++14:
C++ 11 & 14 Tips: Understand novelties in C++ with working examples
https://www.amazon.com/gp/product/B01G3CXS8E/

C++17:
C++17 - The Complete Guide
https://leanpub.com/cpp17

C++17 in Detail
https://leanpub.com/cpp17indetail
Last edited on
One book? Really?
Yes, that book was "Starting Out with C++ from Control Structures through Objects, 8th Edition". I've dug through it over a period of 3 years when I was at uni. I really loved the 'from scratch' aspect to the book, going from how a bite works to the simpler code use and onto more complicated stuff.

So my tool box regarding C++ can be summed up to the content of that book and a couple of other things I've had to pick up on the internet, for various needs of mine.


A technical oriented reference site that is good is: https://en.cppreference.com/w/
Oh this is my bible haha, it's saved my sanity more than I could ever count.

Thank you SO much for mentioning those books, and yes I would be looking to dig through digital books to learn, I like that method. I'd really want to go for that "C++ 17 The Complete Guide", does it encompass all previous versions too though (11 and 14 for instance)?
Both of the C++17 books are strictly C++17, no prior standard.

Well, not exactly true, they mention in brief prior standards to show what is new/changed. Not enough to learn them.

The first eBook I mentioned does that. As long as you have a decent grasp of the basics of pre-C++11 programming.

My current collection of books are those I've kept, proved useful and instructive in the past. I've had more that were little more than a waste of paper.

So my tool box regarding C++ can be summed up to the content of that book and a couple of other things I've had to pick up on the internet, for various needs of mine.

Nothing wrong with that. :)

As long as you can admit you have more to learn, LOTS more. I know I do.

That LearnCpp site might be beneficial for you. There might be other standard language features not C++11 or later you haven't seen and used before.

Learning how to use C++ features instead of C features is also helpful. Such as how to generate random numbers, the C++ containers (including std::string), etc.

One little, minor detail that I am very evangelically militant about, using namespace std;.

DON'T USE IT!

Saving a couple of keystroke now can and will end up causing you grief when you start creating your own classes and/or use 3rd party libraries.

https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice

https://www.learncpp.com/cpp-tutorial/2-9-naming-collisions-and-an-introduction-to-namespaces/
If I go through the C++ 2017 book and backtrack to every prior standard when I don't know them, would you say it's a bad way of going at it? Or should I go through all C++11 before thinking about looking at 17?

As long as you can admit you have more to learn, LOTS more. I know I do.
Well yes I do think I have tons to learn if not everything basically, although I'm amazed at how much I can already do with so little, I can't wait to see how much more or how much more optimised you can get things..

EDIT: This is kind of why I posted my program on here, although I'm really happy I could manage to build that from scratch, I knew that some people would find it to be a spaghetti fest. And I'd like to continue learning and improve myself as much as possible.

One little, minor detail that I am very evangelically militant about, using namespace std;.
Haha I could tell, and I understand, I've just been a lazy bum and couldn't arsed to type std:: all the time, but hey, it's never too late to change :)

Thanks again for your links, they are very informative!
Last edited on
I am learning and relearning C++11/14/17 at the same time. C++11 added considerable heft to the language. C++14 for the most part was bug fixes, C++17 added features, with a few changes.

Along the way there have been some deprecations and removals of things from the language.

Two items I can think of off the top of my head that were removed are the smart pointer std::auto_ptr and the std::random shuffle algorithm.

std::random_shuffle was deprecated in C++11, std::shuffle was added as replacement, and finally removed in C++17. It was done because(?) it used the C library rand function.

Which brings up another topic I am evangelically militant about (militantly evangelical?), how to generate random number in C++.

Before C++11 there was only one way in the standard to generate random numbers, the C library. The Boost library was an alternative.

That has changed. C++11 added the <random> library, along with the <chrono> for C++ time usage.

The C library random generator sucks. Even the C standard recommends not using it.

https://web.archive.org/web/20180123103235/http://cpp.indi.frih.net/blog/2014/12/the-bell-has-tolled-for-rand/

https://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful
Pages: 123