Starting out in this project I had the idea of creating an economy simulation type game that I could use as an experiment for understanding how an economy works and how outside influences might affect it. My goal was to start out with a governmental type entity that provided a source for all products to be bought and sold so there would never be a shortage of anything and there would always be somewhere to put surplus, though the prices would be severely skewed to create a large window for competing prices. But then eventually the central government would not be needed any more so the economy would be self supporting. At least that is the overall goal.
I have had this idea for half a year now, but didn't really get started until about 1 month ago. I started out writing, as detailed as I could, the game design. I included what the overall goal of the game is, what the goal of the players would be, and how they could achieve those goals. I then transferred those designs into system requirements including what the system would have to 'know', meaning the data it would have to keep track of, and also what it would have to do, or calculations it would have to make and functionality it would have to enable the players to do.
I inherently knew the type of architecture the system would have, because of the types of systems I have been working on and the architecture most web systems take on. It would have a database backend with a web front end. The specific technologies would be SQL Server and ASP.NET because that’s what I know and have resources for. So I began designing a database for the entire system. This took awhile and seems to be overly complex.
I tried finding tools to help create an ER diagram like how I did it in school with rectangles representing entities, diamonds representing relationships, and circles representing attributes. Of course there's more detail within an ER diagram, but those were the basics I was looking for. I couldn't find anything really good for free. I have MS Visio and it says it has an ER diagram template, but it's not like I learned in school. So I ended up creating my own stencil within Visio and designed the database. It didn't take too long before it was so big and there were so many connections that it looked like spaghetti with square and diamond shaped meat balls. A lot of the time I spent on it was trying to keep it clean and readable.
Finally I had something I could translate into a database and so I began building a database diagram in SQL Server 2005. A nice feature of this is that I can create the tables and relationships between the tables all within the diagram.
By the time I finished the diagram I decided that it might be better to only implement part of the system so I wrote out an 'Iteration 1' system that simply captured overall pieces of the whole system. There wasn't much detail in this 'Iteration 1'. So even though I had a 'complete' database, I wasn't going to implement all of it into the front end.
It's worth saying here as well that another intention was to learn new parts of SQL Server and ASP.NET that I haven't used before so that it would be an even better educational experience. So part of the purpose of 'Iteration 1' was to get something fully functioning quicker so that I could have experience with the 'new stuff'. To list a few of the things I wanted to use: AJAX, SQL Server Triggers, Wizard controls, and Strongly typed datasets.
I have read some about keeping the logic layer separate from the other parts of the system. With a lot of SQL stored procedure experience I thought it would be easiest for me to have a schema in the database that just contains the stored procedures responsible for the business logic and then have a data access layer utilizing strongly typed datasets and data table adapters to communicate with the data. So it sounds kind of reverse from what I was reading about, but I thought this would be easiest for me.
As I progressed I soon realized that I hadn't spent enough time in the previous steps. I found gaps in the game design, which lead to larger gaps in the system requirements, and even larger in the database design. I even found gaps in the data design due to it just not being thorough enough. The requirement was their but it was only vaguely satisfied. It had been far to easy and appealing for me to move on to the next step with out having a thorough previous step. But at the same time I found myself staring at a step (say the ER diagram) and not sure what else to do with it so I would move on. It wouldn't be until later that I would discover a gap or conflict and then need to go back and partially redesign. This of course meant that I may have needed to implement those changes through out the other steps implemented.
So where I am now is I almost have a complete 'Iteration 1', but have discovered too many design gaps and conflicts to have an elegant finish. I have already made some 'hacks' to be able to move forward but progress is slowing down and the 'wins' from having a well thought out design are disappearing.
So now I am thinking of starting over utilizing what I have learned. I have thought about the process I will take and even though I don't know if it is the best, this is what I am going to do. I will review the game design and system requirements. I feel that these should be complete enough by now. I will work on the project in iterations, but not as severely as the first time. I will implement the full database design, but cut out the 'gold plating' aspects such as AJAX and look/feel stuff, but the full interaction with the data will be there. I will use MS Visio to create a 'Microsoft' entity relationship diagram. Even though I don't feel it is a true ER diagram it is the stencil that Microsoft has included and since I am using exclusive Microsoft tools, it might make the most sense in the end. Besides, does it really matter if a relationship is represented by a diamond or another 'entity'. A relationship will have to be modeled within a table anyway right, so might as well start out that way.
I will then create the actual database which should be very simple since it will already be modeled as such. And I know that Visio can actually create a SQL server directly from and Entity Relation diagram.
I will change some of my naming conventions. Initially I had several objects named the same but within different schemas. For example I had two Product tables with different field names, but they had different purposes. One was for product definitions while the other was for actual products that a player actually owned. So one was actually Param.Product while the other was Data.Product. Even though they are in different schemas it still proved to be a little confusing in other places like the typed datasets that didn't really have an element for schemas. It also looked a little weird in the database diagram.
I also used too simple of field names for key fields. For example in the Param.Product table it had a 'Name' which was its primary key. Then in other tables referencing it as a foreign key there was a Product_Name which referenced it. Through out the system it got confusing when to use the 'simple' version (Name) and when to use the more fully qualified version. So I am going to change this so that field names are more fully qualified throughout.
To follow many of the tutorials I have read about I am going to put the actual database logic in a layer outside of the database on the other side of the access layer. I know how to do it within stored procedures, but I haven't experienced it the other way, so before I can say that stored procedures are easier I will do it both ways and then be able to make a better say. This is a learning experience for me so I might as well do it differently (and more like the industry standard).