The “Result Pattern” is a great way to improve not only the code flow, but also the developer experience for those who’ll work with your code down the line. No need to try/catch random errors and guess error codes, everything is typed and you know exactly what you want/need to handle. #javascript #typescript #developerexperience #designpatterns #softwaredevelopment
How to Improve Code Flow with Result Pattern in JavaScript
More Relevant Posts
-
In the upcoming Webiny v6, we’re rewriting a lot of internals, and the public API for extensions will be completey new. As we’re rewriting things, we’re taking the opportunity to improve the code base and DX for external teams but also for ourselves. This is just one example: the “Result Pattern”. Widely used in C#, proved to be a great pattern for managing and documenting a variety of potential errors that can be returned as a result of an operation. And not a single try/catch is necessary!! 🥳 #designpatterns #developerexperience #softwaredevelopment
The “Result Pattern” is a great way to improve not only the code flow, but also the developer experience for those who’ll work with your code down the line. No need to try/catch random errors and guess error codes, everything is typed and you know exactly what you want/need to handle. #javascript #typescript #developerexperience #designpatterns #softwaredevelopment
To view or add a comment, sign in
-
-
𝐈 𝐛𝐞𝐭 𝐲𝐨𝐮 𝐝𝐢𝐝𝐧’𝐭 𝐤𝐧𝐨𝐰 𝐭𝐡𝐢𝐬… . . . There’s a 30-𝐲𝐞𝐚𝐫-𝐨𝐥𝐝 𝐛𝐮𝐠 in JavaScript — and it’ll never be fixed. 𝐭𝐲𝐩𝐞𝐨𝐟 𝐧𝐮𝐥𝐥 === "𝐨𝐛𝐣𝐞𝐜𝐭"; // 𝐭𝐫𝐮𝐞 🤯 This is not a quirk — it’s a mistake. When JS was created in 1995, 𝐧𝐮𝐥𝐥 was stored as all 0’s in memory. Objects also used 0 as a type tag. So JS confused them. Now fixing it would break the web. 💀 #JavaScript #ProgrammingHistory #WebDev #JavaScript #WebDevelopment #ProgrammingHistory
To view or add a comment, sign in
-
Converting input type number by using parseInt or Number() function or using a plus operator for instance const num = +value. We can instead use the valueAsNumber property which gives the value as number type simple 🪄 Picture Credit: Steve Sewell 🙌 . . #javascript #javascriptTips
To view or add a comment, sign in
-
-
Favor functional components with Hooks. Cleaner syntax, easier logic, better readability. Class components are history. React Hooks changed everything. 🎣 #React #ReactHooks #FunctionalComponents #FrontendDevelopment #JavaScript
To view or add a comment, sign in
-
💻 Solving “Longest Common Prefix” on LeetCode (JavaScript Edition) Today I solved the “Longest Common Prefix” problem on LeetCode — a classic string challenge that’s simple on the surface but elegant when you find the right approach. 🧩 The challenge: Given an array of strings, return the longest prefix that’s common to all of them. Example: ["flower", "flow", "flight"] → "fl" ⚙️ My solution (JavaScript): Instead of checking every string one by one, I decided to sort the array first. This way, only the first and last words in sorted order need to be compared — because they’ll show the full range of differences in the array. 🧠 Why I like this approach: It’s clean and easy to reason about. Sorting reduces the comparison scope. It demonstrates how a small insight can simplify a problem significantly. 💬 Takeaway: Sometimes the most elegant solutions come from looking at the data differently — not from writing more code. #LeetCode #JavaScript #Coding #ProblemSolving #SoftwareEngineering #LearningJourney
To view or add a comment, sign in
-
-
Chain methods like pro - hence the secret behind `dot-dot-dot` magic! 🪄 Let's talk about method chaining in JavaScript, one of the cleanest tricks to write readable and expressive code! Day 11: Building a Chainable Calculator 🧮 🧠 Logic: 🔹 Each method (add, multiply, subtract) update the total. 🔹 All Functions returns "this", which provide the reference of same object. 🔹 By having reference, it allows the next method to be called on it directly. ✨ Result: Cleaner, more readable, and professional looking good also used widely libraries like jQuery & Lodash. #Javascript #InterviewPrep #100DaysOfCode #CodingChallenge #JavaScript #CodingInterview #JSChallenges
To view or add a comment, sign in
-
-
Today is Day 10, and I explored some of the most important function-related concepts in JavaScript: ✅ Pure Functions ✅ First-Class & Higher-Order Functions ✅ map(), filter(), and reduce() ✅ Argument Object & Rest Parameter ✅ Variable Scope (Global, Local, Block) ✅ Scope & Scope Chain ✅ Recursion & Closures #Day10 #JavaScript #FrontendDevelopment #100DaysOfCode #LearningInPublic
To view or add a comment, sign in
-
The JavaScript filter() method is a powerful way to create a new array containing only the elements that meet a certain condition. It goes through each item in the array and returns the ones that pass the test you provide. For example, to get all even numbers from an array: javascript const numbers = [1, 2, 3, 4, 5]; const evens = numbers.filter(num => num % 2 === 0); console.log(evens); // Output: [2, 4] Use filter() whenever you need to sift through data and extract only what’s relevant, making your code more declarative and concise! #JavaScript #WebDevelopment #CodingTips #ArrayMethods
To view or add a comment, sign in
-
🤔 What's the difference between 𝗺𝗮𝗽()and 𝗳𝗹𝗮𝘁𝗠𝗮𝗽() in #JavaScript? #map() transforms each element in an array and returns a new array with the same length. #flatMap() does the same but flattens nested arrays by one level, perfect for unwrapping results without extra .flat() calls! This makes your code shorter and more efficient for handling nested data. Which do you prefer using in your projects, and why? Share your thoughts! #CleanCodeSolutions #JavaScript #WebDevelopment #Fullstack
To view or add a comment, sign in
-
-
Dealing with "Empty Objects"? 🤔 Are you the type who prefers importing a library to handle basic utility tasks, without fully understanding the impact ? It's easy to take shortcuts, but it's important to weigh the pros and cons before adding external dependencies. #javascript #lodash #code #bundle #chunk
To view or add a comment, sign in
-
Explore related topics
- Code Design Strategies for Software Engineers
- Onboarding Flow Design Patterns
- Proven Patterns for Streamlining Code Updates
- How Software Engineers Identify Coding Patterns
- Patterns for Solving Coding Problems
- Maintaining Consistent Code Patterns in Projects
- How to Improve Technical Pattern Recognition and Code Reading Skills
- Coding Best Practices to Reduce Developer Mistakes
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development