#Dev Guru – Devstyler.io https://devstyler.io News for developers from tech to lifestyle Wed, 23 Apr 2025 14:03:52 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 What Every Senior Front-End Developer Should Know About Advanced TypeScript Concepts https://devstyler.io/blog/2025/04/19/what-every-senior-front-end-developer-should-know-about-advanced-typescript-concepts/ Sat, 19 Apr 2025 11:25:52 +0000 https://devstyler.io/?p=128268 ...]]> TypeScript, a robust superset of JavaScript, adds static typing and advanced features that elevate the development experience.

While many developers have mastered the basics, senior developers should be well-versed in advanced TypeScript concepts to write more maintainable, scalable, and efficient code.

Below are seven advanced TypeScript concepts that every senior front-end developer should understand.

What Every Senior Front-End Developer Should Know About Advanced TypeScript Concepts

1. Union Types

Union types enable a variable to hold one of several specified types, providing the flexibility of dynamic data handling while preserving type safety. It’s akin to having a multi-functional tool that fits diverse scenarios.

Example:

More Real-World Example:

2. Intersection Types

Intersection types combine properties from multiple types, ensuring that a variable satisfies all the conditions. It’s a way to merge the identity of different entities, useful for designing more complex types.

Example:

In this scenario, a SuperAdmin type ensures that a user has both User and Admin properties.

3. Type Guards

Type guards act as validation checkpoints within code, allowing for safer type narrowing during runtime checks. These are like checkpoints that only let specific types through, enhancing security and accuracy.

Example:

4. Conditional Types

Conditional types provide powerful type transformations based on certain conditions. They enable dynamic type manipulation, similar to how logic gates control paths in circuits.

Example:

Conditional types allow developers to build types that adapt based on other types, leading to more expressive and flexible code.

5. Mapped Types

Mapped types transform existing types into new structures by iterating over each property, making it easier to implement type-wide modifications.

Example:

6. Template Literal Types

Template literal types use string literals to create new types, providing a way to enforce naming conventions or combine string patterns for type safety.

Example:

These types make your type definitions more expressive, offering clearer guidelines for code patterns.

7. Recursive Types

Recursive types are crucial for representing complex data structures like trees, linked lists, or deeply nested objects. They allow types to refer to themselves, providing a way to model data structures that are inherently recursive.

Example:

Recursive types are like building blocks that enable you to model structures as intricate as a family tree or a file directory.

Conclusion

Advanced TypeScript concepts such as union types, intersection types, type guards, conditional types, mapped types, template literal types, and recursive types are essential tools in a senior developer’s toolkit. Mastering these features ensures that your code is type-safe, concise, and scalable, setting a strong foundation for complex application development.

Material provided by: Kristiyan Velkov

Photo by Austin Distel on Unsplash


Kristiyan Velkov, Contributor at DevStyleR, is with over 10 years of experience in JavaScript and open-source development. He has honed his skills in tools like React.jsAngularVue.js, and Next.js. He also dive deep into DevOpsweb accessibility, and security—because great code is about more than just functionality!

LinkedIn         X

]]>
What is Virtual DOM in React.js https://devstyler.io/blog/2025/03/14/what-is-virtual-dom-in-react-js/ Fri, 14 Mar 2025 07:00:35 +0000 https://devstyler.io/?p=127081 ...]]> The virtual DOM is a lightweight copy of the real DOM that allows React to manage changes more efficiently by minimizing the direct manipulation required on the real DOM.

The virtual DOM is a programming concept where an ideal, or “virtual”, representation of a UI is kept in memory and synced with the “real” DOM by a library such as ReactDOM. This process is called reconciliation.

This process significantly enhances the performance of web apps.

Understanding the virtual DOM is essential for developers who want to get the best out of React. It plays a key role in how React updates the UI, ensuring that changes are applied quickly without unnecessary re-renders.

What Is the Virtual DOM and How Does It Work?

The virtual DOM is an in-memory representation of the real DOM elements.

Instead of interacting directly with the real DOM, which can be slow and costly in terms of performance, React creates a virtual representation of the UI components.

This virtual representation is a lightweight JavaScript object that mirrors the structure of the real DOM.

Here’s a step-by-step process of how the virtual DOM works:

Understanding React’s Rendering and Update Lifecycle

Step 1: Initial Rendering (Virtual DOM Creation)
When the app starts, React builds the entire UI as a Virtual DOM, a lightweight JavaScript representation of the real DOM.

Step 2: Reacting to State and Props Changes
As the app runs, any changes in state or props trigger a re-render of the affected components. React updates the Virtual DOM to reflect these changes, without immediately modifying the real DOM.

Step 3: Diffing Algorithm — Spotting the Differences
React employs a highly efficient diffing algorithm to compare the updated Virtual DOM with its previous version. This comparison identifies only the changes, or “diffs,” between the two versions.

