mirror of
https://github.com/HackSoftware/Django-Styleguide.git
synced 2024-11-25 19:13:45 +03:00
Add explicit sections for example services
This commit is contained in:
parent
be20a60cb0
commit
294aa0bf24
|
@ -27,6 +27,8 @@
|
|||
* [Methods](#methods)
|
||||
* [Testing](#testing)
|
||||
- [Services](#services)
|
||||
* [Example - function-based service](#example---function-based-service)
|
||||
* [Example - class-based service](#example---class-based-service)
|
||||
* [Naming convention](#naming-convention)
|
||||
* [Modules](#modules)
|
||||
* [Selectors](#selectors)
|
||||
|
@ -494,6 +496,8 @@ In most cases, a service can be simple function that:
|
|||
- Interacts with the database, other resources & other parts of your system.
|
||||
- Does business logic - from simple model creation to complex cross-cutting concerns, to calling external services & tasks.
|
||||
|
||||
### Example - function-based service
|
||||
|
||||
An example service that creates a user:
|
||||
|
||||
```python
|
||||
|
@ -516,6 +520,8 @@ As you can see, this service calls 2 other services - `profile_create` and `conf
|
|||
|
||||
In this example, everything related to the user creation is in one place and can be traced.
|
||||
|
||||
### Example - class-based service
|
||||
|
||||
**Additionally, we can have "class-based" services**, which is a fancy way of saying - wrap the logic in a class.
|
||||
|
||||
Here's an example, taken straight from the [Django Styleguide Example](https://github.com/HackSoftware/Django-Styleguide-Example/blob/master/styleguide_example/files/services.py#L22), related to file upload:
|
||||
|
|
Loading…
Reference in New Issue
Block a user