Sunday, December 20, 2009

Code work kicked off!




Today I’ve spent 3 hours coding. I’ve come across a BUNCH of different problems, but most of them I was able to solve after sometime. A lot of these problems were simply syntax or ‘layout’ – I would not be sure how to put some stuff together for it to make sense etc. Part of it are also small pieces of information that are not important until one tries to use them. E.g. I had to change a constructor of Field because it had to be empty for me to be able to put it into the array of Board. It is just a requirement of the language because one excludes the other. This problem and many other I had to look up and the C++ dla każdego book was indispensible here, especially that I was working in the car, without internet.


I was heavily using the tutorial to code the window creating code. A lot of it was pretty much copied, with just slight changes, because this part of the code does not differ from program to program much and it is also quite lengthy, so it takes a lot of time to be able to remember and write it all without reference.


Once I’ve finished the making of the window, I created a function which would display the board in it. It was going step by step – I had to implement the Field function; then create an abstract board as an array of Fields; then write the code which would go through the array and display the fields one by one (I could have made this easier and shorter, but this lengthy approach takes off some load from future – I would have to do it sometime anyways). Only once I had that ready and tested I made the colors alternate making it a real checkers board.


This concept is really important for me right now. I can’t make everything right away at the same time. So being able to separate the process into some steps which are than developed is the way to go. It is quite a challenge, because the different parts of the code are inter-related and intertwined which makes it hard to take only a part  without having to drag the rest with it.


For example, I’ve had to create the Field class to be able to create the board. But my main focus of the moment was to create the board not the fields in their full detail, so I only wrote the most important parts of the Field class that allowed it to function. As I was expanding the program I was adding more and more functionality to Field AS I NEEDED IT.


The process I showed last post is only somewhat correct. The basic idea is correct, but all the steps are really blended together and really only the first one was the only one I did by itself. Later all the steps are too much connected for me to keep the rigidity of a step-by-step plan – it is much more dynamic than that.


Right now I am stuck on one quite big problem - I want to create the two classes of Field and Piece which both point to one another. The problem is that the second function in the code can recognize the function that comes before it. However  the one that is first can not point to the one that comes afterwards because at that point the compiler doesn't know that it exists.

No comments:

Post a Comment