Step 4: Reconciliation — Deciding What to Update
Based on the identified differences, React determines the most efficient way to update the real DOM. Rather than re-rendering the entire UI, React targets only the specific parts that need updating.

Step 5: Applying Updates to the Real DOM
Finally, React updates the real DOM to match the Virtual DOM.

For example, let’s say we have the following counter functionality in the App component:

The virtual DOM representation will look like this:

When the Increase button is clicked once, only the h1 element is changed:

Comparing the Virtual DOM to the Real DOM

The real DOM is a built-in standard interface in browsers that represents and interacts with HTML elements, from Doctype declaration and the root html element to every other element in it.

This real DOM represents the whole HTML document as a tree structure and allows JavaScript to manipulate and change HTML documents.

Sometimes when those changes occur, the whole document might re-render.

This is in contrast to the virtual DOM, which uses a diff algorithm to compare the current and previous versions of updates to the DOM. It only re-renders the parts of the UI that have changed, instead of the whole thing.

Conclusion

The Virtual DOM is one of React’s core features, designed to enhance performance and ensure efficient UI updates. By leveraging the Virtual DOM, React can batch updates, reduce the frequency of expensive reflows and repaints, and apply changes with precision. This streamlined process results in faster, smoother UI updates, significantly improving the overall user experience.

Images and material provided by: Kristiyan Velkov


Kristiyan Velkov, Contributor at DevStyleR, is with over 10 years of experience in JavaScript and open-source development. He has honed his skills in tools like React.jsAngularVue.js, and Next.js. He also dive deep into DevOpsweb accessibility, and security—because great code is about more than just functionality!

LinkedIn         X

]]>
Microsoft entering the Java ecosystem is a game changer https://devstyler.io/blog/2021/01/29/microsoft-entering-the-java-ecosystem-is-a-game-changer/ Fri, 29 Jan 2021 18:02:33 +0000 https://devstyler.io/?p=39508 ...]]> Reza Rahman is Principal Program Manager for Java on Azure at Microsoft. Reza has over a decade of experience with technology leadership, enterprise architecture and consulting. He has been working with Java EE technology since its inception, developing on almost every major application platform ranging from Tomcat to JBoss, GlassFish, WebSphere and WebLogic. Reza has developed enterprise systems for well-known companies like eBay, Motorola, Comcast, Nokia, Prudential, Guardian Life, USAA, Independence Blue Cross, Anthem, CapitalOne and AAA using Java EE and Spring. He was also one of the speakers on the Java2Days and CodeMonsters conferences in December.

Mr. Rahman, you are a frequent attendee of the conferences.

Yes, I was a keynote speaker in the first conference many years ago. I think it was 2009. I’ve tried to attend all of them, but obviously it hasn’t always been possible because of scheduling reasons. But I have attended the vast majority of Java2Days.

Back then you had to travel to the conferences, but now it’s all online, so I guess it’s easier to attend more conferences.

Sort of. Speaking at conferences is not my day job, I do it of a sense of community and helping getting the word out and the work that I’m doing on Jakarta EE. Honestly it was a pleasure visiting Sofia every now and then. When I first visited the Bulgarian capital it was an eye opening experience. I had been to Moscow and Russia before, so I had an idea of what to expect. But Moscow is very different. To me it was an amazing experience. So many young people ready to embrace the future and the world. The tech community and the young people there and also the culture and heritage of Bulgaria to me was very impressive. You guys have very strong sense of who you are as people. So I look forward to visiting Sofia once again.

So you are one of the main guys of this conference and a favorite to the audience. What do you think of the first virtual edition of Java2Days and CodeMonsters?

I think it all went pretty well and I’m really glad that the organizers decided to have it. The attendance was very good. For me it really speaks to the tenacity that you had the conference even despite the challenges and in fact people are attending and they are paying attention. Honestly it’s really great and encouraging that you’re not “oh, we have the pandemic so lets take it easy”.

The learning experience is really good, but I want to ask you what about the networking that is really important for the developers attending a conference?

In essence for me the experience was not very different. I’ve been a virtual worker for a very long time so to me working virtually comes really naturally. My colleagues have always been people that I’m speaking remotely to via Zoom, Google, Twitter, Slack and etc. The same is with the developers community. I’m working either on the Jakarta space or the open source space with people all over the world – India, China, Greece, UK, USA and etc. You name it, right? So in that sense it’s not been different at all, it’s been the same. Of course it would be nice to go to a conference now and then to meet people in person, but to me I’ve even had more interactions with people virtually than I had in the past. So it’s all ok. The community is still engaged.

I read that you make sure that java developers are first class citizens in Microsoft and Microsoft is a first class citizen of the Java ecosystem. Even your lecture on the Java2Days conference was “How Microsoft learned to love Java”. So I’m getting the impression that Java is not that popular in Microsoft or at least it wasn’t for a long time.

