[computer-go] C++ parameter passing

Chrilly c.donninger at wavenet.at
Wed Aug 9 21:14:28 PDT 2006


>Yes, it's a bad smell. This is a method on a BitBoard, which is iterating through the points in that set, and xoring out the corresponding elements of zobrist_numbers from the Zobrist has stored in state. >Since it has to access fields within this BitBoard, I put it in the BitBoard class. It would be better OOD to use an iterator of some kind, but I'm obsessed with speed this week.

If you are obsessed with speed, than make no classes at all. Good old C style is the fastest. Classes have an overhead. But the main point is, a class structure usually makes for this application things more complicated without having a real benefit. Usually one has only one array of zobrist_numbers. One can define this array globally and there is no need to pass them as a parameter. I think the basic rule is: If one is sure to have only one instantiation and also no sort of class-hierarchy, one should avoid classes.
One can structure C-style code in the same way than classes. E.g. by putting all Hash-Related code in one file, by naming conventions... In my experience, one can make a mess in any programming language and programming style and one can write also clear programms in any programming language including Assemblers. The mess depends primarly on one ones head and the age of programm. Over time every programm gets messy. 
The worst programming project I have worked ever was in Ada. Due to an unclear and overambitious specifications it was a complete horror. It was an error-tolerant Operating system. But only the user had do be tolerant for the errors of the system. The project was cancelled after spending about 1000 person years. I think clear specifications - (at least in one ones head) - are much more important than a specific programming style. Additionally one should always implement the most simple solution which meets the criterion. KISS. Handtalk is a nice example of this. Small, strong, stable. It does not matter that it was written in Assembler. Actually I think that its like this not although but because its written in Assembler. Assembler is more cumbersome than C/Java.. and one thinks twice before one implements a complicated idea. 

Even if one parallizes the programm it is in my experience better to parallize by using processes and not by threads. If one has a cluster one has to use processes anyway. But the main point is, that with processes there are clear defined communication points and one can not overwrite some variables in another process. So even for parallization there is only one instance of basic structures.

Chrilly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://computer-go.org/pipermail/computer-go/attachments/20060809/aba4018a/attachment.htm


More information about the computer-go mailing list