From 294aa0bf24f6d05cb85bdaad8ffb8989928ff6c4 Mon Sep 17 00:00:00 2001 From: Radoslav Georgiev Date: Wed, 6 Apr 2022 14:34:55 +0300 Subject: [PATCH] Add explicit sections for example services --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ead3737..7b6e2e2 100644 --- a/README.md +++ b/README.md @@ -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: