Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had fun creating this script to play with the map function, headers, implementation files and such. However, in real life what actual use case would this be practical for? (if any)

main.cpp
----------------------
#include <iostream>
#include <map>
#include "Books.h"

using namespace std;
using namespace books;

int main()
{
	Books book;
	book.output();

	return 0;
}

Books.h
-----------------------
#ifndef BOOKS_H_
#define BOOKS_H_

#include <iostream>
#include <map>

using namespace std;

namespace books {
	class Books {
	public:
		Books();
		virtual ~Books();
		void output();
	};
}

#endif /* BOOKS_H_ */

Books.cpp
------------------
#include <iostream>
#include <map>
#include <string>
#include "Books.h"

using namespace std;

namespace books {
	Books::Books() {

	}

	Books::~Books() {

	}

	void Books::output() {
		map<int, string> book_title;

		// Initialising
		book_title[1] = "Book 1.";
		book_title[2] = "Book 2.";
		book_title[3] = "Book 3.";

		cout << endl;
		cout << endl;

		for (auto b : book_title) {
			cout << b.first << " : " << b.second << endl;
		}

		cout << endl;
		cout << endl;
	}

}


What I have tried:

I am not certain what I should research when trying to apply a fun mini project to a practical business use case.

Any advice on this is welcome.
Posted
Updated 11-Jul-22 19:04pm
Comments
CPallini 12-Jul-22 2:03am    
'Script'?!
OMG.
Richard MacCutchan 12-Jul-22 3:49am    
You are looking at the issue the wrong way round. You should start with the use case and work out the coding necessary to implement it. What you have is a simple piece of code which merely serves as a C++ learning exercise.

Quote:
However, in real life what actual use case would this be practical for? (if any)

This code is good only for your training as you are learning. Sorry to say it.
Every professional programmer is doing much more complex coding on a daily basis.

My advices to beginners:
- Start with an easy/safe language: VB, Java, C#, not C or C++. I do not recommend to start with Python either because of the usage of indentation.
- Read documentation / Follow tutorials (a lot of them)
- Start with tiny/useless projects, the purpose is to learn programming, not doing something useful.
- Start with console mode programs (no fancy graphics, no mouse)
- Learn debugger (an incredible learning tool)
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
- A problem ? Google is your friend.
- Learn one or more analyze methods, E.W. Djikstra/N. Wirth Stepwize Refinement/top-Down method is a good start.
Structured Programming.pdf[^]
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[^]
https://en.wikipedia.org/wiki/Structured_programming[^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[^]
Program Development by Stepwise Refinement[^]
- Learn Algorithms and Data-Structures.
GitHub - The-Art-of-Computer-Programming-Books: "Everyday life is like programming, I guess. If you love something you can put beauty into it." ? Donald E. Knuth[^]
Skiena The Algorithm Design Manual
- Learn Boole algebra
- Learn SQL
- Learn Databases design and Administration
Introduction to database design[^]
1NF, 2NF, 3NF and BCNF in Database Normalization | DBMS Tutorial | Studytonight[^]
- Learn Regular Expressions

Interesting link:
stanford.edu: Learn to Program[^]
CodersLegacy - Imparting knowledge to the Future[^]

There is no shortcut to knowledge, no one can learn for you, you are the only one that can do it.
Remember the exercises and little projects are not here to make something useful, they are here to teach you programming.

My most important part is probably: Learn one or more analyze methods.
 
Share this answer
 
Comments
CPallini 12-Jul-22 2:02am    
5.
Patrice T 12-Jul-22 4:07am    
Thank you.
Quote:
what actual use case would this be practical for?
Being brutally honest, none.

It's a "homework assignment" type app, and is far too limited to be of any real use.
For example, you'd have to modify the source code and recompile it every time you bought or gave away a new book!

Tasks like these aren't meant to be used in the real world; they are meant to teach you how to analyse a task specification, design a solution, implement it, test it, and get it working - which requires a particular mindset, a "way of thinking" that many people do not develop naturally, or do not try to apply outside the narrow field in which they do develop it. These are "general skills" which are part of the problem solving process which are applicable to any problem, computing or not.

And skills need to used in order to develop them, just as riding a bike requires you to get on and try to pedal in a straight line without falling over - you can watch as much of the Tour de France as you like, but that won't make your first attempts on a bike for yourself any less painful!

So while it's not actually useful, that's not a bad thing: it teaches you something, even if you don't realize it at the time - and that means that the next, more complex task is easier for you to work on - until you get to apps which are genuinely useful!

So be proud of what you have done - even if nobody will ever use it in anger! :D
 
Share this answer
 
Comments
CPallini 12-Jul-22 2:03am    
5.
bob_smith_0101 8-Sep-22 23:44pm    
@OriginalGriff
I want to thank you sooo much for your words of encouragement. While I do not need to prove anything to anyone (the roasters), I have a graduate level education and it's when someone takes the time to explain things like I am 5 (love the infosec oddballs of Twitter)...that I am proud I ask questions.

I am VERY good at business, but this forum is not about business is it? Neither would I roast someone for asking questions about business. I would help them.

I realise I am being redundant right now, but thank you again for your post.
Do you have any recommendations of what to study for C++ in a somewhat proper manner?
** If you would please^10000 explain the steps like I am 5, I would appreciate this.
OriginalGriff 9-Sep-22 0:38am    
No, this isn't a "business site" - that needs other skills because if nothing else the legal rules are different in many countries. FOr example, in Germany you need to register a business, set up to pay taxes on the business, and get appropriate insurance before you start trading. In the UK, you can just open a bank account (and probably a web site), and start trading - registering for VAT when you hit (or expect to hit) the threshold. Some US states need a licence, some don't - but the federal government does!
We aren't set up for that; we concentrate on development only (though there is a Running a Business Discussion Board[^] forum, it's also geared towards dev, and isn't exactly busy! :laugh:

C++ is within our purview though - and it's been a long time since I looked for "learn C++" resources (think 40 years) so whatever recommendations I could give you would be way out of date; the language has changed enormously in that time!

Start by looking for a book: Addison Wesley are normally good, as are Wrox and MS Press. But be aware that it's not just the language you need to learn, that's relatively simple - the framework that you use to interact with the user is much, much more complex these days!

If you are just starting to learn development, I wouldn't personally recommend C++, but would instead go for C# - it's a less complicated, more modern language that is tightly bound into the .NET framework and tries very hard to make the developer's life easier. That's just an opinion though - if you're comfortable learning C++ then you go for it!

Good luck - and remember to enjoy yourself learning.
bob_smith_0101 12-Sep-22 22:47pm    
@OriginalGriff Very much appreciate the guidance! Thank you.
OriginalGriff 13-Sep-22 1:06am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900