Obviously not. Most of us know the history of Microsoft and Java back in the 90s and early 00s. Trying to create a basically incompatible implementation of Java and losing the lawsuit and going on creating this entire .NET and C# ecosystem that competes with Java and so on. We also know the battle between Linux and Windows. For those historical reasons Microsoft wasn’t really a very good friend of Linux or Java. It took some time and it took Satya Nadella to came in and begin to change the vision that is saying “ok, we’re no longer in our own little corner with Windows and .NET and all these VB and C#”. The new way of thinking is – we need to open up to the world. So Java was maybe the last major hold of it. Microsoft embraced Linux some years ago and also we embraced Python and JavaScript and all these technology out there. Java was really the last hold of it. So it began to work seriously in the past 5 years. Java in Azure is no older than 5 years. The reality is that we are doing more for Java developers as a result than any other public cloud out there. If you’re a Java developer and you come to Azure, you’re treated with much more seriousness and engagement than any other major cloud platform. The same goes to our partners – IBM, Oracle, VMware and etc. We’re trying to work very close with them because as a major cloud provider, we have to.

And what are the new trends in the Java ecosystem lately? Something new or some sort of improvement?

The Java ecosystem is always moving forward. Some people have been saying that Java is dead for 20 years, but that’s not the case, because we’re always moving forward. There are many different advancements at many different levels. Obviously Java EE used to be a vendor control technology for Oracle truly moving to open source and the Eclipse foundation and then moved forward and began to innovate in the Eclipse foundation. That’s a really big deal and most people are not talking about that enough but it’s significant part of opening up Java as a platform. That’s an interesting development. MicroProfile is an interesting development. To me it’s a way of moving Java EE developers forward while we are doing this complicated and challenging move of moving Java EE to open source and the Eclipse foundation. Also, Quarkus is getting more popular, Helidon, Micronaut. I think the Spring community is innovating here and there also, they’re trying to catch up with Graal, which is also a significant change in the Java ecosystem and IoT.  Interestingly I’m beginning to see a trend of people coming back to monolithic applications and architectures. To me this is like Back to the Future moment, because people realize that distributed systems are not for everything. Those are just some of the key trends. I think Microsoft entering the Java ecosystem and doing all these interesting work is also an interesting trend. People may not pay attention but this actually is game changer.

You have developed a lot of enterprise systems for major companies. What are the most important challenges in developing this kind of systems nowadays? For example one of the issues is the maintaining cost.

It’s always more or less the same. Enterprise moves very slowly. It’s a lot of legacy systems, people are trying to adopt new technologies here and there. It’s like window shopping – middle class person going on fifth avenue in New York looking at all the Gucci and other expensive brands. Of course, you don’t buy anything, you just look from outside the store and see all the interesting stuff. To me enterprise developers are sort of like that. On one hand you have to keep an eye of all of the interesting stuff and understand where you can apply them, but in reality you’re dealing with 5 or 10 years old legacy systems and you need to keep them up and running in efficient way. So it’s all the same challenges – scalability, reliability, maintenance, security and etc. These are day to day challenges in writing enterprise systems. Understanding requirements – this is a big one. People often underestimate. Enterprise challenges are not about the latest and coolest technology. They are much more boring, but maybe much more important and much more difficult.

]]>
Mani Sarkar: The community is forming again https://devstyler.io/blog/2021/01/25/mani-sarkar-the-community-is-forming-again/ Mon, 25 Jan 2021 10:51:47 +0000 https://devstyler.io/?p=38729 ...]]> Mani Sarkar – a passionate freelance software developer mainly in the Java / JVM space based in the United Kingdom. He is a Java Champion, Oracle Groundbreaker Ambassador, and a leader in the software development community. Mani Sarkar sees himself working in areas related to Java, Hotspot, GraalVM, Truffle, VMs, Performance Tuning, Data, and AI / ML / DL / NLP. Follow him on Twitter at @theNeomatrix369 and LinkedIn.

You are a passionate developer mainly in the Java and JVM space, can you briefly explain why you chose this topic for your lectures? What were your aims and expectations?

So, that’s a long story, I did not choose it. It automatically unfolded before me in the past so many years. Particularly for this event, it’s a Java-based event, so I had to speak about Java. I decided to come this year and contribute not just to Java, but also to be part of discussions. I was thinking of doing a talk but in a discussion as you know it’s an open field, you have all kinds of questions, and you can give all kinds of answers to those questions and many others will give different answers to the same questions. Collectively it’s a very useful forum. Every year I’m used to giving a talk on a specific topic, it’s just this year Java2Days was organised so quickly at such short notice. I did tell one of your colleagues that may be developers and speakers may not have a ready talk to present, in my case I would like to come out with a new talk. I am ok to do an “old talk” but then I would also want to present new things. I don’t do “repeat talks” that often. I have already done this a couple of times this year and it does not feel natural to me to do a repeat talk. If I do a talk it will be a new flavour of it and more advanced. I hope this answered your question.

