|
I've been trying to keep up with the Job Interview line of posts over at dev102.com, but unfortunately I've been running out of time to do all of them. Anyway, this weeks question can be found here. Stop reading if you don't want the answer. This problem can be solved using a Finite State Machine. The only thing you're going to store is the current state of the machine, once you reach the end of the machine, you'll alert. On initialization of the piping component, you'll build a finite state machine for the given alert sequence. Every time you are given a message you check what you should do with the state machine based on where you are currently at. I was going to write out the code to do this, but it becomes a little tricky when you have repeating data in your alert sequence because if you get a message you're not expecting you don't necessarily want to reset the state machine to its initial state. For example, if the alert sequence was "A, A, A, A, B", and your input is "A, A, A, A, A, B", you don't want to reset the machine to the first state when you get that 5th A, you want it to stay in its current state.
Do yourself a favor, next time you have a build error that says
something like: The type or namespace name 'XYZ' could not be found
(are you missing a using directive or an assembly reference?). Double
click the error (which will highlight the unknown type) then hit
Alt+Shift+F10. This will bring up a dropdown that has all of the types
that match that class name and hitting enter will automatically add the
appropriate using statement. Thank you Visual Studio!
|
|
Nitriq is a Code Analysis Tool for .Net Developers. It helps you visualize your code and quickly find types and methods that need refactoring.
It is currently in a free public beta, but will have reasonable prices once the bugs are worked out.
I'll be using this blog to talk about .Net, C#, WPF, ASP.NET, Nitriq and MicroISVs.
RSS
Tags
Archive
| November, 2009 (2) |
| October, 2009 (5) |
| September, 2009 (1) |
| August, 2009 (1) |
| July, 2009 (1) |
| June, 2009 (1) |
| May, 2009 (1) |
| April, 2009 (2) |
| March, 2009 (1) |
| February, 2009 (2) |
| January, 2009 (1) |
| October, 2008 (1) |
| September, 2008 (1) |
| August, 2008 (1) |
| July, 2008 (2) |
| June, 2008 (2) |
| May, 2008 (2) |
| March, 2008 (2) |
| February, 2008 (8) |
| January, 2008 (4) |
| December, 2007 (6) |
| November, 2007 (2) |
|