Convention over Configuration principle & example from SAP CC

Nuray Fahri
3 min readNov 15, 2023

--

The Convention over Configuration (CoC) is a software development principle designed to streamline the development process by providing default settings and conventions for developers to follow. Instead of requiring developers to manually configure every aspect of a project, the framework or tool establishes reasonable defaults that can be used unless overridden by the developer.

While CoC simplifies development, it comes with a drawback — it may limit flexibility. When developers need to deviate from the established conventions, additional time and effort may be required to override the defaults.

Examples from Spring

In Spring Boot, Convention over Configuration simplifies database setup. By sticking to naming conventions and including the required dependencies, developers effortlessly establish a database connection without the need for detailed manual configuration.

Similarly, in Spring MVC, developers experience the same in controller mappings, view resolution, and form handling. This means that creating controllers and managing form submissions requires minimal explicit configuration. Instead, developers can rely on naming conventions for an automatic and streamlined setup process.

Example from SAP Commerce Cloud

SAP Commerce Cloud also implements the Convention over Configuration principle to simplify or eliminate the need for writing configuration files.

Example is for importing essential and project data.

Essential Data: Core-level necessities, agnostic to usage across rollouts, include Countries, Languages, Currencies, Titles, and more.

Project Data: Real-time reference data not top core implementation, featuring Catalogs, User Groups, Integration Configurations,Stores, Sites, Search Index Setup, Page Templates and more

Convention

During initialization and update processes, the platform searches for ImpEx files in:

  • For essential data: <extension_name>/resources/impex folders for files with names matching the pattern essentialdata*.impex and imports them during essential data creation.
  • For project data: <extension_name>/resources/impex folders for files with names matching the pattern projectdata*.impex and imports them during project data creation.

The ImpEx directory is not created by default; we create it and copy files to it.

OOTB Example:

Here if we add another impex like resources/impex/Test.impex it will not be executed as not following the naming pattern.

Configuration

If we have specific folder structures or wish to use another folder in resources, configuration can be overridden in the local.properties file:

  • For essential data, add the property <extension_name>.essentialdata-impex-pattern.
  • For project data, use <extension_name>.projectdata-impex-pattern.

Example from Commerce with additional folder in resources:

project.properties:

Basically if we want our configuration to work as the default does, we set the pattern to <extension_name> .essentialdata-impex-pattern=….impex/essentialdata*.impex.

Read more:

https://help.sap.com/docs/SAP_COMMERCE/d0224eca81e249cb821f2cdf45a82ace/8beedbec8669101491c4a5cd1ffc4465.html?version=1905

--

--