Jump to content

  • Log In with Google      Sign In   
  • Create Account

I need help with structuring, really bad!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 superman3275   Crossbones+   -  Reputation: 2011

Like
0Likes
Like

Posted 30 September 2012 - 09:17 PM

I've recently ran into a LOT of problems with how I structure my code. I just don't have a very good idea about object oriented properties/inheritance/encapsulation. If anyone can recommend some books, free pdf's, pod-casts video tutorials, anything about structuring object oriented systems(Especially specifically involving game development). I would like to do a lot of reading on this(2+ hours a day) so I can become a better programming. All recommendations are helpful Posted Image

I'm a game programmer and computer science ninja ph34r.png!

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

 

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here smile.png!


Sponsor:

#2 Bacterius   Crossbones+   -  Reputation: 8827

Like
8Likes
Like

Posted 30 September 2012 - 09:48 PM

I have no book recommendations, but may I suggest another approach: code, code, and code again. Eventually you will see design patterns appear and you'll learn to work with them. If something doesn't make sense, try and change it, even if it means a rewrite. I never found reading about programming a particularly effective way to learn, to me nothing beats practical experience. This is a subjective opinion, YMMV *casts downvote shield*

One thing about OOP is that it may be approached with different points of view depending on what you try to achieve (or sometimes you might think of it differently to someone else just because of the way you think). That's why there are so many "patterns" out there, each with their own strengths and weaknesses (and are sometimes equivalent if you are consistent, and so are up to taste). So don't get too hung up on one particular way of doing things, use whatever works for your project and what you find attractive.

What problems did you run into? Things such as separating logic and graphics, that kind of stuff? Or how to split code files sensibly to maximize reusability? Or how to define proper interfaces for your classes? ...

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#3 superman3275   Crossbones+   -  Reputation: 2011

Like
0Likes
Like

Posted 30 September 2012 - 10:01 PM

Figuring out what should be objects, what they should inherit from, Especially Reusable code, etc. I more or less need something to help me understand how I should apply this to video game programming. Also, I'm refining my list:
•Books about linear algebra
•Books about C++
•Books about graphics programming
•Books about object oriented design
•Books about writing cleaner code.
Please Give me everything you got, especially about linear algebra :)

I'm a game programmer and computer science ninja ph34r.png!

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

 

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here smile.png!


#4 jbadams   Senior Staff   -  Reputation: 18556

Like
4Likes
Like

Posted 30 September 2012 - 10:32 PM

Books about linear algebra

Try Khan Academy.

Books about C++

Check out these recommendations.

Books about writing cleaner code

Code Complete is excellent and I'd highly recommend it to anyone and everyone after getting a solid foundation in the basics of your chosen programming language. This is a more advanced book, and although it's very clear and well written many of the suggestions and examples simply won't make sense without a certain base level of knowledge.

Books about object oriented design

Try these articles on OO design principles. Again, a lot of this may not make a lot of sense until you're able to actually put it into practice, and beginners often have trouble understanding some of the potential problems or pitfalls of poor design until they have personally experienced the problems that can arise.


You didn't have it on your list, but there may also be some value in reading about "design patterns".


However, I agree with the above suggestion from Bacterius -- a good book or reference material is great -- especially to introduce you to completely new or different ideas -- but to really get a good handle on programming you need practice, practice and more practice. There is no replacement for real-world experience, and they say that to really master a craft you need 10,000 hours of experience. I think there's real value (for most people -- different people learn differently) in reading good books, but you absolutely need to keep writing code as well.


If you need more problems to practice your programming you could try some exercises from Project Euler or give Code Kata a try, or simply continue to pick progressively more complicated games or other programs to attempt. I noticed you also spent quite a bit of time and effort improving, cleaning up and adding polish to your first game -- continue to do that, as it's a great learning experience and also establishes a good work-ethic of sticking with your software for the boring "finishing up" tasks once all of the interesting problems have already been solved.


Program structure in particular can be difficult for a beginner to come to grips with, and you really need to learn it through trial-and-error and lots of (potentially messy) experience. Just keep writing software in any way you're able to get it to work, and you'll gradually begin to notice patterns of what works well and what causes problems and needs to be avoided.

Hope that helps! Posted Image

#5 thok   Members   -  Reputation: 692

Like
1Likes
Like

Posted 01 October 2012 - 08:08 AM

Figuring out what should be objects, what they should inherit from, Especially Reusable code, etc.


Code reusability != inheritance.

