tags:

views:

249

answers:

11

I have been learning c++ but my problem is i don't know what to do next. I know how to use pointers, classes etc... in C++ but i haven't written a real program, only assigments from the university(calculating arithmetic means, mean deviation etc)...

What should i do?

Thank you

+5  A: 

I know how to use pointers, classes etc... in C++ but i haven't written a real program,

This can't be true! It's just impossible.

You should write a couple of "real-world" apps before you proceed to design patterns and feel your skill considerable.

As a real app example, you could write a multithreaded network chat client/server. From my experience that's the application where you need to implement several valuable programming concepts in quite a compact code.

Pavel Shved
I'd start with something that doesn't require external libraries. If you're still trying to get a solid grip on C++, the last thing you want is to start messing around with threading libraries.
jalf
Instead, I would advise to start learning the culture of delegating functionality to libraries and of using them from the very beginning!
Pavel Shved
A: 

Learn to design applications. Learn at least 1 modeling language and practice drawing diagrams. Designing is the first step when developing any real application.

Andrew Keith
You should first write a load of *real* programs before you start learning a modelling language or gaining basic "design knowledge".
Pavel Shved
I object to drawing diagrams before writing any real applications, it only leads to over-designed programs.
HeavyWave
Nonsense .. You should learn to design whilst learning programming. Its terrible advice to tell students to skip learning design especially with OOP languages. Even simple class diagrams do wonders in teaching inheritance.Designing is more than just drawing diagrams. Even if you dont like drawing diagrams, designing is planning ahead. If you dont fail to plan, you plan to fail.
Andrew Keith
Nonsense is when a question appears on SO: "Hi, I have a Factory class within a singleton. Why does the code not work? (an example of array out-of-bounds access)"
Pavel Shved
SO often gets people which have poor communication skills which cannot explain their problems properly. I would still encourage such people to learn a new skill because it helps them improve.
Andrew Keith
@Andrew: Still, it's hard to apply something correctly when you haven't understood *why you need it*. Otherwise, you end up with developers asking for Rational Rose when they should write a fizzbuzz test. He's probably better off studying code guidelines (that include a rationale).
peterchen
+1  A: 

Sounds like you've been learning mainly C so far (procedural programming), and not C++. I suggest to advance with the C++ now, specifically the object-oriented-programming part. Learn the OOP theory and concepts, and practice it - get some experience in designing and coding classes. You can just start with the free C++ tutorials on the web, there are lots of them - they contain a lot of programming assignments.

After it, progress to the Design Patterns, read the excellent C++ FAQ Lite, and follow the C++ tagged questions on StackOverflow.

Also, if you want real programming tasks, you can try to find something appropriate at the RentACoder site.

Igor Oks
"I know how to use pointers, *classes* etc... in C++"
BipedalShark
by functional programming components of C++, you probably meant procedural, right?
Marek
@Bi,@Marek: Updated, thanks.
Igor Oks
"Sounds like you've been learning mainly C so far (procedural programming), and not C++" funny yet sadly very real: my first ever C++ course only mentioned classes and a hint of the OO concept in the very last chapter. And I know there are more courses, even books, doing it that way. Imo this stuff should come very early, else you're just learning how to create a program in C with the source in one file ;P
stijn
sbi
@sbi: Absolutely. But I was meaning procedural :)
Igor Oks
A: 

my practical suggestion:

rewrite some applications using c++ which was formerly wrote in c. once you have both c and c++ versions of code, try comparing execution time or efficiency to each other, and analysis the differences to found out the causes by studying c and c++ in advance.

EffoStaff Effo
EffoStaff Effo
+1  A: 

You can either:

  • Come up with an idea for a small program you think you can make. (usually something you need?)

OR

  • Look for some open-source project, try to read the code and make some changes.

You don't have to write a "gui" program, (though you could, using QT for instance, but the "gui" aspect just adds another layer of complexity).

hasen j
A: 

Since it sounds like you're still in Uni, I'd say hold off on writing 'real world' applications. There will be plenty of time for that in the 'real world.' If it were me, I'd start working on getting more experience with things and developing my coding style. There are plenty of coding challenges out there that can help not only strengthen your programming skills, but also your math and logic skills as well. There are plenty of open source projects out there who need people willing to sift through other people's code. This would give you a lot of experience very quickly and prepare you for the 'real world' where most of the time you spend will be maintaining other people's code.

For me personally, it didn't do much good reading about design patterns or architecture or anything like that in school or even a year or so after I started writing 'real' applications out of work because I had no context in which to place these ideas. It took a couple of years of looking through real applications (including open source apps) before things like architectural and design patterns made sense.

Hooray Im Helping
A: 

I think its just a communication problem. I suspect the OP has written code before, just that he has not written any "real" application which did something useful. He might have just been writing simple snippets of code to solve assignments.– Andrew Keith

You got that right!

Mitsaras
+2  A: 

Write Programs
If you don't have your own ideas, look for "code golf"'s here, for lists of interview programming questions, for quesitons from old programming competitions etc. Try to implement various known algorithms, and verify that they work correctly.

This trains your skills to put ideas into code. If you can't do it in your head, have a piece of paper and a pencil ready.

Read Programs
Read other people's programs and snippets, try to understand what the programs / routines are supposed to do, try to understand the algorithm they are following. If you are enjoy that kind of thing, you can also try to find flaws, which inputs would give undesirable results.

Also, consider why some pieces of code are hard to understand, and others are read easily.

Honestly, it's hard to give you good ressources for that. If you've implemented some standard algorithms, try to find reference implementations and try to understand why they do things differently.

Reading and understanding code - whether it's someone elses or your own rom last year - is one of the toughest exercises in coding, but you can learn a lot from it.

Learn new technology
Learn the OOP parts of C++, learn to use and to create templates. Sooner or later, you also need to find a decent UI framework to work with.

Learn new Concepts
Learn about OOP as an abstract concept, and compare to C++ how it implements that. Read about coding standards and general rules what code is good, what code is bad. I don't particluary like the google coding standards but they added rationales why they make somethign a standard. CS has no absolutes, no universal rules, only tools we hope to apply correctly in the right situation.

Do these four things in parallel, step by step. It takes 10 years to become a good programmer, start now :)

peterchen
A: 

Bjarne Stroustrup's advice :

The best follow-up to this initial course Programming -- Principles and Practice Using C++ is to work on a real project developing code to be used by someone else.[...] in parallel with a real project, read either professional-level general textboox (such as Stroustrup The C++ Programming Language), a more specialized book relating to the needs of your project (such as Qt for GUI, or ACE for distributed programming), or a textbook focussing on a particular aspect of C++ (such as Koenig and Moo, Accelerated C++; Sutter's Exceptional C++; or Gamma et al., Design Patterns).[...] Eventually, you should learn another programming language.

Working on a real project and dealing with the demands of a non-techie audience is a must.

anno
A: 
.. i haven't written a real program, only assigments from the university(calculating arithmetic means, mean deviation etc)...

What should i do?

Well, write a real program then.

A few suggestions:

  • Tetris
  • Calculator with GUI
  • Chat program
  • Facebook/Twitter/.. utility (photo uploader or whatever..)

Pick a project that you find interesting + challenging and go for it. Good luck!

StackedCrooked
A: 

Take an open source C++ package that you might actually use and modify it in some way. Start with simple modifications, then try something more major.

For instance go to this page:

http://keepass.info/download.html

Near the bottom under Other Downloads and Resources get the KeePass 1.16 Source Code. This is software for managing passwords. If you practice good password hygiene then you will never use the same password on more than one site, so you will need a password safe to securely keep track of them all.

Some suggestions on things that you could change. One is to rip out the windowing framework and port it to something else. Linux has GTK vs QT. Windows has darn near everything so try porting it to an older framework like V or FLTK.

http://www.objectcentral.com/objectcentral/vgui/vgui.htm http://www.fltk.org/

If KeePass doesn't use SQLITE, then port it to that. If it does, then port it to Berkeley DB which is still available from Oracle as open source

http://www.oracle.com/technology/products/berkeley-db/index.html

When you do this, look for opportunities to either subclass an existing general class, or to refactor an existing class into a more general parent class, with a specific subclass for the specific GUI or db.

And if you don't like KeePass, then spend some time with Google because there is a lot of C++ opensource out there to choose from.

Michael Dillon