Avnrao - Design Patterns, C#, .Net & SQL Server

Thoughts sharing on Design Patterns, Model Driven Architecture, Designing Classes and little bit on C#, .Net and SQL Server.

<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011


Navigation

Subscriptions



Sudoku Game Solver

If you want to be an Architect, you need to think like one. I always wanted to learn how Architects approach design classes and what kind of though process they put in to solve certain design challenges. I found very little information on this and wanted start scribbling on this topic. 

As mentioned in my previous post, i am going to illustrate the design for sudoku game solver using GOF design patterns. If you need to know more information about Sudoku game, look at the previous post. Solving a sudoku game is quite interesting and challenging based on the complexity of the game. WebSudoku has lot of games that you can try and heat your brain solving medium, hard levels. I wouldnt even touch evil category..they are scary..

Medium, Hard levels can intimidate you, if you do not follow certain simple methods to solve. If you follow these simple rules, you can solve lot of games with ease. Here are few simple tips that will get you started to solve the puzzle.

  • Take a pencil and paper. Draw a grid like this one : Grid.
  • Now start selecting the digits that are already given in the puzzle.
  • When you start marking the known digits, based on sudoku rules, that digit should not be present in the respective column, row, box. You will know what i am talking about, when you click on a digit in the Grid shown.
  • As and when you select, same digits disappear from column, row and boxes. You will be left with only digits that are allowed in individual Cells.
  • Based on the complexity, you will be left with few choices, where you need make a dicision between 2 digits or more. If the puzzle is simple, then, you would simply has solved the puzzle without any effort.

We are going to design and develop an application that solves sudoku puzzles for us. We simply enter the known numbers into the application and rest is taken care by application. Final result is a solution to the game. So lets get the page specs ready for this application.

Page spec :

  • The application allows us to enter known digits from a sudoku game.
  • As the digits are entered, based on sudoku game rules, the digit entered will be removed from the column , row, and box.
  • If a digit is only in one place in the entire column, row or box, that digit should be automatically be highlighted.

This is how the screen should behave. Now we have an idea about what we are going to develop. For this kind of application, there are many way to implement them. One way is directly jumping into coding and starting typing without any design. This approach has many issues, such as maintainability, understading the code and all. We will take the better approach of design the application and then coding.

We need 2 designs, Domain and UI. Since we do not have any interaction with data source, we need not design any data layer or databases. Lets start with designing Domain classes. Check the diagram below.

The class diagram shows a simple domain design that i came up with for Sudoku solver application. It follows Model driven architecture where the model is represented by these domain objects. The interesting part is how to come up with such kind of diagram and understanding what patterns used in this design. How these patterns can help simplyfying the code and making objects reusable.

We will go through design approach in the next blog. Mean while, if you can come up with domain design for sudoku solver, please post me the link.

posted Wednesday, August 09, 2006 4:05 PM by avnrao with 0 Comments

Few Prototypes on using Design Patterns

You can refer to my Previous Blog for some of the prototypes i have created using Design Patterns. It explains what design patterns are, and design an application without / with design patterns.

I will be sharing Sudoku Game solver application that have designed and developed in the next blog. Please stay tuned..

posted Tuesday, August 08, 2006 3:22 PM by avnrao with 0 Comments




Powered by Dot Net Junkies, by Telligent Systems