I've been programming more and playing Magic less, so some of my posts (like this one) are only about programming. Hopefully I'm not alienating my audience. I'm not sure who exactly reads this blog but I'm guessing it is a mix of non-programmers, programmers, computer literate Magic players, as well as a few people who program and play Magic. (Hi to frwololo, nantuko84, DennisBergkamp, Rob Cashwalker , etc...)
These points are taken from the book "Code Complete" by Steve McConnell.
1. The less you know about the internal workings of another method, the fewer assumptions you make about how the method operates. The fewer the assumptions you make, there is less chance that one of them is wrong.
2. The goal for individual methods is to make them like a "black "box". You know what goes in and you know what comes out but you don't know what happens inside.
3. The more independent the subsystems are, the more you reduce the complexity. Carefully defined modules separate concerns so you can focus on one thing at one time.
4. If you have data leaks between the subsystems because of sloppily defined interfaces, you will have a flood of unnecessary complexity.
5. A blanket attempt to avoid mistakes is the biggest mistake of all. Design is a process of carefully planning small mistakes in order to avoid making big ones.
The first and second points are basic but still very important. Sometimes I forget that objects and methods shouldn't know the internal workings of each other. Writing methods like "black boxes" will improve your code.
I think that the third point is the most important. Forge has several parts: IO, user interface (gui), decks, rules implementation but I didn't design these parts to be separate which results in the fourth point.
The fifth point made me laugh because I thought that the design process tried to make everything perfect. The program should be perfectly planned and each part of the program should be perfectly defined and everything is just perfect. The truth is that program design is a very sloppy process. Mistakes are OK but you try to make small mistakes instead of big ones.
Early mistakes (on paper) are less frustrating than later mistakes which are etched in code. Early mistakes are MUCH easier to fix.
Internally Forge has two play areas. I misunderstood the rules and thought that each player had his own "in play" area (now called battlefield, yeah). The problem occurs when you steal a creature that has a "come into play" ability and Forge thinks that creature is being played and the ability triggers. This problem can be fixed by some clever coding but it all stems from my initial misunderstanding. Changing the code to create a unified "in play" area would be a nightmare. (Mostly the user interface (gui) code would have to be changed.)