• Recent Tutorials

  • Application Planning & Design - The quick 101

    Now, after some delays and internet dropouts, this is finally in the correct section - enjoy

    Now, roughly a week ago I wrote this: http://www.pascalgamedevelopment.com...planning-stage and I got roughly a tonne and a half of feedback so I'll now write up a quick sequel based on feedback and for completions' sake.

    Thats one of the reasons WHY you'll want to be doing some planning. Here HOW.

    I am myself, a pen and paper person. So I'd grab a notebook, and start off with a list, in order, of what the program to do - it might look like this at first:

    Code:
    Initialization
    Main Loop -
       Get user input & events
       Work out what the input/event changes (if any)
          Commit those changes if needed AKA. Process data, input, gravity in a game or whatever
       Draw those changes
       Wait for the next cycle
    Deconstruction / closing the program / finalization
    And yes, all the experienced coders reading that will say I have just roughly illustrated how 99% of applications work - bar the only updating stuff if things change since I have been known to be too lazy to implement that. However, after a few minutes it might develop into something more like this as details are added, expanded and the picture comes into focus from the much more generalized picture we started with:

    Code:
    Initialize the libraries (if any)
    Load a config file to set initial values
    Get a window up and running, prepare objects and data types for the application
    Main Loop -
       Scan for events
       Check for window manager events
       Check for Input
       Call darw procedure relevant to current program mode (map, cutscene in a game, menu or dialog box of editor...)
       Update that with a sdl_flipcanvas or something similar
       Work out how many cycles that took and take that out of wait loop to keep a more constant FPS count
    Save any config changes
    Free up memory
    Halt
    Comments 11 Comments
    1. LP's Avatar
      LP -
      Can you please modify my quote in the article to something less cluttered like this:

      Depending on the project type, there are different Software Development Philosophies. If project is done in smaller teams, one of Agile Development techniques can be used. Some common architectural solutions are described as Design Patterns. There is also a book with the same name.

      There are several code refactoring techniques that should be used to improve the overall quality of the code. In this topic, take a look at Quality Attributes and Non-functional Attributes that should be taken into account when developing the project.
    1. paul_nicholls's Avatar
      paul_nicholls -
      Hey Ben, that attachment didn't work in your "What goes where and how?" installment of this article so I can't see the image...
    1. code_glitch's Avatar
      code_glitch -
      @Lifepower: Sure thing
      @Paul: Might be from when I had to transfer it into the right section, I'll see what I can do.
    1. SilverWarior's Avatar
      SilverWarior -
      If you think that you examples of Application planning with the help of paper and pen will convince other in using similar methods I'm afraid you are mistaken. Why? Most pepole who ever created any computer game or have strong logical sence would come up with idea of that complexity in a few minutes and thus won't even bother writing it down.
      But when doing real planning the rough plan would look like something like this:

      1. Check if the game is already running (using mutex or similar method). If it is running notify user about that with a message and later close second one or make sure that the already running game is shown and then close second one. If the game isn't already running continue to step two.
      2. Load the esential libraries needed for graphic interface and sound system. Also if your game has support for joysticks, gamepads, and some other hardware load neccesary libraries for those to.
      3. Load settings
      4. Create a window and initialize a graphical engine.
      5. Initialize sound system.
      6. Initialize control system.
      6.1. Show main menu. For this use a gamesteate property.
      6.1.1. Alow user to browse trough other submenues of the main menu (ingame options, credits, etc.)
      6.1.2. If a user selects a new game start game initialization proces. Show a loading screen here.
      6.1.2.1. Initialize necessary classes and records
      6.1.2.2. Load predesigned map or create a random map
      6.1.2.3. Create necessary ingame objects (characters, buildings, etc.)
      6.1.2.4. Hide the loading screen and draw initial state of the game.
      6.1.2.5. Start the game loop
      6.1.2.5.1. Check fo player input.
      6.1.2.5.2. Proces game changes, based on player input and other variables and game procedures. This proces can be divided into multiple subsections based on the game design.
      6.1.2.5.3. Draw game graphics
      6.1.2.5.4. Play necessary game sounds and music
      6.1.2.5.5. Fire some special effects (force feedback etc.)
      6.1.2.6. When the loop ends free used ingame objects
      6.1.2.7. Unload maps
      6.1.2.8. Free unneded clases and records
      6.1.2.9. Show main menu again. And continue with main menu code.
      6.1.3. If player selects load saved game, then do similar as in new game but instead load initial game data from savegame file
      6.1.4. If player choses Exit start with game closure procedure
      6.1.4.1. Unload input controlls
      6.1.4.2. Unload sound engine
      6.1.4.3. Unload graphical engine
      6.1.4.4. Free rest of the application's resources
      6.1.4.5. Terminate.
    1. code_glitch's Avatar
      code_glitch -
      @SilverWarrior: Thats exactly the problem, I average around 94% on exam scores involving logic as a fundamental (chemistry, physics, biology, maths etc) - I NEVER used to think planning everything like that was needed - I just HAD the idea.

      BUT, consider the number of individual statements in the following:
      Code:
      1. Setup the appropriate sound & video environment for the OS and its specific setup & HW
      2. Load your config file and ensure it all works
      3. Process input, take action and etc
      You get the idea
      Even where you say
      Code:
      6.1.4.3. Unload graphical engine
      You could still be looking at a few dozen lines. Having that plan in my head as well as my code is just a tad unnecessary. Brushing your teeth is not hard, neither is remembering an essay, combine the two and its quite hard - and try it while you drive: now thats a proper challenge for us people with 4 limbs. Kids, please don't try that either at home or on the roads
    1. SilverWarior's Avatar
      SilverWarior -
      That is the most comon problem in newbe game or appliction developers. They have a great general idea but don't have the necessary knowledge about what all needs to be done to make that general idea a reality.
      I myself am full of general ideas and have ended with many unfinished projects, becouse I never figured out what all is needed to make that idea a reality.
      Now I'm slowly beggining to understan all of this. And since I'm a pasionate gamer I learned alot just by observing how games works. While most pepoles see games just as bunch of graphics and sounds I look at them compleetly differently. I don't se graphics I see sprites or 3D objects, I know that there are complex mechanich behind every game, etc.
      Actually I never looked at games or at other applications as most of the pepole does. I always knew in a whay that they are formed from various parts (buttons, functions, etc.). That's why I started programing, becouse I wanted to learn exacly what is going on behind the scenes.
    1. LP's Avatar
      LP -
      Quote Originally Posted by SilverWarior View Post
      I myself am full of general ideas and have ended with many unfinished projects, becouse I never figured out what all is needed to make that idea a reality.
      Actually, this is common especially in the most ambitious projects. Sometimes even trivial projects with minimal requirements end up being very large and time consuming, not because of lack of planning but simply because of time underestimation being very common among even the most advanced developers and engineers.

      This subject is more of philosophical nature and in this context, there is a work Unskilled and Unaware of It. The idea is that the more you know about some subject, the more accurately you can estimate your own knowledge of it and vice-versa: if you know little about some task, you'll most likely overestimate your own skills on this task. In other words, the more you learn about something, the more you realize that you actually know very little about it.

      There has been a related work (unfortunately, I've lost this reference) that mathematically proved that if you consider yourself above the average in certain knowledge, probabilistically it is more likely you *are* the average.

      There was another very interesting research, although I've lost this reference as well. The idea was that you need to dedicate fully at least 10 years into one specific area to become master of it (btw, if someone has reference to this paper, *please* let me know).

      To resume, keep working on projects, even if they are unfinished, learning how they are done and never stop at this task; in ten years you'll most likely succeed.

      There's one quote related to this phenomena of having many unfinished projects. When they asked Edison, what it felt like to fail 1,000 times to invent the bulb, he replied that he did not fail 1,000 times, rather than he found 1,000 ways how it should not be made (or in other contexts, that the development of light bulb involved 1,000 small steps).
    1. code_glitch's Avatar
      code_glitch -
      @LifePower: If you ever get the chance, perhaps take a look at a book called 'Dreaming in Code' or http://en.wikipedia.org/wiki/Dreaming_in_Code for a quick rundown. Quite a good read, follows the development of the Chandler program (time management software). It covers quite a lot of the morals of planning and time management on software development.
    1. LP's Avatar
      LP -
      Quote Originally Posted by code_glitch View Post
      @LifePower: If you ever get the chance, perhaps take a look at a book called 'Dreaming in Code' or http://en.wikipedia.org/wiki/Dreaming_in_Code for a quick rundown. Quite a good read, follows the development of the Chandler program (time management software). It covers quite a lot of the morals of planning and time management on software development.
      This definitely seems like an interesting book, thanks!
    1. LP's Avatar
      LP -
      Just wanted to add something to this discussion, there are some concepts that you may find interesting. Contrary to Design Patterns that I have mentioned earlier, check Anti-patterns. Also, for indications of a problem in the software check for Code smell.

      Other pages that you might find interesting are Programming rules of thumb and Programming principles.
    1. code_glitch's Avatar
      code_glitch -
      Looking quite good, and for those who want to know about my next article, I am working on it - and its a tantilising one! All I will say for now is that its targeting a very popular linux and how to get your libs running on said platform . You'll have to wait and see what its all about , development and writing is on the slow right now courtesy of mock week and me having to sit 6 hours + of exams every day