Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jorgechato/dsl-kata
DSL coding kata
https://github.com/jorgechato/dsl-kata
dsl kata public python
Last synced: 27 days ago
JSON representation
DSL coding kata
- Host: GitHub
- URL: https://github.com/jorgechato/dsl-kata
- Owner: jorgechato
- Created: 2018-11-10T07:35:59.000Z (about 6 years ago)
- Default Branch: 3-form
- Last Pushed: 2018-12-13T08:47:48.000Z (about 6 years ago)
- Last Synced: 2024-11-07T10:46:03.398Z (3 months ago)
- Topics: dsl, kata, public, python
- Language: Python
- Size: 86.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DSL Kata
Python solution uses a different approach because the language lacks a block syntax and multi-line lambdas.
Each of these objects is built inline using readable method names.This implementation overloads the operators `__str__` for operations on the text and range fields.
```python
print(
Form(
CharField(name="user", size="140", label="User Name"),
id="adidas-form",
)
)print("-"*5)
print(
Form(
CharField(name="user", size="140", label="User Name"),
PasswordField(label="Password"),
id="adidas-form",
)
)
``````html
User Name
-----
User Name
Password
```
## Run
```bash
$ python main.py
```## Strengths
- Single step for creating the request
- Easy to dynamically create criteria
- Operator overloading improves readability## Weaknesses
- Repetition of the class name
- Literal list used as argument## TL;DR
In general, there are 3 types of DSL implementations: `fluent interface`, `readable inline method arguments` and `blocks`.
Fluent interfaces is the most effective approach for the static languages.
For Python, readable inline method arguments seemed to be the most idiomatic.