As complicated as necessary and no more. mojoPortal code is written in an Object Oriented style. For the most part, when the user interface, the website, interacts with business objects, it will create an instance of the business object and interact with its properties and methods. In the data layer, by contrast, static methods are used. Its purpose is to abstract the underlying database entirely away from the business layer. This allows one to create data layers for multiple database platforms.
Much of the code in the business and data layer is generated which saves enormous time on typical CRUD (Create, Retrieve, Update, Delete) operations. We always review the generated code and usually have to customize it if we need something other than basic CRUD. We use CodeSmith Studio which is like using ASP.NET to generate your code including anything from stored procedures to user interfaces based on the database schema. We wrote our own scripts so we can point it at an MS SQL database and generate a corresponding data layer for MySQL, PostgreSql, or SQLite.
The whole website is the presentation layer and therefore should only have code related to presentation logic. That is one of our goals in designing this framework. This website was built using ASP.NET. It consists of:
- .aspx pages
- .ascx user controls
- a Global.asax file
- a Web.config file
- a Culture.config file
- mojoPortal.Web.dll, which contains all the presentation logic for the core framework
mojoPortal.Web.dll talks to mojoPortal.Business.dll and presents its interfaces to the user as web pages.
When working on the website we try to make sure that all of the code is presentation logic, providing a mapping between business object properties and methods to visual controls for intuitive user interaction.
All business logic for the core framework modules is handled by mojoPortal.Business.dll or other business layer DLLs for various features
When developing in the business layer we try to think of the most natural way to represent or abstract business entities as objects in a way that can be easily consumed by the UI.
Data Access Layer
All data access logic for mojoPortal.Business.dll is handled by mojoPortal.Data.dll. There are different versions of mojoPortal.Data.dll for each of the supported databases, MS SQL, MySQL, PostgreSQL, and SQLite. You can put any version in the bin folder of the web along with mojoPortal.Business.dll, and the site is happy as long as a valid database exists for the provided connection strings.
When developing in the data layer we try to think of how the database platform works and optimize operations according to its capabilities.