Last month I've rewritten some tests in one component. Here is result:
before:
290 tests in cypress (time 06:01)
177 tests in jest (time 23.762s)
= 6:25
after:
154 tests in cypress (time 03:47)
249 tests in jest (time 32.685 s)
= 4:20
#it #programming #softwareEngineering #software #javascript
Posts by Marek Szkudelski
React v19 is finally out with some interesting new hooks.
Balancing Don't Repeat Yourself (DRY) and Single Responsibility Principle (SRP) can be tricky.
Should you merge similar code for DRY or keep it separate for SRP?
Discover insights from my Allegro experience in this blog post:
#it #programming #code #softwareEngineering
Ho Ho Ho 🎅🛷🎄
Domain Driven Design for Frontend Devs - Advent Calendar
Starting 1st Dec,
Each day,
Around 10am CET
a portion of distilled knowledge on practicing #DDDesign
Let your frontend teammates know
Spread the word - thank you 😘
#DDD #aDDDvent
For example, consider a function saveUser that returns a boolean indicating success. Its description might be: “It saves a user to the database and returns the status.” Everything after "and" shouldn't belong in the function.
Want more Clean Code tips? ➡️ Follow me! 🔔
Separating responsibilities simplifies your code, and simplicity always wins. This makes your code easier to read, test, and maintain. 🧩
Ask yourself: can you describe what your function does in one sentence, without using “and also”? If not, it’s time to simplify. Less is more in clean code. 💡
Error handling is a separate responsibility, and a function should do exactly one thing.
That’s why it’s worth moving try/catch blocks into separate functions.
❇️ The "main path" of your code stays clean, focusing on the function's goal.
❇️ Error handling is clear, separate from business logic. 🛠️
Why? Because a returned false or an error code can easily be overlooked. All it takes is someone forgetting to check the return value – and even the best developers make that mistake. 🆘
An exception, on the other hand, cannot be ignored – it will stop the program and clearly indicate the problem. ⚠️
A function that does something shouldn’t return anything. No true or false, no error codes. If something goes wrong – throw an exception.
#CleanCode #Programming #SoftwareEngineering #Code
For example, add aliases for git add, commit and push. It'll speed up your work already.
If you'd like to start with my config, you can fork my repo and change only aliases.txt file and setup zsh.
Or you can start configuring by yourself :)
You can use only someone else's (for example my ;) ) configuration and add your own aliases.
You could also start from a few most common command you use on daily basis. Adapt them and then think about adding more.
Terminal aliases have been a cornerstone of my productivity for years, especially for tasks like Git or npm commands.
Let me share some insights and tips! 🧵
For example, instead of typing:
git commit -m, I use gc.
git checkout -b becomes gcb.
(link for config instruction below)
#programming #it
The flavor of code syntax you personally prefer to use doesn't matter. What matters is having a single, consistent approach across all devs working on a project.
Totally agreed! I prefer using eslint/prettier with pre-commit hook to ensure that code on remote repo is consistent.
50 shades of gray :) Sometimes there is sun, but I work then.
When my kids will grow up a little bit I plan to go somewhere warm every fall/winter.
yeah, in spring or summer :) Or in deep winter when it's snowing ;)
Come to Poland and try to find sun in November :)
Nice :) I wish I have such discipline to do so. But I use commit amend a lot to avoid commits like "fix typo". Sometimes I use cherry pick to split Pull Request into smaller ones.
Ok, I'll check that. Thanks for help!
I don't but I've been thinking about it lately. I plan to add time-blocks to my calendar just for myself to focus on current task. I believe it could be useful in time I have multiple project/tasks to tackle with.
I tried to use your app, but I've got "Profile not found". Is it because my custom handle?
I've heard Raycast is great, but unfortunately I can't install that software on my work laptop :/ But I use some custom basic snippets in my IDE. For example, for creating component.
The repository includes a step-by-step guide to help you configure and create your own aliases effortlessly. Start saving time and streamline your workflow—you’ll thank yourself! 😊
What about portability?
I sync all my aliases between personal and work devices using a remote repository: github.com/mszkudelski/...
This ensures I can apply updates across devices with a single terminal command.
I also use combinations like:
gch master (switch to master branch)
gpl (pull the latest changes)
gch - (return to the previous branch)
gr - (rebase changes)
Together, these make keeping branches up to date seamless.
And here’s my favorite:
guc, which executes:
git add .; git commit --no-edit --amend; git push --force-with-lease
This command updates the latest commit with new changes and force-pushes it—ensuring I’ve synced (pulled) everything beforehand.
Terminal aliases have been a cornerstone of my productivity for years, especially for tasks like Git or npm commands.
Let me share some insights and tips! 🧵
For example, instead of typing:
git commit -m, I use gc.
git checkout -b becomes gcb.
(link for config instruction below)
#programming #it
So you use rebase and commit amend a lot?
Yep, some tests were duplicated and I removed them during this refactor. Or they just tested some not important aspect of feature which additionally was already tested by jest.
This refactor was about test optimization in general but also reviewing if every test is necessary.