Alfresco Best Practices

jayesh

April 28, 2022

Software industry is most dynamic industry among other. The biggest challenge being in this domain is to keep updating your knowledge day-by-day. Though this challenge is applicable to everybody in software domain, its applicable more to the people using open source tools and frameworks.

It may not be that complex to learn new framework but to implement with right practice. Best practice comes with experience only. Using Alfresco for quite a long, I thought to share my experience so that you can leverage it in your project.

Best practice is very wide topic so I will divide it in following section,

  1. Development best practice
  2. Architectural best practice
  3. Deployment best practice

In this blog, we will learn development best practices. If you are new to Alfresco development, this blog will guide you to know what you should follow most religiously while development. I feel following 4 are important topics you should put in practice,

  1. Use the extension mechanism

Most simple and easiest way to learn any open source framework is to see how out-of-the-box functionality works. It’s often observed that developer doing R&D makes changes in existing file to see how existing functionality works and end up making change in same file and save in code repository.

Alfresco provide extension points to develop custom features. There are three category of extension,

  • Declarative – XML configuration that requires no coding
  • Programmatic – Code that adds new functionality
  • Override – Code that overrides default behaviour

Each category mentioned above has its way to extend or add new features to Alfresco. I would strongly recommend you to refer extension points guide on Alfresco documentation before you start with development.

  1. Implement your own content model

Another wrong practice we observed with newbie developer is, they google for the content model, find matching solution someone provided in blog or tutorial, copy-and-paste same file in their code and start adding their project code. The tutorials and materials you find through googling are just to explain you about concept. You should read those files, understand the concept and implement content model for your project on your own. This will help avoiding unnecessary code in your project.

  • Implement custom content model for your project
  • Extend required content types based on project requirement
  • Name the content type and property properly to avoid conflict
  • Be conscious about grouping properties between aspect and type.
  • Use association wherever needed, don’t force it 🙂

  1. Be through full with your code structure

Nothing wrong to read through out-of-box codes and clear your understanding how out of the box implementation works. The wrong practice starts when you mix the code structure of Alfresco and your custom code. When you are using open source framework, you have to be very conscious while implementing custom code. You always have to be through full for naming and packaging your custom code to avoid keeping same package paths, XML file names or package path.

  • Do not mix your custom webscript with out-of-the-box webscript packages.
  • Do not follow same java package structure as out of the box. Create project specific package structure.

  1. Package your customization with Alfresco ways

As a developer we put over most energy in coding and deprioritize packaging aspect of custom code. The real trouble starts from here. Packaging code in right way is equally important as coding. If you are following standard practice of packaging Alfresco code, you will have luxury of monitoring your module status from admin console.

There are two possible ways of packaging your custom code,

  • Use AMP to package your custom Alfresco code. AMP is preferred approach if you are using third-party library in your custom code. You will be creating AMP for both platform extension and share extension.
  • If you want to traditional way of packaging custom code, Alfresco 5.1 supports simple module approach using JAR. The only limitation of packaging custom code using JAR is, you will not be able to package third-party libraries.

Refer extension packaging Alfresco custom code to know more on this.

In my next blog, I will share about best practice in architecture and deployment. Stay tuned! Keep learning! 🙂

Blog By,
Jayesh Prajapati
Solution Architect

Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments