Software Engineering
Subscription.status={"active", "canceled"}
Enter fullscreen mode
Exit fullscreen mode
A single field tells us in plain language what the status of the object is by using enums instead of booleans. Another upside is the extensibility and future-proofing that this technique gives us. If we go back to our previous example of adding a “pause” mechanic,... See more
Enter fullscreen mode
Exit fullscreen mode
A single field tells us in plain language what the status of the object is by using enums instead of booleans. Another upside is the extensibility and future-proofing that this technique gives us. If we go back to our previous example of adding a “pause” mechanic,... See more
Common Design Patterns at Stripe
How to build this skill:
- Maximize what you can do on your own: by ruthlessly prioritizing your time, pushing back on activities that have small ROI, and focusing on areas where your input is crucial; for engineers, it often means less coding (if more junior people can do that piece of coding).
- How you can maximize what you can do through others:
3 Critical Skills You Need to Grow Beyond Senior Levels in Engineering
But now we are only logging that error message. It would be better to define a custom Exception that we can then handle in our API in order to return a specific error code to the user:
import pandas as pd
import logging
class DataLoadError(Exception):
"""Exception raised when the data cannot be loaded."""
def __init__(self, message="Data could not be... See more
import pandas as pd
import logging
class DataLoadError(Exception):
"""Exception raised when the data cannot be loaded."""
def __init__(self, message="Data could not be... See more
How to Write Clean Code in Python
And then, in the primary function of your API:
try:
df = load_data('path/to/data.csv')
# Further processing and model prediction
except DataLoadError as e:
# Return a response to the user with the error message
# For example: return Response({"error": str(e)}, status=400)factory_boy
factory_boy is a fixtures replacement based on thoughtbot's factory_bot.
As a fixtures replacement tool, it aims to replace static, hard to maintain fixtures with easy-to-use factories for complex objects.
Instead of building an exhaustive test setup with every possible combination of corner cases, factory_boy allows you to use objects... See more
factory_boy is a fixtures replacement based on thoughtbot's factory_bot.
As a fixtures replacement tool, it aims to replace static, hard to maintain fixtures with easy-to-use factories for complex objects.
Instead of building an exhaustive test setup with every possible combination of corner cases, factory_boy allows you to use objects... See more
FactoryBoy • GitHub - FactoryBoy/factory_boy: A test fixtures replacement for Python
- Tornado is a Python web framework and asynchronous networking library designed for handling long-lived network connections. It is built to be non-blocking and uses an event loop to manage all operations. While Tornado itself does not rely on a thread pool for its core operations, it provides interfaces for integrating with thread pools (e.g.,
Saverio Mazza • FastAPI: Thread Pool and Event Loop
Each log message in the system should be unique.
If I query for a log in a specfic service, I will be confused to see the exact same logs at different flows inside the service.
More than that, I’ll just have to start debugging for the issue, since the logs are now offically useless.
One way to keep the logs unique is to denote the service name and... See more
If I query for a log in a specfic service, I will be confused to see the exact same logs at different flows inside the service.
More than that, I’ll just have to start debugging for the issue, since the logs are now offically useless.
One way to keep the logs unique is to denote the service name and... See more
Logging practices I follow
Problem : Tight coupling leads to fragility - a change in one microservice breaks connected services.
Low cohesion results in unclear responsibilities.
Low cohesion results in unclear responsibilities.
- Solution : Apply loose coupling and high cohesion. In a loosely coupled system, each component is independent and changes in one will not affect the others. High cohesion means that each component
Muaath Bin Ali • Microservices Design Principles
We ship often
Shipping early is not enough. We also need to keep shipping tiny iterations daily instead of waiting months to ship something big.
Having a strong sense of urgency , and making hard decisions fast is how we enable that process. Our sprints only last 1 week and are quite short when compared to the rest of the industry - this is by... See more
Shipping early is not enough. We also need to keep shipping tiny iterations daily instead of waiting months to ship something big.
Having a strong sense of urgency , and making hard decisions fast is how we enable that process. Our sprints only last 1 week and are quite short when compared to the rest of the industry - this is by... See more
How we ship new features · Resend
When a test fails, you should be able to begin investigation with nothing more than the test’s name and its failure messages —no need to add more information and rerun the test.
Effective use of unit test frameworks and assertion libraries (JUnit, Truth, pytest, GoogleTest, etc.) serves two important purposes. Firstly, the more precisely we express... See more
Effective use of unit test frameworks and assertion libraries (JUnit, Truth, pytest, GoogleTest, etc.) serves two important purposes. Firstly, the more precisely we express... See more