Skip to main content

Learning Session #5


1. npm / yarn

Yarn is a package manager for JavaScript libraries and an alternative to npm. I’ve been using yarn from quite some time and I’m satisfied with it, especially when comes to installation times (in contrast to npm).

This article highlights a problem of duplicated bundles in your project, which can occur inside of your project from time to time. This leads to an oversized project’s dependencies.

Sergio is also an author of the yarn-deduplicate package which analyses your yarn.lock and removes duplicates. As a fan of every type of optimization – thank you for your work, Sergio!

This is a great presentation I found, where the author shares his experiences in creating performant web applications.

What caught my eye:

- Using the right business methodology for your project is a key to success,
- Using the right tools is as important. With them, we can check if our project isn’t too big, how big it should be, how big individual modules are, etc.
- Share your knowledge and successes inside your team!

This article introduces basic tools for writing clean code (mostly for JavaScript projects). I personally use some of them too. Now I can’t imagine working on a project without ESLint or TSLint!.

(In fact, when writing this I realized that creatia ng list of useful tools for creating clean and performant apps is a great idea for a separate article! I might just use this idea the in nearby future 😊)

2. Java

This Is only a part of a great “Testing with Spring Boots” series of articles created by Tom. I mentioned this one because this is the part I started from.

Frankly, I wasn’t always sure if testing controllers in Spring is possible or if it even makes sense. This article changed my mind and presented me with reasons and examples of why and how to implement such tests. It is even easier for us to create such integration tests because Spring provides us with tools.

I highly recommend reading all articles from the “Testing with Spring Boot” series!

Article covers the implementation of audits on Spring entities using three methods. Methods varies and are different in the complexity of implementation and flexibility.
After reading this article you will surely find something to suit your needs!

3. TypeScript / JavaScript

>> Creating types for existing JS library

Recently at work, we’ve started working with external JS library and had to integrate it with our TypeScirpt/Angular codebase. For that, I started implementing types based on the library’s documentation.

It was more fun that I initially thought it would be! Maybe because I wasn’t doing anything like this previously…

There was two things I learned during this task:

- How to implement a type for the constructor:
- There are a lot of differences between using types and interfaces in TypeScript. I basically was using a strategy: if I wanted generic and/or extendable functionality I used interfaces. In all other cases, I was using types.


Here I found a thorough explanation of how to implement “Copy to Clipboard” functionality in JS. There are basically 3 ways and they are basically as good as the other, but they differ in browser compatibility. I personally used document.execCommand(‘copy’) option, because it worked well under IE11.

When using TypeScript I always used if (object.property) doSth(); syntax to check whether a property holds truthy value. Nothing is wrong with that of course, but it didn’t work in the one particular case.

Recently I made a mistake by assuming, that code above would also check whether the property of such name exists on object altogether. Well, wrong. In that case, JS engine would throw ReferenceError, because we are referring non-existing property.

For that to work, we need another condition and it is explained by Flavio in his article.

>> Creating and exporting large text files [ 1 ] [ 2 ]

Here I present two simple solutions that, when combined, let you generate and download pretty big text files (like CSV). With that solution, I’ve been able to asynchronously generate CSV file for 1.5mln objects served from my backend. That’s neat!

4. Other

Here Mark lists his tips for creating better pull requests. I believe that implementing those simple rules in every team would make every team member’s life easier. I speak from experience, because I value readability when doing code reviews and make sure that my PRs are simple to review.

That's the end for today. In the end, I just want to share something small, but exciting. I was able to create my first pull request on public GitHub repo and got it merged! It may have been just two lines of changes, but everyone must start from something, right? 😋

Comments

Popular posts from this blog

How I started with Functional Programming

There was a moment during past Learning Sessions when I declared, that I’ll share with you how and why I decided to dive into Functional Programming. And that day is today! I’ll guide you along the path I took to understand basic concepts of FP. My first meaningful encounter with FP was during local WrocÅ‚aw TypeScript meetup . There I got to hear Józef Flakus telling us about core concepts of the FP. We then got to the concept of FRP and how it is used in MarbleJS, the framework for creating server-side apps. In fact, Józef is the creator of this framework. It was really cool to hear his point of view. Those concepts were entirely new to me, because (as it turned out) I had 100% imperative programming mindset. The second talk that day was authored by Tomasz Ducin. He showed us how we can implement functional composition in TypeScript. It was a brilliant live coding session but… I had no idea what he was talking about 😉 I was examining code created by Tomasz for the entire ...

Learning Session #10

1. Functional Programming Basically all content surrounding FP this time is connected with articles and projects created by Giulio Canti ( @giuliocanti ). For me reading those articles below definitely firmed and expanded my previous knowledge on FP. I would like to give credit to Piotr ( @hasparus ) who introduced me to Giulio’s work after the last WrocÅ‚aw TypeScript meetup. It was genuinely fascinating, thank you both! >> “fp-ts” library  I think fp-ts today is as famous for TypeScript as Rambda for JavaScript. With it, you can use “popular patterns and abstractions available in most functional languages”. If you are a newbie to FP (like me) and you know TypeScript it may be a good way to get your head around FP concepts through practice. Just play with it a little, create something small, something you know. >> “Getting started with fp-ts” series Aside from fp-ts having a well written official guide, Giulio created a series of articles, that introduce...

Learning Session #2 (12/31 – 01/13)

1. Git >> Free and (almost) unlimited private repositories on GitHub Last week everyone on Twitter was talking about this so I can't just leave that be, right? 😉 What I’m referring to is GitHub announcing free and unlimited private repositories for all users. That’s a great news and I was wondering why this option was not enabled from day one I started using GitHub. I mentioned that this option is “almost” unlimited because free private repository can manage up to three collaborators only. Big projects won’t be able to use those, but at least individual users can now freely hide code they consider shameful 😉 2. React >> React Crash Course by Mosh Hamedani During last two weeks I’ve completed this YouTube crash course by Mosh Hamedani. It is derived from his full course on React and contains first couple of lessons. It think it was a great introduction to the library itself (React is a considered a library, not a framework, isn’t it? 😊). Tutorial ends ...