Skip to content

Examples

Rosario Carvello edited this page Mar 18, 2020 · 18 revisions

Subsystem examples

Into WebMVC package you will find different examples of source code files located under the examples subfolder. They give you a demonstration of main WebMVC functionalities, as well as, how to organize software into subsystems. Provided examples are organized as follow:

  • examples (main subsystem)
    • about (it contains a simple demonstration of coding a source code information helper)
    • cms (it contains general examples about showing contents by using WebMVC)
    • db (this subsystem contains some DB related examples)

Below is the directory/files structure:

Exaple.
Rember that, due to the MVC design pattern, you will find a replica of examples folders/files structure also under models, views and, templates folders.

You can run a demo from here

Conclusion

As we just described in the previous page a subsystem, in WebMVC, is identified at two levels:

  1. a physical level, the pathname. For example, the pathname examples/cms identify the subsystem cms which is contained into the main subsystem examples;
  2. a logical level, the namespace. In this case, it is the name examples/cms and must be equal to its pathname. Namespaces are used in source code for structuring and organizing naming conflicts.

For each subsystem, WebMVC uses a directory to physically store all its classes and uses a namespace to refer each class when it needs to be instantiated and executed; directories and namespaces must have identical names that are conventionally written in lowercase.

In conclusion, you need to take in mind that there are two decomposition levels when writing code with WebMVC:

  • First is the MVC decomposition (directories: controllers, models, views and templates)
  • Second is provided by the application subsystems, that is a folders/files structure you need to replicate within the controllers, models, views, as well as, for the templates directory.
    Also, remember that the directory controllers are the root directory from which all application controllers for the defined subsystems can be invoked. This is because in WebMVC the directory controllers are the entry point to access application software functionalities.

Inside all levels live each WebMVC assembly, a logical and physical name for representing, aggregation of the model, view, controller and, template and you can use for naming classes and template.

Clone this wiki locally