ACC Tips & Tricks, Adobe Campaign, Marketing Automation

Using OOP techniques in ES5: A Guide

Adobe Campaign Classic OOP concepts in ES5

In this blog I will be exploring object-oriented programming (OOP) and Adobe Campaign Classic in ES5. As you may already know, Adobe Campaign Classic relies on ES5, the version of JavaScript specifically used by the platform.

In ES5, there are a few limitations in terms of what you cannot do compared to newer versions of JavaScript (ES6 and beyond) when it comes to object-oriented programming (OOP). Here are a few aspects that may be limited in ES5:

  1. Class Syntax: ES5 does not have native support for the class syntax introduced in ES6. Instead, constructor functions and prototypes are commonly used to define objects and their behaviors.
  2. Inheritance with class: ES5 does not have the extends keyword for class inheritance. Instead, prototype-based inheritance is used, which involves manually linking objects through their prototype chains.
  3. Private Members: ES5 lacks built-in support for defining truly private members within objects. While you can emulate privacy using closures and naming conventions (like prefixing with an underscore), they are not enforced or restricted by the language itself.
  4. Getters and Setters: ES5 does not have explicit getter and setter syntax like get and set in ES6. Instead, you need to define getter and setter methods manually within the object’s prototype.
  5. Arrow Functions: Arrow functions, introduced in ES6, have a more concise syntax and lexical this binding. In ES5, regular functions are used, which may require extra precautions for proper this context handling.
  6. Iterators and Generators: ES5 does not have built-in support for iterators and generators, which are useful for iterating over collections or creating custom iterable objects.

When exploring OOP examples in ES5 while browsing the internet, I have come across numerous implementations. Since ES5 lacks native support for the class syntax introduced in ES6, constructor functions and prototypes are widely utilized to define objects and their behaviors.

Based on the examples I’ve observed, I have developed my own implementation that addresses a crucial aspect that was missing in those solutions: private methods. Let me share my implementation with you

var MyClass = function () {
  // Public properties
  this.a = 'some public property value';
  this.b = 'another public property value';

  // Private property
  var c = 'private property';

  // Private method
  var privateMethod = function() {
    logInfo('This is a private method.');
    logInfo('Accessing a:', this.a);
    logInfo('Accessing b:', this.b);
    logInfo('Accessing c:', c); // Print the private property c
    // Add your private method implementation here

  // Public method
  this.publicMethod = function() {
    logInfo('This is a public method.');;

//extend MyClass
MyClass.prototype.function = extensionFunction (){
	logInfo("YAY, i'm something like extension method")

var a = new MyClass();
  1. The MyClass constructor function is defined. When invoked with the new keyword, it creates instances of MyClass objects.
  2. Inside the constructor function, public properties a and b are defined and assigned values. These properties are accessible from outside the object and can be accessed and modified.
  3. The variable c is declared within the constructor function, but without using this. This makes it a private property because it is not exposed as a property of the object. It is only accessible within the constructor function itself.
  4. The privateMethod function is defined within the constructor function. It is a private method because it is only accessible within the constructor function and cannot be accessed directly from outside the object.
  5. The publicMethod function is assigned to the object’s prototype. It is a public method that can be accessed from outside the object. Inside publicMethod, the private method privateMethod is invoked using call(this) to ensure it is executed in the context of the current object.
  6. Extension of original class functionality with use of Prototype methods.
  7. An instance of MyClass is created using the new keyword and assigned to the variable a.
  8. Finally, the publicMethod of the a object is called using a.publicMethod().
06/26/2023 10:28:34 AM	js	This is a public method.
06/26/2023 10:28:34 AM	js	This is a private method.
06/26/2023 10:28:34 AM	js	Accessing a: some public property value
06/26/2023 10:28:34 AM	js	Accessing b: another public property value
06/26/2023 10:28:34 AM	js	Accessing c: private property
06/26/2023 10:28:34 AM	js	YAY, i'm something like extension method

You might have noticed that to call a private method I use predefined JavaScript method – .call(). This method in JavaScript is used to invoke a function and explicitly specify the value of this within that function. It allows you to control the context in which the function is executed.

The .call() method takes two or more arguments:

  • The first argument specifies the value to be set as this within the function.
  • The subsequent arguments (optional) represent the arguments to be passed to the function.

In the context of the code you provided (, .call(this) is used to invoke the privateMethod function with the value of this set to the current object.

When .call(this) is used, it ensures that the privateMethod function is executed in the context of the current object (this). This allows privateMethod to access and manipulate the properties and methods of the object.

Oh hi there 👋
I have a FREE e-book for you.

Sign up now to get an in-depth analysis of Adobe and Salesforce Marketing Clouds!

We don’t spam! Read our privacy policy for more info.

#adobe campaign classic #JavaScript #programming
Marcel Szimonisz
Marcel Szimonisz
MarTech consultant As a marketing automation consultant, I specialize in solving problems, automating processes, and driving innovation in my clients' marketing platforms.

I hold certifications in Adobe Campaign v6 (3x certified) and Salesforce Marketing Cloud (5x certified).

Additionally, I serve as a community advisor for Adobe Campaign, offering expert insights and guidance.

In addition to my professional pursuits, I also enjoy exploring various programming languages, CMSs, and frameworks, further enhancing my technical expertise and staying at the forefront of industry advancements.
Take a look at our subscription offering in case you are looking for a Marketing Automation Consultant.

Leave a comment

Your email address will not be published. Required fields are marked *

Similar posts that you may find useful

Mastering Marketing Automation: From Data to Engagement
Marketing Automation

Mastering Marketing Automation: A Guide

6 minutes read

Marketing automation is a technology-driven strategy that streamlines, automates, and measures marketing tasks and workflows. It aims to enhance efficiency, personalize customer experiences, and drive results by utilizing software platforms and technologies to automate repetitive tasks and nurture leads through the sales funnel. Marketing automation is a multifaceted process comprised of four essential steps. First […]

Continue reading
Link campaign to the delivery send in salesforce marketing cloud
Salesforce Marketing Cloud

SFMC | Link campaign to delivery send

3 minutes read

Are you aware of Salesforce Marketing Cloud’s additional marketing feature known as Campaign? This tool allows you to group similar journeys together, providing greater organization for your marketing activities. However, one drawback is that the campaign information is not available in the data views. While waiting for a fix from Salesforce, you can establish a […]

Continue reading
SFMC tips and tricks
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

SFMC TIP | Invalid links in HTML

1 minute read

When the HTML template is used (loading your own HTML code) all the links that use query parameters (?a=b) will resolve to invalid links when they redirect upon user click. This happens when web analytics UTM tags are being attached to the delivery. To resolve this issue all the links with additional query parameters has […]

Continue reading
Salesforce Marketing Cloud Tips
Marketing Automation, Salesforce Marketing Cloud, SFMC Tips & Tricks

Track links that are AMPScript variables

1 minute read

When you save links as part of an HTML code in an AMPScript variable, such as a paragraph containing a link to a page, you may face challenges in tracking these links. Salesforce offers a great feature that allows tracking of such links using the “httpgetwrap” inserted right before the URL protocol. When dealing with […]

Continue reading
Adobe campaign classic hot clicks extract workflow
Adobe Campaign, Marketing Automation

How to redo hot clicks report in workflow

3 minutes read

In the world of email marketing, tracking recipient activity is essential to understanding the effectiveness of your campaigns. One valuable report that marketers often rely on is the “Hot Clicks Report,” which provides insights into recipient interactions, such as email clicks. The report is included with the Adobe Campaign Classic installation, and you can simply […]

Continue reading