# Extensibility

To stay "pluggable" the architecture must be highly "extensible". Consider the following recommendations while implementing an application:

* **Use classes for multi-part, complex feature implementations**. Classes allow isolating functionality under the shared context while splitting the functionality into logical functions. For example: React components, GraphQl query-builders.<br>
* **Use functions for single-purpose, isolated feature implementations** where context sharing is not required. For example request and data processors, utility functions.

To allow plugin nesting (stacking), the data-structures for class members and functions must be carefully chosen according to the following guidelines:

* **For a list of conditions resulting in different outcomes use maps or objects**. Try to avoid "if-else" or "switch" cases as they are tougher to read and extend.<br>
* **For a list of items dependant on order or "SortedList" utility** from `@scandipwa/framework/src/util/SortedMap`. Try to avoid objects as they do not guarantee the proper sorting of entries, and arrays as they do not expose a way to insert after or before a specific entry.<br>
* Try to **avoid returning complex values (objects of a class)** if possible. The common complex values are: React elements, GraphQl Fields. For example: instead of returning a wrapper with rendered items in it, consider splitting that logic into smaller parts:
  * wrapper rendering function
  * a function returning the array of items wrapped by a wrapper
  * a function for each wrapped item rendering

{% hint style="info" %}
Read more on Extensibility in the [documentation](https://docs.scandipwa.com/building-your-app/extensions).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://scandipwa.gitbook.io/shopify/architecture/extensibility.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
