Why it's important to write Readable Code/Expressions in Adobe After Effects and how to do it.
- Roland Kahlenberg
- Apr 11
- 4 min read
Updated: 5 days ago
As an Adobe Video Solutions Partner, my main area of focus is in developing Custom Solutions including highly Advanced Intelligent MoGRTs and After Effects Templates and Scripts.
Solutions based on a Systems Thinking approach often provide the best solutions because they are based on a holistic approach to problem-solving. A systems-first approach means you'll be building a solid foundation on which you will develop your solutions.
One of the first things you want to do is to write Readable Code because in order to develop Advanced Intelligent MoGRTs/Templates/Toolkits, you require a system and having a system means using lots of different Expressions.
Scaling your After Effects Expressions Library is going to be an important part of growing your efficiency in developing solutions; be it
So, you are going to have to re-use, build upon and expand existing Expressions and in order to make this happen, you want to write Readable Code or Readable Expressions so that you can scale your Expressions Library easily and quickly.
Re-use as many of your Expressions as is possible, to cut down on development time and also to cut down on testing time since you've used the code in a previous project, you will already know what requires testing and even how to tests.
Use the Q & A below to test your understanding of Writing Readable Expressions.
Q & A
What is Readable Code?
Readable Code is defined as code that is human-readable, meaning it can be easily understood by others (and even the original author at a later time). It's a characteristic that facilitates the management and governance of systems, making the code's purpose and logic more accessible.
What simple test can be used to gauge the readability of a short After Effects Expression?
For short After Effects expressions, a useful test for readability is to examine the last line of code. This final line should ideally provide a clear indication of which properties are being manipulated and what calculations are being performed to achieve the expression's result.
Why is writing Readable Code particularly important in the context of After Effects Expressions?
Readable Code is a term meant to describe code that is human-readable and easy to understand and not a bunch of jumbled alphanumeric characters.
While important in all coding, readability is highlighted in the context of After Effects expressions because these expressions, though often short (typically 4 to 15 lines), directly impact visual results and are frequently shared or revisited. Readable Code makes it easier for designers and other users to understand, troubleshoot, and modify these expressions.
How do variable names contribute to or detract from code readability?
Meaningful variable names are crucial for readable code. Using names that clearly describe the purpose or function of a variable significantly enhances understanding. Conversely, cryptic or overly short variable names, even if initially clear to the author, can make the code difficult for others to decipher. The sources suggest a preference for names that describe what the code does rather than just what it is.
How does Readable Code contrast with "cryptic" code, as mentioned in the sources?
The motivation to write Readable Code is to make them more easily understood with code that is hard to understand due to complex structures and cryptic variable names.
This highlights the practical challenges of maintaining and modifying code that lacks readability and underscores the benefits of prioritizing clarity in coding practices.
Can tools assist in improving the readability of existing code? If so, how?
Yes, you can prompt ChatGPT or most LLMs with your Expression and ask it to write comments for each or specific parts of your Expression.
You can also prompt them to rename variables to be more descriptive and add inline comments to explain specific sections of the code, thereby making the logic more transparent and easier to follow.
Is there a trade-off between code efficiency (performance) and readability? How should this balance be approached?
While writing efficient (performant) code is important, readability should not be entirely disregarded in its pursuit.
The sources suggest that well-structured and clearly named code can often be both performant and easy to understand.
Prioritizing clarity can also aid in identifying and optimizing code later. The goal is to find a balance where the code runs effectively while remaining accessible and maintainable.
Glossary of Key Terms
Readable Code: Code that is human-readable, easily understood by others (and the original author later), facilitating management and governance of systems by making its purpose and logic accessible.
When developing Motion Graphics Systems, it is imperative you write Readable Code because the system will evolve; it will grow and you or someone else will have to re-visit previously built Component Libraries or Templates from which to craft new solutions for new use-cases or to update campaign requirements.
Component Library: Code that executes calculations quickly and efficiently, leading to smooth playback and faster rendering in applications like After Effects.
Reproducible Code: Code designed to function correctly when the layers or properties it is applied to are duplicated, allowing for easy scaling and extension of projects or toolkits.
Cryptic Code: Code that is difficult to understand due to complex structures, poorly chosen variable names, or a lack of clear logic.
Meaningful Variable Names: Variable names that clearly describe the purpose or function of the variable within the code, enhancing its readability and understandability.
Inline Comments: Explanatory notes added directly within the code to clarify specific sections or the logic behind them, improving readability.
Motion Graphics Toolkit: A set of pre-built elements or templates in motion graphics software, often driven by expressions, designed to be easily customized and reused for various projects.
A well-crafted Toolkit will include Responsive and Adaptive features which ensures the Toolkit will work across wide-ranging types of content in an automated manner. Adaptive & Responsive features are also foundational, critical, requirements for developing bespoke Automated Content with Adobe After Effects.
Comentários