How do I know what code to put into creating certain programs?

Started by
6 comments, last by alnite 11 years, 7 months ago
Hey, I'm currently studying DirectX, I did learn some of the basics of C++ before this and a bit about DirectX.

Sometimes I'm not really too sure what the best method is to learning, besides actually programming. The way I do it is I read from the books, take the examples from the CD's, look through it and actually understand what it's doing, write out a very simple step by step on how to create this, I try not to mention any names of function's, structures, datatypes, etc. So when I get to a certain step I have to search for the information myself and I think it helps me remember the functions and such.

The only problem I am having with this is knowing what I need to put into programs. Say if I have read through an example program, I know what it's doing, what it accomplishes in the end, but then I want to write it from scratch, I just have no idea what steps I need to take, the order of the code. My mind just goes blank.


I've been taking my studying seriously for 2 years I would say, so it's not a very long time. I'm learning from books and have a huge list of books to work through on C++, DirectX, Computer Science, etc.

I just want to know if I am doing something wrong for me to just not know what needs to go into a program. I will give you an example, I'm currently working through an example program that takes the directional arrows on the keyboard as input and displays an image corresponding to that arrow. I'm working with Direct3D Input at the moment, so it's all based on keyboard, mice and gamepad input, but I'm starting the very first and basic program. I know how to do the basic Windows programming, like displaying windows, etc.
Advertisement
The more you program, the more you are able to predict what kind of code you need to create something and how to organize everything. You should start small, creating programs you are able to make and then aim to more difficult ones. You should try to break your programs in smaller incremental steps you are able to make.
Do it the way we all did it in the beginning: just start hacking code together. If you realize that your current architecture doesn't do the job, then think about a better one and rewrite the whole thing. Repeat this until you finished the project.
After a while you will get a feeling for it so you don't have to rewrite every project ten times, so just keep practicing.
Would you recommend to just keep getting as many books as possible and maybe get different programmers perspectives? I know programming is all down to practice and doing it yourself, but sometimes I find certain books go into to much detail and don't just get to the point whereas others don't explain something enough. The internet can also be a pain at times to find information if you don't put in the right combination of words lol.

I mainly want to program video games, I have an idea in my head already and I think with enough practice I might be able to get something basic up and running without looking at examples and such.
Just practice. You don't need to spend a ton of money on books. You just have to accept that pretty much everything you write for the next couple years is going to be utter crap, and use that time to keep practicing. Eventually you'll realize you're spending more time coding and less time hitting the web looking for answers. You'll always have to do plenty of that, though, as there is always something else to learn. You'll never get to the point where you know it all, and if you think have gotten there, you're wrong.
Yeah you need to get more practice. Books are good, but at one point you have to start doing some actual programming. Pick a simple task, and code it yourself without the help of books.
Also, if your goal is to make games, DirectX is definitely not the way to go. It takes way too long to get anything done, and it will just confuse a beginner. Grab SFML for 2D games.
Sometimes I'm not really too sure what the best method is to learning, besides actually programming.[/quote]Since the best method of learning is programming, why not program?

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

This is the dilemma in learning programming. Unfortunately, you just have to code away. Start small. Even printing a series of characters from a - z, or every other character, will get you somewhere.

This topic is closed to new replies.

Advertisement