Last update on .

Here are some tips for building custom content models in Alfresco:

Keep Properties in Custom Aspects

Alfresco provides developers with powerful tools for modeling content and automating functionality. Aspects are one of the biggest. Because Java developers are familiar with method annotations, most quickly comprehend how aspects allow a developer to cross-cut the content model and group custom properties into a bundle. However, aspects have the additional property that they can be added or removed programmatically. This makes aspects more flexible than traditional content types which cannot be removed once applied to an asset.

For this reason, aspects can help our content model keep pace with the inevitable evolution of business needs. Next time you create a custom type, instead of defining the custom properties as part of that type, define them as part of a custom aspect that is mandatory for the custom type. In the future you can remove the aspect if you need to remove the properties (after migrating any information that needs preserving, of course).

Use CamelCase, Not Underscores

Left over from my pre-Java days is a fondness for underscores. I think underscores improve readability, especially with identifiers like RFI_Number. However, using underscores in aspect, type, or property names had unexpected consequences when the name was converted to a key for localization or display in a form field.

I asked internally about this, and I found a difference of opinion about whether underscores should be legal in a content model. Since there are some instances where underscores are used in the core product’s content model, any problems with underscores are probably bugs. But the convention of using CamelCase is predominant and it is what our automated tests cover. It is safest to use CamelCase as is common in the Java world.

Pingbacks

Pingbacks are closed.

Comments

Comments are closed.