Nor does it really necessarily have anything to do with object oriented programming. There are design techniques you can apply (composition, inheritance, etc.) to achieve code reuse, but you can also get a lot of code reuse if you write in a somewhat functional style. Another way to put it: Try to move as much as code as you can into pure functions/methods. For example, you could write your physics, general math, and collision code as a collection of simple functions, then piece them together however you need. You don't need to worry about shared state as much and it makes your code easier to test. I would also argue that it makes managing the complexity (of games) much easier.

Neither OO nor functional programming are silver bullets, in my opinion. In my (limited) experience with writing game code, it seems that a balance between the two approaches is very nice. It depends on what type of component you're trying to build--"best tool for the job" and all that. =)

For reference, there's a nice blog post about functional programming written by John Carmack: http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/

#6 Radikalizm   Crossbones+   -  Reputation: 2881

Like
0Likes
Like

Posted 01 October 2012 - 08:24 AM


Figuring out what should be objects, what they should inherit from, Especially Reusable code, etc.


Code reusability != inheritance.

Nor does it really necessarily have anything to do with object oriented programming. There are design techniques you can apply (composition, inheritance, etc.) to achieve code reuse, but you can also get a lot of code reuse if you write in a somewhat functional style. Another way to put it: Try to move as much as code as you can into pure functions/methods. For example, you could write your physics, general math, and collision code as a collection of simple functions, then piece them together however you need. You don't need to worry about shared state as much and it makes your code easier to test. I would also argue that it makes managing the complexity (of games) much easier.

Neither OO nor functional programming are silver bullets, in my opinion. In my (limited) experience with writing game code, it seems that a balance between the two approaches is very nice. It depends on what type of component you're trying to build--"best tool for the job" and all that. =)

For reference, there's a nice blog post about functional programming written by John Carmack: http://www.altdevblo...ogramming-in-c/


I use the same approach for most of my game code, trying to strike a balance between OOP, DOP and functional programming based on where each paradigm makes sense.
My math library which I've developed over the years is written using a completely functional approach for example as this provides a more natural approach to 'doing math' with a very clean and re-usable structure, while systems which have to process a lot of data will use a data-oriented approach, just to give an example.

I gets all your texture budgets!


#7 EpicWally   Members   -  Reputation: 282

Like
0Likes
Like

Posted 01 October 2012 - 11:28 AM

When I first started programing (not too long ago) I found myself in a similar boat. The syntax of the language made sense, but I couldn't wrap my head around what code to write where, when to use composition, when to use an interface, when to use inheritance, how to compartmentalize, etc. I didn't even know where to begin to start learning through trial and error. I found "Head First Design Patterns at Barnes and Noble, and it did a very good job of explaining design patterns, along with good OOP principles and concepts. It is writen with Java examples for code, but the patterns and concepts it goes into are univerally applicable. While everyone's learning styles are different, I found this book to be exceptionally helpful.

#8 UltimaX   Members   -  Reputation: 467

Like
1Likes
Like

Posted 01 October 2012 - 01:48 PM

•Books about writing cleaner code.


Take a look at this one: http://www.amazon.co...cm_cr_pr_sims_t

[EDIT]
I found the book free online and want to assume this is a legit site? (I just Googled the book name and it was the second link). If not I am deeply sorry and appologize. You should buy the book either way as it's a great read.
http://www.e-reading.org.ua/bookreader.php/134601/Clean_Code_-_A_Handbook_of_Agile_Software_Craftsmanship.pdf

Edited by UltimaX, 01 October 2012 - 01:53 PM.


#9 mholmes   Members   -  Reputation: 189

Like
0Likes
Like

Posted 01 October 2012 - 04:25 PM

In VB we have #region "Name Here" #End Region to help organize the code. I recomend you write it all down on paper and organize it there first. Once you start to code sometimes it becomes a giant mess unless you plan it out on paper first. Hope that helps.

#10 render donkey   Members   -  Reputation: 138

Like
0Likes
Like

Posted 02 October 2012 - 03:19 AM

I can help. but as exchange. you must help me with my english.
if you agree. contact me.
my email boyue@rocketmail.com

#11 Wilhelm van Huyssteen   Members   -  Reputation: 974

Like
0Likes
Like

Posted 02 October 2012 - 05:28 AM

Like the first reply stated. Just keep coding and you will see good patterns emerge.

Write the dam application and then you will spot the parts that you can generalize and move up the class hierarchy for reuse later. Don't even create an hierarchy until you find clear examples of duplication in your code.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS