 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Szymon Rozga Guest
|
Posted: Thu Aug 11, 2005 5:42 pm Post subject: Small projects to strengthen my C++ |
|
|
I've been kinda playing around with some C++ this last year. I was in a
game design class in which we programmed a game in C++ and a simple
gaming framework called GameX. Needless to say, the huge amount of code
that had to be written and the small amount of time we had for it, led
to some pretty ugly code and one or two nasty memory leaks that took a
while to track down. But all in all, I know I could learn more.
I was thinking of having some concrete list of small projects (doable
in a day or two), that would let me gain more experience with C++ and
think better in it. Since I have a bit of free time coming up, I was
wondering if the people here have examples of some problems that I
could solve in C++ that will let me gain more experience with the
language.
Since I've been taking an algorithms class this summer, I was thinking
of implementing a bunch of the algorithms (all kinds of greedy, divide
and conquer, and dynamic programming ones). Maybe make a library out of
it for myself. Also, I had been reading 'Design Patterns' and was
thinking of writing examples of many of the patterns for myself.
Any other recommendations?
To give you an idea of my level of experience, I'm a junior in college,
have used Java for some classes, C# for a GUI and mission execution
engine for my AUV team I am part of and lots of Ruby for all kinds of
scripts and modules at my part time job. So I'd say I'm confident in my
OO design and understand those concepts. (And of course I have
rudimentary knowledge of a lot more things, but these are my strengths;
I hope to make C++ one of them too)
-Szymon Rozga
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Carlos Moreno Guest
|
Posted: Thu Aug 11, 2005 8:59 pm Post subject: Re: Small projects to strengthen my C++ |
|
|
Szymon Rozga wrote:
| Quote: | I've been kinda playing around with some C++ this last year. I was in a
game design class in which we programmed a game in C++ and a simple
gaming framework called GameX. Needless to say, the huge amount of code
that had to be written and the small amount of time we had for it, led
to some pretty ugly code and one or two nasty memory leaks that took a
while to track down. But all in all, I know I could learn more.
I was thinking of having some concrete list of small projects (doable
in a day or two), that would let me gain more experience with C++ and
think better in it. Since I have a bit of free time coming up, I was
wondering if the people here have examples of some problems that I
could solve in C++ that will let me gain more experience with the
language.
Since I've been taking an algorithms class this summer, I was thinking
of implementing a bunch of the algorithms (all kinds of greedy, divide
and conquer, and dynamic programming ones). Maybe make a library out of
it for myself. Also, I had been reading 'Design Patterns' and was
thinking of writing examples of many of the patterns for myself.
Any other recommendations?
|
My recommendation is that perhaps 1 or 2 days projects are not really
adequate to strenghten your C++ skills. Perhaps you should look at
few-weeks-long projects, so that you do have the opportunity to play
with more advanced/complex issues, as well as a more careful design.
Given that you're into games, why not programming your own versions
of things like Solitaire, Freecell, or Minesweeper, or Tetris, etc.?
You could go to http://games.yahoo.com, pick any of those games, and
program it yourself in C++ -- with or without the nice graphics). I
would also recommend that you drop by http://www.wxwidgets.com for the
GUI parts of your projects.
Perhaps a bit of reading would also help? Things like "Effective C++"
or "Exceptional C++" could be extremely helpful for you -- they don't
teach the C++ language; instead, they assume a target audience that
is already familiar with the language, and they teach you how to use
it the right way (DO's and DONT's kind of thing). They teach you
tricks, techniques, pitfalls, etc. Very interesting reading at any
rate.
HTH,
Carlos
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
kevin.hall@motioneng.com Guest
|
Posted: Fri Aug 12, 2005 9:08 am Post subject: Re: Small projects to strengthen my C++ |
|
|
Here are some pretty common needs for real-world applications. There
is no standard solution (well, maybe the Boost library, but that's
sometimes more complex than what people need). But doing the following
will help you down the road develop future apps more quickly:
(1) A flexible argument parsing class / library.
(2) A configuration file parser / loader / saver
(3) A stream class that will pass output to multiple other streams (for
example, a log file ofstream and std::cout).
(4) Create some flexible template versions of design patterns: Memento
would be a good one to start with.
And then of course write test programs for each of these.
If you really want to better your skills, also write some API
documentation and a short article on what you did. These last skills
will be important when you get out into the corporate world.
Lastly, if you have time, post your code and articles in the newsgroup
and on some other developer site like www.codeguru.com or
www.codeproject.com. Not only will you get constructive criticism, but
you'll also be helping others, and building relationships with other
developers. If you become well known on the newsgroups and forums,
people will be more eager to help you. And should the need ever arise,
these relationships may possibly even help you find work.
Well, good luck in your endeavors!
- Kevin
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
tony_in_da_uk@yahoo.co.uk Guest
|
Posted: Fri Aug 12, 2005 8:15 pm Post subject: Re: Small projects to strengthen my C++ |
|
|
Sounds like a good idea to concentrate on something unique to C++, like
templates.
I suggest you implement what I - for lack of knowledge of terminology
chosen by people who've doubtless derived such objects in the past -
call a "type map". The properties are simple:
- you instantiate a template with a typelist (I used Loki),
- you can assign a value of any type listed
- you can retrieve the value using the cast operator
All the values are to be stored distinctly (i.e. it's a struct not a
union; not a variant).
E.g. Type_Map<TYPELIST(int, std::string, double)> type_map;
type_map = 5;
type_map = std::string("hello");
type_map = 3.14;
then
cout << (int)type_map << (std::string)type_map <<
(double)type_map << endl;
// yes - static_cast<>() it all if you can be bothered, but it
won't compile if the
// wrong type is provided...
should output "5hello3.14n".
What's the point? I found it a convenient basis for an extensible
error handling subsystem: systems using my error handling simply
defined a typemap that classified their error in the amount of detail
they wanted (e.g. anywhere from simply { file, line } to { subsystem
name, error classification, reason, recommended handling actions, retry
intervals, max retry count etc }). I went away and wrote my system
independently of such decisions. Users created one or more objects of
the typemap, and used them like XWindows uses graphics contexts (i.e.
they allow the developer to use the same error context object in
related error situations, avoiding continually passing information at
each point of error reporting (which for larger systems with
non-trivial error reporting ambitions, is not only inefficient, but
painful and verbose enough to code that developers just can't be
bothered)).
Like variants, but without the run-time overheads, this concept can be
quite empowering in developing reusable code.
If I think of something else, will post again.
Cheers - Tony
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
benben Guest
|
Posted: Sat Aug 13, 2005 1:16 am Post subject: Re: Small projects to strengthen my C++ |
|
|
Have you tried doing the exercises in The C++ Programming Language (by
Stroustrup)? Some of them are quite much a one-or-two-day projects. The nice
thing is, you can always go to the chapter that interests you and those
exercieses are quite topic-specific yet open ended.
Ben
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Szymon Rozga Guest
|
Posted: Sat Aug 13, 2005 1:39 am Post subject: Re: Small projects to strengthen my C++ |
|
|
All of these sound great. Thanks a lot guys.
Kevin:
What do you mean by "A flexible argument parsing class / library"?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
tony_in_da_uk@yahoo.co.uk Guest
|
Posted: Mon Aug 15, 2005 12:52 pm Post subject: Re: Small projects to strengthen my C++ |
|
|
Mentioned something in my first post which in itself is a good
exercise: writing variants. For example, the following three variant
implementations make reasonable exercises:
1) A discriminated union. The variant class is templated on a
typelist, and you can store any of those types and retrieve it again
via "bool get(Type* p_buffer) const" or similar.
2) A RTTI-based implementation, with a non-template variant class, and
a templated constructor that stores typeid() results. A get function
like the one above can be provided....
3) A virtual-dispatch based mechanism, with a non-templated variant,
and a templated constructor that instantiates a base class (a template
parameter to the variant) that captures the set of operations expected
of the stored types, storing the pointer. The variant object can then
be used to invoke behaviours. Start with a simple set of operations,
e.g. streaming + arithmetic operations. E.g.
template <typename T>
class Interface : public Abstract_Interface;
Variant<Interface> my_variant = my_class;
cout << my_variant << endl;
Cheers, Tony
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
kevin.hall@motioneng.com Guest
|
Posted: Mon Aug 15, 2005 7:54 pm Post subject: Re: Small projects to strengthen my C++ |
|
|
I was referring to command-line parsing (something to parse main's argc
and argv). Sorry for the confusion.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
tony_in_da_uk@yahoo.co.uk Guest
|
Posted: Tue Aug 16, 2005 11:34 pm Post subject: Re: Small projects to strengthen my C++ |
|
|
Another suggestion: try the Guru of the Week questions (search Google)
- they won't take you a day or two, but they're a good investment of
time. - Tony
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|