This topic tells you about the benefits, and design considerations for fragments.
A fragment is a partial accelerator. It can do the same transformations as an accelerator, but it cannot run on its own. It’s always part of the calling (host) accelerator.
Developing a fragment is useful in the following situations:
Developing and maintaining a fragment is complex. The following is a list of design considerations:
The fragment you develop must work with all possible syntax and format variations. For example, dependency in a Gradle
build.gradle.kts can have the following forms:
implementation(‘org.springframework.boot:spring-boot-starter’)
implementation("org.springframework.boot:spring-boot-starter")
implementation(group = "org.springframework.boot”, name= “spring-boot-starter")
implementation(group = ‘org.springframework.boot’, name= ‘spring-boot-starter’)
implementation(name= “spring-boot-starter", group = "org.springframework.boot”)
The fragment can be used in multiple accelerator contexts and its behavior must result in a compilable and deployable application skeleton.
When flexibly reusing fragments in different combinations, each fragment must cover a small, cohesive function. Fragments must follow these two UNIX principles:
Keep the files the fragment changes to a minimum. Only change the files that are related to the same technology stack for the same purpose.
Fragments are used by accelerator authors. VMware has found that the following guidelines keep fragments understandable and reusable.
Fragments might require the use of versioning. For example, if accelerator acc-1
imports fragment frag
, and accelerator acc-2
also uses fragment frag
, then care must be taken in the contract that the fragment exposes. Changing its behavior for the benefit of acc-1
might break its use in acc-2
.
To resolve this, you can track the versions of the fragment and document with numbers when there is an incompatible change. VMware recommends that you use semantic versioning to track the contract for fragments.
To give you more flexibility with version control, Application Accelerator does not manage versioning. VMware recommends that you track the semantic version of fragments in the fragment name. For example, if fragment frag
changes its contract in a way that is not compatible with previous accelerators that use it, it becomes frag-v2
and is regarded as a different fragment.
You can store fragment versions where you want, but version control systems such as Git are a good choice.