Awkward question about writing longer programs.

I've been working on a text based RPG for a couple of weeks now, even though this exact version likely won't be finished. I started with a simple menu, then I've basically went into mini projects by completing each individual segment - within the same main.cpp. Each segment is way more complex than what your typical text RPG would offer because I don't see the point in making "1 Attack! 2 Heal! - you missed Ogre!", but because of this my code is kinda.. long and in chunks.. or something. It's like I've been developing miniature engines for different things, but as I go along, in the midst of my code.

Currently my program is ~700 lines long and probably has too many ifstatements, but it works really well with no bugs and looks (runtime) really great. The point of this thread, though, is to ask if this is an alright approach to creating a program, or if I should stop doing it now before I form bad habits. Since I'm relatively new to programming, I'm not sure how big 700 lines of code even is. That could be nothing, I don't know. But yeah, is it okay to go into side-projects within a main project, even if it means what you've programmed isn't all that portable to future projects?

Thanks.
Split your code in to functions. I can't remember the last time I had code over 100 lines, because of functions.

And always remember; "If you need to use the same code more than once, create a function"
Each menu option has its own function, but then for example in character creation, every stage is inside the function. A lot of the lines of code are object arrays, listing skills, character stats and so on.
Create the class'/structs within main and then pass them to other functions by reference.

I do this all the time. Create in main, pass by reference to a 'load' function, i.e. file. Then, the class within main reflects the load functions data. This can then be passed, again by reference( or other if need be ) to other functions.
Topic archived. No new replies allowed.