What's essential about architecture is that you can not set up a good architecture in an ivory tower. The pictures you make must be useful and not become wallpaper. Architecture encompasses standards, principles, guidelines, conceptual models, patterns, mechanisms and more.

The non-functional requirements are a good starting point for setting up software architecture artifacts.

Functionality

Functionality is covered by use cases, but often there are also use case transcending functional requirements like patterns and mechanisms. An example:

subclass plaatje met Region voor killer sudoku

 

Usability

From an architectural perspective the following principles are relevant:

  • Separation of presentation logic, business logic and data
  • Selection before action

By separating the business logic, the sudoku rules, this logic can be re-used by both mobile devices and desktop computers.

 

Mobile devices like smartphones and tablets must handle touchscreen events, while traditional desktop applications must handle keyboard and mouse events. So the presentation logic differs, but the sudoku logic is the same.   

Selection before action can be considered as a user interface guideline as well. For the app the principle means that the user first has to select one or more cells and then activate an action upon these selected cells, for instance by pushing a button.

 

Reliability

Reliability can be divided into Confidentiality, Integrity and Availability (CIA). For the app there are no real security issues, but for availability there is a autosave requirement (R001). Important design decisions are the usage of the browser's local storage and the JSON standard for serialization and deserialization of objects (the board objects).

 

Performance

To ensure a response time within 100 milliseconds (requirement P001) cell candidates are stored in a bitmask. Candidates can be added and removed by using bitwise operations.

Example:

Suppose a cell has 4 candidates 1, 3, 7 and 9

These candidates can be stored in 2 bytes as

These 2 bytes can be interpreted as a 16-bit integer as well

If you want to remove candidate 7, you shift in a new bitmask with value 1 that value 7 positions to the left

Then you compare the 2 bitmasks using a logical AND operator

Now the resulting bitmask has candidate 1, 3 an 9

Note that In Javascript the smallest integer is a 64-bit integer, which means that bitwise operations are not really effective.

 

Supportability

A supportability principle that has been used for the app is:

  • Separation of the know and the flow

Separation of the know (rules) and the flow (processes and presentation) is important for the maintainability and reusability of the sudoku rules. 

 A common pattern for setting up a web app is MVC, see Model-View-Controller. Since the app is a Javascript application controllers are represented by eventhandlers and views are represented by HTML-pages. The model is represented by the implementation independent analysis model (class diagram).

Other patterns that has been used are the strategy and the visitor pattern,see software design patterns.

Software can be written in many languages. For the app Javascript has been chosen. There are some drawbacks:

  • Javascript is a (slow) interpreter
  • Javascript uses weak typing
  • Javascript doesn't support class inheritance

 

R001 Autosave possibility

Each user event (keyboard-, mouse- or touchscreen event)  must trigger a saved snapshot of the board.

 

U001 Undo/Redo possibility

For this requirement you can specify a mechanism

 

U003 Hint/Autosolve possibility

For autosolve a backtracking algorithm can be used.