Notes on Generic Programming - III: Generative Programmingc: Sep 20, 2021
Product line Engineering
A configurable software
A configurable software has different options that allow its users to chose variations from these options according to their requirements. The end result is a unique tailored binary that is customized to meet the demands of the given user. If everything is built into a single binary, it creates bloated features that may not constrain users’ requirements. Therefore, configurable software allows users to design products that are tailored to their needs.
Example: Linux kernel, Apache spark, etc.
Goals of configurable software:
- Should offer several/configuration options/
- Should allow stakeholders to select options
- Should create a tailor-made system variant
Therefore, configurable software is something that a software product line instead of just being software.
Software product line
Definition of Software pipeline:
- Built from a common set of core features
- Should satisfy the demands of the domains or market segment it is designed for.
Key abstraction of application domain Finds the specific part that is important for the user to change or adapt.
Represents commonalities and variability A switch that can enable a specific part of the software. It can be some isolated codes if selected properly create different software.
Means of communication Documentation and default values. The system can specify some values and should be able to reason about these values. The stakeholders can then try suggestions or come up with their own version.
Means to specify product variants Since features can be enabled or disabled, these can allow us to distinguish different product variants.
In some situations, users can easily understand a feature while in other situations they may not. These features irrelevant to users can come up as implicit requirements based on user choice. For example, to enable X, the user should enable Y before using X.
- Collect, organize, and store past user experiences when building systems for a particular domain. This can be from development or looking at existing systems.
- Another way to learn about a domain is by deeply analyzing the given domain.
- Should satisfy the requirements for stakeholders in that given domain.
- Can start with the most common and required feature in that domain and build upon these features.
- Should facilitate reuse of assets when building new systems.
- It focuses on two things
- Feature model: Represents design feature space and connections on how these features are dependent upon each other.
- Reusable Design: Design isolated and reusable components that can be part of something big. Should be extensible.
- Feature selection: User selects the features from available configurations based on their requirements.
- Variant generation: Based on the selected features, the system uses the reusable design and fetches program and combines them to produce a specific software variant
A software pipeline provides means to communicate with users in situations when configurations don’t fit together. The pipeline should notify the user when their configuration does not match or are incompatible.
- This area means to describe different features for a given system.
- Allows ways to provide a dependency relationship among these features.
- Can also define constraints.
- Propositional formulas
- These are a formal and machine-readable representation of features.
- These allow automating the feature space and prevents enabling of some feature based on the constraints.
- Aren’t easily readable without formal knowledge
- Feature diagrams
- These are informal graphical models that are easily readable by humans.
Some common symbols are:
- Filled circle: Mandatory feature.
- Unfilled circle: Optional feature
- XOR group: Represented by unfilled arch. This means exactly one feature should be allowed.
- OR group: Represented by filled arch. Means at least 1 should be allowed.
- Inner nodes represent abstract features
- Leaves represent concrete features.
- These are informal graphical models that are easily readable by humans. Some common symbols are:
Purpose of Domain analysis
- Select and define the domain of focus
- Explore different parts of the domain.
- Can be flexible
- Collect relevant information and combine it to the domain model
- Represents common properties.
- Represents variable properties
- Help understand the domain boundary and dependencies between the variable properties.
Focuses on the following properties.
Domain definition: Without clear boundaries, it will be difficult to incorporate the software into different domains.
Domain lexicon: Defines the most occurring vocabulary in the domain. These are the specifics and jargon of the domain.
Concept model: Understand the formal relationship among the higher order of abstraction.
Feature models: Understand the relationship among available features.
Domain scoping: Understand stakeholders and goals of stakeholders.
The clear domain analysis allows us to design a software pipeline that can be tailored to users in the given domain.
Feature Binding Time
Features can be enabled during different phases of software production and deployment.
Compile time features:
- These are features decided in compile time.
- As a result, they are responsible for producing different software variants.
- These are features that are baked into the program.
- Are highly adaptable to execution of the program.
- Can be selected interactively or automatically.
- These are configuration files and binding files that are loaded when program execution starts.
- Depending on the configuration, the program will change its state and enable/disable features depending on the configuration.
Features can be bound differently.
Static binding: These call specific methods as per intention. Therefore introduce rigidity where it doesn’t allow features to be rebound.
Dynamic binding: These are features bound before use and unbound after use. A virtual polymorphic class can represent some of the ideas. Another way is using function pointers.
Changeable binding: Features are bound between uses but have options to unbind them.
Depending on the feature binding time and bounding mode, we can drive our design to perform different things.
Variant Generation Methods
- Internal generators
- These use the language tools or internal DSLs to generate the required part of software code.
- External Generators
- Can be external programs or application that generates code.
- Allows combination with external DSLs.
- Build Systems
- These provide options to select different pieces during the compile-time and configuration option.
- Are usable with other generator methods.
- Understand the basic requirements of the software.
- Find the common parts of the programs and the common process that links these parts.
- Allow for options to control different items required in the process.
- Create an abstraction that helps to interconnect generated code with normal code.
- Internal generators are useful when we are constrained to host language and provide ways to create generators.
- Sometimes build system can be used to enable or disable the flags.
Generative Domain Model
Handling optional features.
Throw runtime error when the unwanted item is processed.
- Reduces the amount of compile-time features.
- To this, we may require a runtime switch.
Check the requirements during compile time. This is simple to implement and to understand. The side effect user can implement the features but these are not able to compile the program.
We can remove the code related to unwanted features during the compile time. Removing all the parts of the program that aren’t unnecessary forces users to work with only available features. However, this idea is difficult to maintain and should be a design consideration.
Generative Domain models.
- Generative Programming
Automate manufacture of intermediate and end products.
- Problem space ( Domain-specific concepts )
- Define and encode the constraints and invalid features.
- Define optimization and construction rules.
- Define dependencies of the software. For example, if certain features (eg. NTFS) are disabled, we can remove the parts that are used to process (eg. Read/write on NTFS type) these features.
- Elements can be combined and removes duplication (minimum dependency)
- Understand the domain and build software that allows enabling/disabling features without worrying about breaking the system.
Allows tailoring the experience per customer and per their requirements which can improve the relationship.
Dimension of concepts and product line such that it works for different stakeholders and their requirements. Another dimension is about how these are implemented i.e how to engineer them without compromising the design and modularity.