May 12, 2008

Write Code: Mind Wide Open

I was talking with a friend of mine about some programming stuff. He has got a school assignment to develop a simple game in C#. Well, the first thing that students usually start with, is that they buy a book about C#. They read the book, and when the last page is over, they start with the development of their fabulous application. Now they know a lot of C# commands, structures, objects, we could maybe say that some of them are now even C# gurus (at least they know a bunch of commands). Now there is a problem. Many times I face people that even tho' they know HOW to write code, they do not know WHAT to write!

Many times they are missing the essential imagination of the application's building blocks, relations, dependencies, application flow, etc. My suggestion for this case is to grab a pencil and paper, forget everything you know about C#, open your mind and start drawing and designing your application.

You can start with the user interface. If you know that the game will be the minesweeper, draw a basic window, control objects, the minefield, etc. Then start with the application analysis. Within the analysis you have to understand what must your application exactly do. After finishing the analysis part, you should have an activity diagram, that will clearly display what actions may happen in you application and how to handle them. This part was the platform independent analysis. For this part it is not necessary to know anything about C#. As you will go deeper and deeper, your drawing will became more and more platform dependent, and for this game it should end up at the .net and C# platform.

So continue with deeper analysis and create the architecture of you application. Start thinking about building blocks of you application - basic classes, interfaces, methods, their relations, dependencies, etc. Draw everything to your paper and take notes. Supporting applications like MindManager or FreeMind may help you to collect your ideas and don't forget anything.

After having completed all these steps, remember all the things that you learned about programming in C#, take a look at your drawings and notes, and now you should know HOW and WHAT to write to your source code!

image

A successful analysis at the beginning is about complete understanding of the application and it ensures that at the end of your application development you should not end up in such a situation as it is displayed on this ^ picture :-)

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I agree with you, sometimes more important than know some programing language perfectly is to have a good idea how to bulid a game/project. For example there are many books about C#, C++, but only few of them are good. I think the best are those where you build project as you go through chapters, when you learn something new you can then apply it on that project. At the end you have robust application which containst all the "modules". In my opinion most of us are not looking for finished results, we are looking for modular guide which can help us realize our visions.

    ReplyDelete