It's been a while since I posted my first Silverlight application, a Digital Logic Simulator. Since I've posted this project, many people have asked for and I've promised to put together a tutorial that explains the design and implementation of this tool. Now that things are beginning to wind down as the holiday season comes to an end, I have some free time to begin working on this long awaited tutorial. So this will be the first in a multi-part series to document the design and implementation process employed for this project. I'll be sure to include sample code and detailed explanations as needed, but for those who are interested in diving right into the code, you can download the complete source code for this project from CodePlex.
Part 1: Defining a class for logic devices
I'd like to point out that this particular project is one that I've been thinking about since I was an undergrad studying Computer Science many years ago. My inspiration was a great program for the Mac (OS 8 era), the name of this program escapes me but I'll be sure to insert it here along with a screen shot if I do manage to figure out what this program was called. But in short, it was great because it allowed the student to very easily connect various gates together in order to verify that a simple digital logic circuit worked as expected, according to its truth table. I always thought that this program was nicely done and I was also disappointed that an equivalent PC version was not available. At one point, I considered developing a program like this in Java so that it would be portable, but Java turned out to be a disappointment on many levels (which is a topic for another blog article). In any case, when I first started learning about Silverlight, I almost immediately realized that it would be the perfect platform for implementing a simulator like the one for the mac. On a side note, there was also a great Turing Machine emulator for the mac that had no good PC equivalent, and I think that this could be another great little project to work on in the future.
Going back to that old mac program and thinking about how it was designed, what I really liked about it was how intuitive it was to use. You could simply drag various logic devices onto the screen and position them however you wanted, and connect the devices by dragging the output of one device to the input of one or more other devices. When trying to decide how best to replicate this behavior from an object-oriented perspective, it makes sense to identify all of the properties and behaviors that are common to all digital logic devices that will be used in the simulator. After identifying as many of these that come to mind, they can be defined and generalized in a super-class from which specific logic devices, such as gates, can be derived. For this digital logic simulator, I defined a "Device" class which fulfills this purpose.
(To Be Continued...)