And how do you feel during these virtual conversations? Did you get used to this? Do you miss the face-to-face interaction with the audience? What are the challenges and how are you coping with this pandemic situation? 

Good question. I work as a freelancer, and I work from home and almost all of my interactions with my clients in the last three years have been online. Because my clients are remote, they are based everywhere. Even if some of them are based in the UK or London they don’t have an office. The others are based outside of the UK and we don’t meet in person because you know it’s more practical to have a conference call and because of the changes that are happening since the beginning of this year for me it’s just a natural thing. I didn’t have to adjust much or change to anything new. The thing that has changed was that I used to go to the city to do meet-ups and events like conferences and things like what we are doing just now, and that has stopped massively in the last 9 months. That’s a big change. I like to meet new people, talk with them and interact with them because there is nothing like a face-to-face conversation. We can still have a few virtual conversations for practical reasons, but at the end of the day we will still want to meet people, have a coffee, have lunch or dinner or share something. Those are the things that we are missing, but maybe if virtual conferences and events are transformed we can bring in something like VR technology, where we can feel like the person we are talking with is next to us. I don’t know what are the possibilities and what are the good and not so good things about such technology but for now this feels different because I am used to meeting people at conferences. In the beginning conferences for me were more to go and attend the talk and learn. Eventually it became more networking and talking with people and that’s just gone away because I learn now by going online, I don’t have to go to an event, conference or meeting. But I don’t get to meet and interact with people – as soon as the webinar finishes everyone has logged off and off to do something else because everybody has other things and their agenda is so packed with work and there is no free time. So yes, it has changed quite a bit. I didn’t have to adjust to it but I noticed that I am missing these things and there are no replacements.

Yes, I totally agree.  And the most important thing is it seems that most of the people are actually ready to commit this and are accepting the “new virtual reality” as normal. What advice can you give to the audience how to cope with this? 

I am in a similar situation as everybody else, not in any special situation. The key part is to keep on doing what you are doing and do not get distracted, because there are so many distractions. Yes, it takes time and effort to get used to it. Yes, we want to meet other people but now the restrictions are a fact and we need to just work with them, not against them. Stay focused! This is a great time to do things that we couldn’t do before like reading a book. Stay away from the computer, because we are spending a lot of time with it. I am not doing myself this, as much as I am suggesting this to others but for everybody else who is not used to this I would say be more offline than online. Be online only if it’s necessary. There are a lot of offline activities that can disconnect you from the world even for a while. Thinking about the restrictions and the problems and what we are missing and what we do not have – all of these things are not making us feel good. Try to stay away from this. I keep myself very busy. I am involved in many things that I would like to achieve and get done for myself. In a way, this is a great situation for me because I am less bothered and distracted by the outside world, even though I still have to interact with it. But I have my own agenda, I maintain a “to-do list” both on paper and digital form. Keep yourself busy, keep yourself in check. For example my “to-do” list is like a check for me to see how well am I doing, how far am I with some of the things that I want to do. I am not thinking about the things that are happening around me that much even though I know they are there and when I go outside to do shopping or for a walk I see what is around me but when I finish the task and get back home I know that I am back to my routine and sometimes I am just resting. Have enough sleep! That is very important!

I know some of the Java2Days people don’t understand that. In the last few weeks you have probably not slept enough, very long hours. One of your colleagues said that she slept only between 4 am and 7 am. You are about to get out of this cycle soon, when the conference finishes. Don’t sleep for 3 hours, sleep for like 6-7 hours straight.

Yes, and eat healthily, stay calm, don’t panic, and try to stay undistracted by the things that are happening around us. If there is nothing to do, pick up a book to read, that’s the best I can recommend!

I truly thank you for your participation at the conference these three days. I hope we will be able to meet and discuss further topics in 2021 as well!

Yes, very much looking forward to it, please organise more conferences like this next year as well, because we still don’t know when we are going to be back to meeting face-to-face. So, if you want to keep yourself busy and organise another event like this in the next few months I will be more than happy to attend. Now you have all these different channels like Brella, Inevent, Zoom, etc so all of that is in place and you know how they work. The community is forming again, you can interact with them again as you have got like 2000 attendees this year! Normally, I used to come to Sofia and there were like 500-600 visitors per session*. I don’t know if you have ever had 1000 people.

Yes, the virtual world is helping us to unite so we are becoming more and more. 

Yes, and in a very short period of time, you have done very impressive work!

* Mani’s last conference was in 2014 

]]>