Module decoupling specs

From Inforail
Jump to: navigation, search

Disclaimer - in this assignment a graphical interface is used as an example, but you must be aware of the fact that problems will happen if the program becomes too tied to any of its other sub-components.

A typical mistake one can make is tie the program's logic tightly to its graphical interface. As a result, the program becomes difficult to maintain, and it cannot be adapted to new needs. The right solution in this case is to re-write it from scratch, but in practice a program is patched with "temporary" kludges that will cause more pain in the future.

By designing software in such a way that the logic is separated from the interface, you make your life easier.


Objectives

Design a program that can be accessed via multiple interfaces, one of them is a full-featured graphical interface, the other one is a text-mode interface. You can use other secondary interfaces, ex:

  • web-interface
  • provide an API that other programmers can use (i.e. they can achieve the same results by calling functions from the interface you provided)


Warnings:

  • Do not create 2 programs that do the same thing in different ways. You are supposed to break it into modules, and both versions must use the same core module.


Requirements
  • The software must consist of at least 3^ logical units
    • the core - this is where you write the business logic of the program
    • GUI - this is the full-featured graphical interface module that interacts with the core in order to know what to display on the screen
    • secondary user interface - this can be a text-mode console interface, a web-based interface, or a CGI program that generates HTML at the output.
  • The same core must be used by all the user interface modules.
  • The other parts of the program (i.e. the ones not related to the GUI) must also be designed in such a way that they can be easily replaced with other modules.
    • However, you only need to provide one sample implementation for those parts.


^ As you continue developing your project, you must apply the same approach for other parts of your program, ex: storage (plaintext files, databases, etc), data input (from the keyboard, from another program, from an external device, etc), and so on. If you do so, the program will contain other modules, hence "at least 3" is said in the first requirement.


Notes:

  • The secondary UI does not have to implement the entire feature-set of the graphical interface, a subset of the most basic features will do.


References

  • Ncurses - a library that allows you to create GUI-like user interfaces for console applications.
  • Ncurses screenshots - examples of console applications that use Ncurses to create user interfaces.
  • MVC pattern
  • Noteman - an example of a badly designed application, its logic is tied to Borland's VCL GUI; as a result, it wasn't updated since '45. The source code is available.