Here's a list of topics and resources to use the next time you have a little down-time. Applying these skills will help you write more maintainable code. Over time you will also gain a reputation for being the kind of developer people turn to when they have a thorny problem to solve.
Functional Programming Basics
Functional Programming is a vast subject, but you can start to see benefits from the understanding of a single concept: Pure Functions. Let's start with a simple definition 👇
This next video👇explains how to use it in your software.
Note: He refers to pure-functions as "calculations" and side-effects as "actions", so keep that in mind.
You will only learn by doing, so if you'd like to practice:
- Go through your current code-base
- Look for a Function where the side-effects and business-logic are mixed together
- ideally you already understand the details of the function really well
- Separate out the Business Logic into a Pure-Function with just the "Calculations", and keep it separate from your side-effects.
- Ensure your application still works.
If you would like an example, here's code for an example ShoppingCart Class where you can add items and a discount is calculated before checkout:
Why would you want to do this though.
- Most bugs tend to be in the Business Logic
- If a Function or a Class logs to a DB or sends an email every time it's run, it becomes harder to test properly.
- If you can extract a Calculation into a Pure Function, it becomes easier to run.
- The easier it becomes to run, the easier it is to fix bugs.
- You can even write unit-tests for your Pure-Functions and run them automatically on every change, making it easier to catch regressions.
Next Steps
There's a few other skills I think make it easier to work with old code, I'm going to add those in shortly:
- TDD, for better-quality pure-functions
- C4 Architecture Diagrams, for standardized documentation
- Sequence Flow Diagrams in Mermaid, to get quicker feedback on code
- Trunk Based Development, to reduce operational overhead for small teams
- CodeScene, to manage the health of a codebase and pay-down tech-debt
- Approval Testing, when the original devs on a project aren't available
Leave me a comment or DM me on Twitter if you have any specific requests or questions.
Top comments (0)