Refactoring optional chaining
Dailygrind
by Sergio Martino
2y ago
Optional Chaining is a relatively new feature in ECMAScript and perhaps not a novelty in other languages such as Kotlin or Java. Simply put, it allows developers to safely reference properties and methods located deep into an object without incurring in an exception. const client = {}; console.log(client.details.address); // Uncaught TypeError: client.details is undefined console.log(client.details?.contacts?.mobileNumber); // undefined Optional chaining can also be applied to execute conditional function calls: client.portfolio?.calculatePortfolioValue?.(); // undefined You have almo ..read more
Visit website
Future proofing components within design systems
Dailygrind
by Sergio Martino
2y ago
When it comes to architecting web components within a design system, it is worth thinking about portability and future proofing. A design system should be able to evolve with the company’s offering and not be a product of technology hype or trend. A design system should therefore aim at being technology agnostic. With this in mind, some companies (ie: Microsoft Fluent UI) have implemented design systems as a foundation of html and css, along with their framework component implementation. Build for one platform or for all. Everything you need is here. (Microsoft, Fluent UI) As a framework fad ..read more
Visit website
A 2020 retrospective
Dailygrind
by Sergio Martino
3y ago
This past year has been a wild ride. Our communities have been through what has been one of the worst years in history, one that transformed how we live, work and socialise. Some of these changes are going to permanent and there is speculation that the impact of these straordinary events could transform society in a way and scale never seen before. With this in mind, I am grateful I have been able to continue doing my job in 2020, something I love to boot, and I am prepared to embrace/confront change in the upcoming year. So let’s review some of the things I found interesting during the year a ..read more
Visit website
A 2020 retrospective
Dailygrind
by Sergio Martino
3y ago
This past year has been a wild ride. Our communities have been through what has been one of the worst years in history, one that transformed how we live, work and socialise. Some of these changes are going to permanent and there is speculation that the impact of these straordinary events could transform society in a way and scale never seen before. With this in mind, I am grateful I have been able to continue doing my job in 2020, something I love to boot, and I am prepared to embrace/confront change in the upcoming year. So let’s review some of the things I found interesting during the year a ..read more
Visit website
Microfrontends: an expensive recipe for frontend applications
Dailygrind
by Sergio Martino
3y ago
Microfrontends is a new trend in the frontend world however, the idea of being able to compose an application out of other independent applications is not new. Previous experiences such as Java Portlets have not been very successful while other companies, such as Beamery or Spotify, have tried the Microfrontends path with mixed results. I would bet that the Spotify desktop client is among the top 25 most intricate uses of JavaScript in the world. — Mattias Petter Johansson (Spotify) Despite that success, we found our move to micro-frontends also created some new challenges for us. If you’re ..read more
Visit website
A simple validation model, leveraging discriminated unions
Dailygrind
by Sergio Martino
3y ago
Validation is a common part of web applications. Different patterns for validation apply at different application layers (ie: input, data model, network schemas) and types (ie: data, ranges or constraints, structure) with a common goal: making sure the data we deal with is correct and useful. In this article I will be exploring a simple pattern for data model validation in Typescript and how discrimnated unions can help structuring a validation object. The goal Let’s start from what we are trying to achieve: a pattern for validating data and a consumable feedback object: export function vali ..read more
Visit website
Decision making using a strategy
Dailygrind
by Sergio Martino
3y ago
Developing software through code mostly means applying well estabilished design patterns. This is no different then choosing the most popular recipe to cook a beef Wellington: You want to rely on battle-tested experience You want to make sure the process is streamlined You want to minimise disruption and the risk of failure You want guaranteed results Design patterns are recipe frameworks: problems that have already been solved successfully and efficiently in the past do not require a new solution. Design patterns in fact, are the foundation on top of which all software is built. I will not ..read more
Visit website
The case against Regular Expressions
Dailygrind
by Sergio Martino
3y ago
A regular expression is a sequence of symbols that defines a pattern. This pattern is then used to search for characters or combinations of characters within text. In its simplest form, regular expressions can provide a viable method for text matching and extraction, using a concise api (in the javascript world, it would be the RegExp api). Below is an example of how regular expressions can help on working with text: // constructor form new RegExp('https?://(www\\.)?youtube\\.com/(watch|playlist).*'); // literal form /https?://(www\\.)?youtube\\.com/(watch|playlist).*/; Looking at the abov ..read more
Visit website
State and reactivity in Vue
Dailygrind
by Sergio Martino
3y ago
In one of my previous articles, I mentioned how it is possible to design a simple state manager in Vue by using observable. The Observable API has been available in Vue since version 2 however, with version 3 the reactive object is no longer directly modified but proxied into. Let’s have a look how both work in detail: In Vue 2, a reactive store might look like this: // store.js export const store = Vue.observable({ orders: 0 }); We can provide the components with a basic dispatch function that will collect an action with a payload and that will take care of updating the state. Also, we mi ..read more
Visit website
Scraping news with Python
Dailygrind
by Sergio Martino
3y ago
In this article, I will explore how you can scrape a newspaper website and extract articles using python and the command line. In general, I would recommend python for everything that involves CLI for its excellent tooling. Let’s have a look at how this can be achieved using click (to install it you can pip install click), a python library that streamlines your work on the CLI: import click import importlib @click.command() @click.option("--scraper") def main(scraper): pass if __name__ == "__main__": main() Since every website is built differently in terms of html elements, we would want t ..read more
Visit website

Follow Dailygrind on FeedSpot

Continue with Google
Continue with Apple
OR