3. 2. Implementing best practices

As the development starts, you need to ensure that the developers are following best practices. It can be difficult to identify what best practices to follow for a particular implementation, but we identified 7 Key Concepts for Successful Development in Kentico. Each of these concepts are applied differently depending on the particular requirements and details of the task at hand. However, the basics of these concepts can be applied broadly.

Security

There are two sides to security. The first is related to properly configuring access to content and functionality for authorized users.

The second is making sure that hackers are not able to exploit flaws in the implementation to gain unauthorized access to content and functionality.

When it comes to Kentico, you need to consider the following:

  • User permissions and access control lists (ACLs)
  • Proper configuration of web parts
  • Sanitization of user input to SQL injections and cross site scripting attacks
  • Secure data storage/transfer

Kentico administration UI, out of box controls, and APIs make it easy for you to secure your application by providing an easy to use UI, some automatic protections, and tools to make sure you are able to easily secure your code.

Performance

Many times, developers primarily focus on just making sure what they build is functional. This can lead to scalability issues, higher running costs, or even dissatisfied users.

Kentico does a lot of optimization automatically, and provides lots of ways to get better performance out of your project with features like:

  • Caching in MVC or Portal Engine
  • APIs that can be fine tuned to retrieve only the necessary data.
  • Built in debugging tools allow easy access and visibility into the inner workings of the system.

It's important to note that while Kentico does a lot of things automatically, it can be very easy to introduce performance issues. Here are a few practices to keep in mind as you develop:

  • Introduce as few (ideally zero) SQL queries as possible.
  • Make sure that you have a caching strategy and that it is working.
  • Review the performance of your custom code using the debugging tools in the administration interface.
  • Review how the project is configured, as some options like analytics and online marketing features can add some overhead to requests (only enable what you need).
  • Consider first page load time as well as primed cache load time.
  • Consider integrating third-party tools to gain further improvements such as minifying your HTML with WebMarkupMin

Dependencies

When building something new, you need to consider what it depends on (data structures, third party APIs, etc.) and what will depend on it (templates, custom modules, etc.).

It is important to plan how what you are building will interact with its dependencies in order to avoid re-work or extra effort. This is also important when considering how to deploy new features/functionality down the line.

Some examples of dependencies to think about in Kentico include:

  • Page types and content needed before being able to build a template.
  • Cache dependencies being configured properly.
  • Code files and resource strings for a custom module class needed before developing module UI.
  • Third party libraries must be available in .NET or as a web API before you can interact with them inside a Kentico project.
  • Relationships between custom built features must be understood.

Maintainability

Whether the project will be maintained by the same team or not, implementations should be created with future maintenance in mind.

If something is built sloppily the first time, maintenance can easily be exponentially more costly. It is important to consider every aspect of what you are developing when it comes to maintainability.

For example, you will want to pay attention to some of the following things in Kentico:

  • For web parts, use short control IDs with descriptive titles that identify the purpose and control ID (e.g. control Id: "MN", Title: "Main Navigation [MN]").
  • Name code files appropriately (e.g. use the class name of the class contained in the file).
  • Store code files in an appropriate location in sub-directories identifying it as custom for the project and based on the namespace (e.g. /CMSWebParts/MCP/ProductConfigurator.ascx(.cs), where MCP is an abbreviation for "Modular Construction Products", the site name).
  • Use Kentico's logging APIs to log success/failure/warning/information appropriately.
  • Consider refactoring large methods and using abstraction layers to make code readable and reusable.
  • Use built-in extensibility points such as global events or providers.
  • Use an appropriate naming convention to avoid collisions with system objects, especially during upgrades/hotfixes (e.g. prefix things with an abbreviated version of the site/project name).

User experience

This applies to both editors and visitors. Your solutions should be built with ease of use in mind. Your editors will have an easier time keeping the site up to date, and your visitors will be more engaged.

Some examples of how you can create a good experience for editors and visitors are:

  • Utilize widgets rather than web parts for personalization and/or AB testing to allow your editors to manage this themselves.
  • Build integrations that require simple interaction or are automatically run.
  • Utilize custom modules to extend the system in a complex way while maintaining a consistent and easy to use user interface for editors.
  • Don't require more information than necessary from visitors.
  • Provide visitors with a customized experience based on their history or context.
  • Make it easy for visitors to fall into the pit of success.
  • Consider page load times for visitors (the faster the better).

Extensibility

Projects are very rarely built once and never extended. Thinking about how a feature might need to be enhanced in the future can help save effort and time in the future.

However, do bear in mind that there is a need to balance the effort/time with the project's budget/timeline. Be sure to think about:

  • Consider how data will grow and change in the future.
  • Think about future integrations or features that need to be added.

Consider building on Kentico built in extensibility points to help with this process:

  • The portal engine enables rapid development and flexibility.
  • Use custom modules.
  • Investigate event handlers.
  • Look for providers to override/extend.

Testing

You should always verify that what you've built functions as intended. This includes negative testing to make sure that unintended behavior is guarded against. More details on this can be found in the Testing section.

  • Scenario: Adding a category page with personas and secured content

  • Scenario: Integrating with an existing authorization service

  • Scenario: Automatically importing content