Python Forum
BEM Methodology: Class Compositions with Modifiers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BEM Methodology: Class Compositions with Modifiers
#1
Have you ever struggled with keeping your code modular and maintainable, especially when working on larger projects? If so, I want to introduce you to bempy, a Python library for building complex classes using the BEM (Block-Element-Modifier) methodology.

https://github.com/fefa4ka/bempy

With bempy, you can define Blocks, Elements, and Modifiers using simple and easy-to-use syntax. The library also supports inheritance and automatic documentation extraction, making it simple to understand and maintain large projects.

The BEM methodology encapsulates the appearance, logic, and content of a component into distinct Blocks, making it easy to reuse and modify without affecting the rest of the application. Each block can be combined with other blocks to create complex structures, making it easier for developers to collaborate on a project.
    blocks/
        myblocks/
            ComplexBlock/
                _mod/
                    minimal.py
                    cheap.py
                    extended.py
                __init__.py
You can export and build the block. To build a ComplexBlock with the minimal modificator, you can do:
from bempy.myblocks import ComplexBlock

MinimalComplexBlock = ComplexBlock(mod='minimal')
complex_instance = MinimalComplexBlock(
    basic_arg='hello',
    minimal_mod_arg='world'
)
In this example, MinimalComplexBlock = ComplexBlock(mod='minimal') is the construction of a complex class with the specified modificator. And MinimalComplexBlock(...) is creating an instance of the defined block.

Let me know your thoughts and experiences with bempy!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020