<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Catalin Serafimescu on Medium]]></title>
        <description><![CDATA[Stories by Catalin Serafimescu on Medium]]></description>
        <link>https://medium.com/@catalinserafimescu?source=rss-f2fa4b41bcc4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*fFxwXDynlqi5ayjh</url>
            <title>Stories by Catalin Serafimescu on Medium</title>
            <link>https://medium.com/@catalinserafimescu?source=rss-f2fa4b41bcc4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:29:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@catalinserafimescu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Everyone has a take on AI coding. Here’s the one I actually work with]]></title>
            <link>https://medium.com/@catalinserafimescu/everyone-has-a-take-on-ai-coding-heres-the-one-i-actually-work-with-981763342645?source=rss-f2fa4b41bcc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/981763342645</guid>
            <dc:creator><![CDATA[Catalin Serafimescu]]></dc:creator>
            <pubDate>Sat, 16 May 2026 12:28:09 GMT</pubDate>
            <atom:updated>2026-05-16T12:28:09.404Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Not a methodology, not a manifesto — just the pipeline that keeps it from turning into a mess.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*axYU-3GRQAlGmvSKbJsBKw.png" /></figure><p>Everyone has an opinion about “AI coding” now. Most of it is either “it writes my whole app” or “it’s useless and hallucinates garbage.” Both camps are right, depending entirely on the process around the model. The model is not the product. The process is.</p><p>Here’s how we run a real, spec-heavy library project with agents doing most of the typing and humans doing most of the deciding. It’s not magic. It’s a pipeline with gates, and the gates are the whole point. None of it was designed up front — it accreted, one fix at a time, from things that went wrong. That history is the reason it can now mostly run itself.</p><h3>Rule zero: bound the agent before it does anything</h3><p>The first thing we load into the main agent isn’t the task. It’s a set of behavioral rules — Andrej Karpathy’s guidelines on the common ways LLMs screw up code. Think before coding. Surface assumptions instead of guessing silently. Write the minimum code that solves the problem, nothing speculative. Touch only what the task requires — no drive-by “improvements.” Define verifiable success criteria and loop until they’re met.</p><p>This sounds soft. It isn’t. Left unbounded, a capable model will happily refactor three files you didn’t ask about, invent a configuration system for a single use case, and add error handling for inputs that can’t occur. Loading the constraints first changes the default behavior for the entire session. Every later phase inherits it. We’re not asking the model to be smart; we’re asking it to be disciplined, and discipline has to be set before the work starts, not bolted on after.</p><h3>Picking the framework: GSD vs BMAD vs Spec-Kit</h3><p>We looked at a few spec-driven development frameworks — GSD, BMAD, Spec-Kit — and went with Spec-Kit. The reasoning was boring and that’s good: it maps cleanly onto a workflow where a specification is the source of truth, it produces tracked artifacts (spec, plan, tasks) instead of vibes, and it doesn’t fight a git submodule layout. The other two are fine tools; they just optimize for a slightly different shape of project than ours. The lesson isn’t “Spec-Kit wins.” It’s that you should pick the framework that matches how your truth flows, and then actually commit to its artifacts instead of treating them as decoration.</p><h3>The cast: who does what</h3><ul><li><strong>Opus 4.7 is the main agent.</strong> It drives. It holds the plan, makes the calls, orchestrates everything else. The expensive, capable model is the one place you don’t want to economize, because every downstream decision compounds from here.</li><li><strong>Sonnet does the legwork.</strong> Research, per-phase implementation under a brief, the parallelizable grunt work. Cheaper, fast, and perfectly good when the task is well-scoped by someone else.</li><li><strong>Codex is the adversary.</strong> It does not write our features. Its job is to attack them — hostile review of plans and PRs, from a fresh context, with no emotional investment in the design it’s tearing apart.</li></ul><p>Splitting “the one who builds” from “the one who tries to break it” is the single highest-leverage decision in the whole setup. A reviewer who didn’t write the code and isn’t the same model that wrote it finds things the author is structurally blind to.</p><p>And every one of these is a fork from the main agent into a clean, focused context — the researchers, the per-phase implementers, the reviewers, all of them. None of them inherits the main agent’s running narrative, its half-formed assumptions, or the order it happened to look at things. A reviewer carrying the author’s context tends to arrive at the author’s conclusions. A fresh, narrowly scoped context is what makes a second opinion an actual second opinion instead of an echo — and it’s what keeps each agent fast and on-task instead of wading through everything that came before.</p><h3>Research, in parallel, before any opinions form</h3><p>Before we plan anything, we send several Sonnet agents out in parallel to read the official specification and study the other implementations already on the market. Not “summarize this” — we ask for pros, cons, where real users hit pain, what the spec says versus what shipped products actually do, where the ambiguity lives.</p><p>Parallelism matters here for a reason that isn’t just speed: independent agents that haven’t seen each other’s conclusions don’t groupthink. We get genuinely different readings, and the disagreements are the signal. The places where two researchers contradict each other are exactly the places that need a human decision later.</p><h3>Map every spec item so nothing can quietly go missing</h3><p>We take the specification and turn it into a list where every requirement gets an identifier. Every single one. This is tedious and it is non-negotiable.</p><p>The reason is simple: “did we implement the spec?” is an unanswerable question, but “is requirement R-047 covered by a task and a test?” is a yes/no. Once every spec item has an ID, completeness stops being a feeling and becomes a checklist you can fail. This is the same Karpathy principle as rule zero — weak success criteria need constant clarification; strong ones let the work loop on its own.</p><h3>Planning, scoping, and an argument before any code</h3><p>With research in and the spec mapped, we plan. This is where we cross-check the plan against the spec, run an adversarial review over it, and make the scoping calls: what’s in v1.0, what’s deferred to v1.x, and — just as important — what order things have to happen in so we’re not building the roof before the walls.</p><p>Scope discipline is where most projects rot. Everything feels like it belongs in v1.0 until someone forces the question “does it, though?” The adversarial pass exists to force exactly that question, on the plan, before a line of code makes the answer expensive.</p><h3>How Spec-Kit actually fits the workflow</h3><p>Spec-Kit isn’t run for its own sake. It owns a specific stretch of the pipeline: turning an agreed plan into a spec, a plan, and a dependency-ordered task list, then driving implementation against that task list. The artifacts are tracked. The tasks are ordered so dependencies come first. When a phase is big, we hand one phase to one Sonnet subagent under a tight brief, and the main agent independently re-checks the gate before moving to the next one. The framework gives us the rails; the orchestration on top is ours.</p><h3>The design loop: argue until it converges</h3><p>Design happens in a loop, not a single pass. We draft, run a review, rewrite, and repeat — with a hard cap on rewrites so it can’t spin forever. Codex runs adversarial passes against the design. The loop ends on <strong>convergence</strong>: the design stops changing in meaningful ways under attack. Not “we’re tired of it” — convergence.</p><p>The cap matters as much as the loop. An unbounded “keep improving it” instruction is how you get an agent polishing forever. So the loop is bounded twice — in how wide it’s allowed to look and in how many times it’s allowed to retry — and it has exactly three ways out. It converges. Or it’s down to one or two low-priority issues, which we waive explicitly and file as follow-ups rather than block the whole thing on them. Or it simply fails to converge — what we call a catastrophic design flaw, which is a precise thing, not a vibe: the serious problems (the P1s and P2s, the kind you can’t quietly ship around) are still unreconciled after three rewrite rounds. And the third of those rounds isn’t more of the same — it’s deliberately handed to Codex, a different model taking a different approach, specifically so the last attempt isn’t the same mind repeating the same mistake. If even that can’t reconcile them, the design is treated as broken at the root and restarted from scratch, not patched. Anything else — drifting, endless polishing, quietly running out of steam — is not an exit.</p><p>Those three crisp conditions are the entire reason the pipeline can run unattended. An agent that knows precisely when it’s allowed to stop, and when it must escalate instead, doesn’t need a human standing over it blessing each step. That’s the difference between “AI that needs babysitting” and a process that self-verifies and only interrupts you when it genuinely should.</p><h3>The implementation loop: TDD and two gates</h3><p>Implementation runs through Spec-Kit, test-first. The flow:</p><ol><li>Tests before code, derived from the mapped requirements.</li><li><strong>Gate A</strong> — design/feature-bundle review before the PR exists. Codex review, an adversarial pass, a bounded rewrite loop, convergence or escalation.</li><li><strong>Gate B</strong> — hostile PR review before merge. A reviewer that didn’t write the code, from a fresh context, tries to break it. Triage, fix, re-review.</li><li>Verification that the boring stuff actually fired: code coverage, sanitizers, static analysis. Not “we ran tests” — evidence that each check ran and passed, on disk, before a gate can be marked done.</li></ol><p>Two independent gates with an independence rule between them is deliberate. One gate is a checkbox; two gates where the second one assumes the first one missed something is a process. The verification step exists because “we have tests” and “the sanitizers actually ran in this build” are different claims, and only one of them is true by default.</p><h3>Traceability, and proving it before anything is called “done”</h3><p>This is rule zero coming back around. Every implementation task is marked explicitly against the feature or requirement it serves, and we check both directions: every requirement has tasks (completeness) and every task has a requirement (no speculative scope creep). A task that doesn’t trace to a requirement is either a missing requirement or work nobody asked for. Both are bugs in the plan, and both are easier to catch on a traceability check than in a code review three weeks later.</p><p>But marking tasks is not the same as proving the work landed, and that distinction cost us. Early on we didn’t have a hard completeness gate — we had the traceability markings and a general intent to honor them. A feature slipped through “complete” anyway. Marked done on the plan is not the same as actually done in the merged code, and the gap between those two is exactly where things quietly go missing.</p><p>So now there’s a mechanical three-way audit, and it is not optional. It checks, against the <em>merged tree</em> rather than the plan: every task marked done has a real test and real implementation behind it; every requirement has both landed; and every feature-catalogue entry it owns is actually closed out. The result is 100% or an explicitly recorded waiver — no implied passes, no “close enough.” And it’s wired as a hard precondition to the merge gate: the gate refuses to even start until the audit is satisfied, the same way it refuses to start on a failing verification run. The point isn’t the audit itself. It’s that “are we actually complete?” stopped being a question someone answers from memory and became a check the pipeline won’t let you skip.</p><h3>When the human actually decides</h3><p>The pipeline runs itself right up until it hits something it shouldn’t decide alone, and then it stops and asks. Where the researchers contradicted each other. Scope calls — what’s really v1.0. When a bounded loop exhausts its budget without converging. When a gate escalates instead of passing.</p><p>This is the part people get wrong about agentic workflows. The goal isn’t to remove the human; it’s to make the human’s attention expensive and spend it only where it’s worth spending. The agents handle the volume. The human handles the judgment calls — and because everything upstream is tracked and traceable, the human is making those calls with real context instead of vibes.</p><h3>Why bother with all this</h3><p>You could skip every gate and let the model rip. It’d be faster on day one and a swamp by week three. The gates, the caps, the adversarial reviews, the traceability — none of it makes the model smarter. It makes the <em>process</em> trustworthy, which is the only thing that lets you move fast for longer than a sprint.</p><p>And none of it arrived as a grand design. Every gate is a scar. The completeness audit exists because something slipped through “done” once. The independent reviewer exists because a reviewer too close to the code kept missing things. The bounded loops and their exit conditions exist because “keep improving it” never terminates on its own. The flow is just the accumulated set of fixes for ways we’d already been burned, each one turned into a check the pipeline enforces so we can’t be burned the same way twice. That’s the part that compounds: a process built out of real failures, with loops that know exactly when to stop and when to escalate, is one you can actually let run on its own and trust to catch its own mistakes — instead of watching it like a hawk and approving every move.</p><p>The model is not the product. The process is. The model is just the fastest typist you’ve ever worked with — and like any fast typist, it’s only as good as the editor standing behind it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=981763342645" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to ruin your CV in 2020s]]></title>
            <link>https://medium.com/@catalinserafimescu/how-to-ruin-your-cv-in-2020s-ff518f614681?source=rss-f2fa4b41bcc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff518f614681</guid>
            <category><![CDATA[it-life]]></category>
            <dc:creator><![CDATA[Catalin Serafimescu]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 18:28:17 GMT</pubDate>
            <atom:updated>2026-02-04T18:28:17.606Z</atom:updated>
            <content:encoded><![CDATA[<p>You try to survive. You adapt. Make compromises. And one day no one wants you anymore</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fs7Wi7wWRFNLBpCLPovtag.png" /></figure><p>If you didn’t read it yet, have a look at my other story, it gives more context: <a href="https://medium.com/@catalinserafimescu/people-are-commodities-5a80a0f2b3f0">https://medium.com/@catalinserafimescu/people-are-commodities-5a80a0f2b3f0</a></p><h3>Background</h3><p>Job market changed. AI is replacing real jobs, helps developers, cleans the house, make scrambled eggs. <br>Western countries are praising “fail fast” ideology, but that is just a buzzword, no one wants to fail at all. Everyone want to “deliver” and things moves fast, no one has time to wait — time to learn, time to grow, time to stabilize.<br>I’ve been in consulting business for 16 years now. I worked for countless clients where we did whatever was needed to deliver features in production. Until last client, I only seen two paths: one where you had dedicated teams which works with you, and one where you have the power to decide what to do, and do it. <br>Last client has a different approach: having a pool of things to do and a pool of people, pick whatever is burning that day, pick someone from the pool and tell him/her to do it. They are pushing hard to use AI, to compensate for the lack of experience in the specific field. We are consultants, so we are trying to do what are we asked to do, as best as we could.</p><h3>What changed</h3><p>For consultants, there is an expectation to see a feature from planning to production, with everything it entails: planning, developing, testing, getting sign-off, raising CRs, deploying to production. Somehow this makes sense. But lately I saw that this workflow require us to work with technologies we are not used to, with minimal support from team which was supposed to handle it, handling infrastructure, etc…</p><p>Thing is, speaking with colleagues from other clients, it seems this happens almost everywhere: they are asked to learn new technologies overnight by getting access to learning platforms, then design and implement whole systems without having a system architect, at least. And most of clients get rid of Level 2 support teams, so developers are in charge of attending tickets, on top of current assignments. I can describe you a day when I had to look into some problems in production, while several people were screaming that UAT does not work, too, and, at the end of the day my manager asked why I didn’t progress on the tasks I had assigned. Fun fact: this week I am on support and I am also Release Manager for this month.</p><h3>Why is bad</h3><p>I am mainly system architect and C++ developer, or other way around, depending on the requirements. Or, I am supposed to be. Thing is, when I updated my CV with what I did in the past 4 years, the C++ part almost disappeared. I added Kubernetes, DevOps, Python, Release Management and couple other things. Then I tried to apply for some jobs, C++ based. No response, not even one. Initially I said that it might be my age, but I reviewed my CV and I noticed: after 22 years where the majority of the work was around programming and system design, the last 4 years looks like spaghetti. <br>In the end I had couple interviews, but, as I mentioned in other article, they either looked for something very specialized (someone who works with exactly the technologies they were looking for [and not N years ago]), or they put me through stupid pipeline starting with live coding Leetcode problems.</p><p>Why is bad? Because this diverse experience several years ago was supposed to favour you, to prove you are versatile and bring more than coding skills to the team, but now it works against you. Clients wants people who do everything, but they pick only the ones who actively works on whatever specific area they need; these things are in contradiction. Last interview I had, first question was: “I see you do lots of DevOps and Release Management work, are you a developer or DevOps?” and 2nd one: “I see that in the past 4 years you did lots of things, how much C++ development you did, are you still up for it?”.</p><p>I see my company struggling placing consultants to clients, I saw client requirements like “we want consultants from X location who previously worked for Y client on Z product”. We had lots of good people we could not find contracts because this kind of requirements.</p><h3>Conclusions</h3><p>I see people try to adapt, learning new technologies, having side projects in GitHub to attach to CV, spending time on open-source projects, etc… but their CVs makes them look “Jack of all trades, master of none”, in order to get them picked by AI filter. Problem is that recruiters are looking then at specific skills AND experience. Practically, unless you do exactly what they are looking for, you are unlikely to get picked for interview. <br>There are many articles here, on Medium on this topic, people attending dozens of interviews. I think is harder to get a permanent role than work as contractor — many of my colleagues are contractors, but they are mercenaries, they accept whatever provides enough money to ensure they can go on. I speak with some of them, they don’t have career plans, they don’t try to learn new technologies or languages (I would bet that this makes you more attreactive) because ‘time is money’ — that is, chances to get a job because you said you learned from books (no experience) are slim, so it doesn&#39;t worth investing time in it. Instead, they rely on learning at the job, because this gives them both knowledge and experience and they are paid at same time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff518f614681" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[People are commodities]]></title>
            <link>https://medium.com/@catalinserafimescu/people-are-commodities-5a80a0f2b3f0?source=rss-f2fa4b41bcc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a80a0f2b3f0</guid>
            <category><![CDATA[job-market]]></category>
            <category><![CDATA[consulting]]></category>
            <category><![CDATA[people]]></category>
            <category><![CDATA[it-professionals]]></category>
            <dc:creator><![CDATA[Catalin Serafimescu]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 19:37:51 GMT</pubDate>
            <atom:updated>2026-02-02T19:37:51.168Z</atom:updated>
            <content:encoded><![CDATA[<h4>People have become commodities. Technology evolves. Society evolves. The job market evolves — and not always in a good direction</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8GAOMOdVyQ6lk5kEyJ5yeQ.png" /><figcaption>Image created with AI showing people being hired, used, and thrown out</figcaption></figure><h3>A bit of context</h3><p>I’ve been working since university. Heck, I was working even in high school. <br>26 years ago, when you were interviewed, you had to know some programming language, some SQL, reason a bit and you could land yourself a job. Then you worked as designed developer, learn a bit about software engineering, some technologies you need, and you had support from company — not necessarily trainings, but they give you time to learn new stuff, and this applied to new joiners — they got them and they put them in training programs, they give them time to learn.</p><p>I am working as consultant since 2010. I worked for countless clients since.<br>I had 2 technical interviews in 2010–2011, one in 2021, which involved a bit of coding. Everything else was at most a discussion with some manager. Clients were asking for me, or, when they onboarded whole team, I was one which didn’t had to interview. At all places I was left alone to do my job, or I was the one who drive the show, the only requirement was to deliver. When I had a problem I could not solve it myself, my manager helped me to solve it (getting help, resources, anything I needed to solve it).</p><p>Last client (2021) has a different approach, one I already seen it failing twice: having a pool of people and a pool of problems to solve, pick whatever problem is burning now and assign it to whoever is closest to you. So I had to adapt: learn a bit more about Kubernetes, learn some DevOps, learn some new technologies they were using, learn some in-house technologies they were developing. On top of that we were on-support rota (they don’t have L2 support), plus Release Managers (again, on rota), after they kicked off the DevOps guy we had. We have so much work on releases, that we were discussing that one person is not enough, so we should have two persons preparing the releases. And we have two. Developers, not DevOps</p><p>I am also taking interviews for my own company, including pre-interviews for clients. And this plays an important role next</p><h3>Job market changes</h3><p>3–4 years ago I started to notice a shift in the job descriptions I got: “junior developer with strong knowledge on C++/Java/C#/&lt;your language here&gt;, SQL, Kubernetes and DevOps”. Mkey… quite a lot to ask from a junior. Then, last year I saw it: “junior developer with strong experience on high-performance, low-latency trading, networking protocols. Experienced with CI/CD pipelines (GitHub actions preferred) and Cloud technologies (K8s)”. There isn’t such “junior”. <br>Job descriptions passed around started to look like a wedding wishlist. Some were asking for niche systems or technologies, where experts were paid handsomely, combined with trivial ones (DevOps, Python, scripting).</p><p>Then I made a connection with my client: he wanted me for my C++ skills, but I was doing DevOps, support and Release Management. When they needed an expert for some thorny C++ problem, they would ask me to look into it. Otherwise, I was working on what was burning that day.<br>Then I noticed people coming and going, some because of burnout, some because some projects finished. This is not uncommon on consulting world, but couple of people were actually <strong><em>replaced </em></strong>with others who had similar skills, but also some which were required at that time.</p><p>Slowly, other signs started to attract my attention:<br>- some skilled guys which passed my interview were rejected by clients because they lacked some very specific skill <br>- job descriptions asking for specific skills. Example: Low-latency systems — clients were rejecting good people because they didn’t work at last job on low-latency systems, even they did that for 10 years before. <br>[L.E. I know this is very specialized skill, but is not that you can find such experts easily]<br>- Some guy asked me in the middle of the interview, where he didn’t do too well, when I am going to give him Leetcode problems. I was puzzled, I asked why, and the answer was “because I prepared myself with Leetcode and I actually have X score” (whatever that means)<br>- Other guy let escape that he checked my LinkedIn profile and even Medium account, and read my posts, so he can understand me better. HE. UNDERSTAND. ME.</p><p>People started to adapt in order to beat the system — create the CVs with AI by feeding job description, learn Leetcode by heart, have “personal projects” in GitHub, even stalking the interviewer. <br>I even read that some wrote keywords from job description in CV with background color, so it won&#39;t be seen or printed, but AI used to select them would pick them.</p><h3>My experience</h3><p>I’ve been in some interviews too, on the other side of the table.</p><p>First experience was with guys from a small team. They wanted “a C++ expert with strong software engineering skill” but, after discussing with them, the job was around writing some automation shell scripts; C++ skills were “required” because they had some C++ code and, from time to time, someone had to debug it.</p><p>Second one was with someone from the same client, different department. We agreed there won’t be a live coding session, because I was already working for them and they knew my reputation, just a discussion with department manager. But got two guys who asked me to do live coding sessions with some Leetcode problems. Their team has nothing to do with such thing but… that was the most they could do. They weren’t interested in my experience, my work, or the systems I built. They wanted Leetcode. Problems they never use. They failed me — and three months later, their manager asked if I was still available… One month after that he was fired because he wasn’t able to fill both positions in 9 months.</p><p>Now I am expected to be able to tackle any problem, in any domain, and use AI for everything. Actually, <strong>because</strong> I am <strong>asked</strong> to use AI. The attitude is: you should be able to do it, just ask Copilot. Last time I touched a cpp file was in late October, 3 months ago.</p><h3>Conclusions</h3><p>Technology evolved, job market changed, expectations changed. No one cares about people, no one cares about true professionals. Everyone wants just to deliver (aka make money). No one really invests in employees development — everything I saw in the past years was just providing access to online training platforms and expect that employees will use them to gather knowledge required by company at that time. But this year is one technology, next year is another, and there is no time to build real knowledge. As such, companies hires people who already has the skills, then drops them when they are not required anymore. It is supposed that one would build such diverse panel of skill on their own time.<br>We’re told to adapt. But this isn’t adaptation — it’s survival. And the cost will show in a few years, when systems built by exhausted, inexperienced developers — guided by AI instead of mentorship — start collapsing. <br>I’ve already seen the cracks, but this story is for another time</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a80a0f2b3f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to share your headset and webcam with Hyper-V virtual machine]]></title>
            <link>https://medium.com/@catalinserafimescu/how-to-share-your-headset-and-webcam-with-hyper-v-virtual-machine-e8beb5b990f6?source=rss-f2fa4b41bcc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8beb5b990f6</guid>
            <dc:creator><![CDATA[Catalin Serafimescu]]></dc:creator>
            <pubDate>Fri, 22 Nov 2024 13:15:28 GMT</pubDate>
            <atom:updated>2026-03-04T06:22:27.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j8E0jB-PaZpSdLrHNFsDqw.png" /></figure><p>There were lots of people complaining they can’t share the headset and webcam with the VM when using Hyper-V. Here’s how I managed to do it, I hope this will be helpful to you.</p><h3><strong>March 2026</strong></h3><p>Microsoft removed completely RemoteFX. The procedure below does not work anymore. The new procedure I use now is:<br>- I have the Hyper-V VM<br>- I created a RDP file used to connect to that VM using machine name<br>- I run a PowerShell script which launches the VM, waits to came online, then uses the RDP file to connect to it.</p><p>In RDP file select same devices you want to share, for audio and camera:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*T0faBtbpd4SbcoJPdrB1NA.png" /></figure><p>I’ll leave below two versions of PowerShell script, one which uses the RDP file</p><pre># VM name din Hyper-V<br>$vmName = &quot;HyperVMMachine&quot;<br><br># Path to RDP file<br>$rdpFile = &quot;C:\Path\VMMachine.rdp&quot; <br><br># Start VM (Hyper-V)<br>$vm = Get-VM -Name $vmName<br>if ($vm.State -ne &quot;Running&quot;) {<br>    Start-VM -Name $vmName<br>}<br><br>Write-Host &quot;Waiting to initialize...&quot;<br><br># Wait until it gets the IP<br>do {<br>    Start-Sleep -Seconds 2<br>    $ip = (Get-VMNetworkAdapter -VMName $vmName).IPAddresses |<br>          Where-Object { $_ -match &#39;^\d+\.\d+\.\d+\.\d+$&#39; } |<br>          Select-Object -First 1<br>} until ($ip)<br><br>Write-Host &quot;VM online with IP: $ip&quot;<br><br># Open RDP file<br>Start-Process $rdpFile</pre><p>and one which uses IP directly</p><pre>$vmName = &quot;HyperVMMachine&quot;<br><br># Start VM (Hyper-V)<br>$vm = Get-VM -Name $vmName<br>if ($vm.State -ne &quot;Running&quot;) {<br>    Start-VM -Name $vmName<br>}<br><br>Write-Host &quot;Waiting to initialize...&quot;<br><br># Wait until it gets the IP<br>do {<br>    Start-Sleep -Seconds 2<br>    $ip = (Get-VMNetworkAdapter -VMName $vmName).IPAddresses |<br>          Where-Object { $_ -match &#39;^\d+\.\d+\.\d+\.\d+$&#39; } |<br>          Select-Object -First 1<br>} until ($ip)<br><br>Write-Host &quot;VM online with I: $ip&quot;<br><br># Connect RDP<br>mstsc /v:$ip</pre><p>If you can’t run the PowerShell script, probably you need to reset the policies</p><pre>Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned</pre><p>or, for each invocation</p><pre>powershell.exe -ExecutionPolicy Bypass -File StartVM.ps1</pre><h3>Old procedure (not working anymore)</h3><p>First, you need to enable redirection:</p><ol><li>On HOST machine, open Local Group Policy Editor (gpedit.msc) and enable this policy: Computer Configuration/Windows Components/Remote Desktop Connection Client/RemoteFX USB Device Redirection — Allow RDP redirection of other supported RemoteFX USB devices from this computer = Enabled</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEktqpYRW9_IU2vdDhGLew.png" /><figcaption>Enable sharing PnP devices on HOST</figcaption></figure><p>2. On GUEST machine, open Local Group Policy Editor (gpedit.msc) and enable this policy: Computer Configuration/Windows Components/Remote Desktop Session Host/Device and Resource Redirection — Do not allow supported Plug and Play device redirection = Disabled</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Am1Rr7RvmiZqZewILVSPQ.png" /><figcaption>Enable sharing PnP devices on GUEST</figcaption></figure><p>Now, it is important to undestand something:<strong> if you DO share the USB devices, they will not be accessible anymore from the host machine. </strong>Read that again!<br>When you share the devices with VM, they will appear in guest Device Manage, but the VM will always have Remote Audio device, you won’t be able to pick your headset. Or I wasn’t able to, but that wasn&#39;t a problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w_EZtocI_DYRd68SD6XkwA.png" /><figcaption>GUEST VM will always have Remote Audio device and not the headset device name</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*YaYlYuKvwOuCtFBESHaEhA.png" /><figcaption>GUEST VM will Device Manager will show the devices shared</figcaption></figure><p>When you connect to VM from Hyper-V Manager <strong><em>sometimes</em></strong><em> </em>you’ll be able to choose which devices to share. Most of the time you won&#39;t, if you choosed to save them (!). So you better run this from cmd:</p><blockquote>VMConnect.exe localhost &lt;VMname&gt; /Edit</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*eY9lyBxswi-YufkvVqLxMg.png" /></figure><p>Click on Show Options and then Local Resources tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*Mt1WsmFPmyOIpcFkCi-blg.png" /></figure><p>Audio Settings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*di2FDOUF7vD8G-d9_xlw7A.png" /></figure><p>Click More:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*IEw2Ll5AJezHi9NHxXjFDA.png" /></figure><p>and choose which devices you want to share with GUEST VM</p><p>Did you read what I said above? <strong><em>What you share you won’t be able to use locally anymore!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*GHzfzJcEGqw95VChq9s9NA.png" /></figure><p>Same thing for headset (Plantronics Blackwire 5220 in my case).</p><h3>Using headset on both HOST and GUEST</h3><p>OK, so you are a normal person and want to use your headset on both host and VM. Almost like myself. How do we solve this problem?</p><p>Well, the answer relies on GUEST sound device, which is called Remote Audio. That means that we want to play and record audio to whichever device is configured on HOST.</p><p>So let’s configure it:</p><ol><li>DO NOT SHARE YOUR HEADSET on the configuration window above.</li><li>Set VMConnect to use your headset (on HOST) on Sound/System/Volume mixer:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*LJz59MzJ3Ie2VWlcWC1WtA.png" /><figcaption>Set VM to use headset on HOST</figcaption></figure><p>Now you can use it on HOST too:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*iFt6pSl1CgcobYKmmMZ5MQ.png" /><figcaption>Webex using headset on HOST</figcaption></figure><p>I shared the camera, so the camera is not available anymore on HOST:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*QJ2aaDYQfvNAKoL_ANu5Lw.png" /><figcaption>Camera is not available anymore on HOST</figcaption></figure><h3>Conclusions</h3><p>Well, I don&#39;t know how to make camera available on both HOST and GUEST. Didn’t spent too much time on it. If you need it, just disconnect from VM temporarily, or use it directly from VM.</p><p>In my case, I need headset for both VM and host PC, for different reasons. If I need camera, I close temporarily the VM window, but the important part is that I can use the headset on both machines without troubles, and I saved VM settings, so I don’t have to set them each time I start it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8beb5b990f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is wrong with IT world?]]></title>
            <link>https://medium.com/@catalinserafimescu/what-is-wrong-with-it-world-abca148db915?source=rss-f2fa4b41bcc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/abca148db915</guid>
            <category><![CDATA[it-services]]></category>
            <category><![CDATA[consulting]]></category>
            <category><![CDATA[management-and-leadership]]></category>
            <dc:creator><![CDATA[Catalin Serafimescu]]></dc:creator>
            <pubDate>Thu, 14 Nov 2024 16:00:19 GMT</pubDate>
            <atom:updated>2024-11-14T16:00:19.550Z</atom:updated>
            <content:encoded><![CDATA[<p>Things are changing, and not in a good way</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*noUOeScPHWV50zZ788e1fw.jpeg" /><figcaption>Generated using AI</figcaption></figure><p>I have been working in IT for 25 years, and the last 15 years I am doing consulting work. In the past 2 years I noticed that things are changing, and not in a good way.</p><p>When I started my career, I applied to quite a few interviews as young graduate. I knew C++, some databases, some system architecture… and that was it. I got a well-paid job for a good company, and since I was working for top tier banks.</p><p>Then I started to learn more and more: C#, design patterns, SOA, etc… and I always coped with the technology. I was praised for my skills, I was leading several teams at once, I always delivered in time. And I read more and more about the technologies I was interested in.</p><p>Then, after 10 years, I switched to a consulting company, taking assignments as expert in the system I was working on previously. Again, I was praised for my skills, there were clients which asked for my explicitly, I was flying around Europe for clients to help them with the problems they had. And I was happy. I was switching clients from time to time, but usually they already knew me, or they treated me according to my skills. Usually, I didn’t had to deal with HR, or lower-level interviews, just with program managers and some technical leads which knew what they were looking for.</p><p>Working for so many clients, I had to interact with many types of people, many managers, team leads, etc… Most of the time they used Agile methodologies, and they were asking for a quote, then adjusted the plan accordingly to how things were going. And things were fine, we were delivering on time most of the time, the pressure was acceptable, the managers were understanding.</p><h3>What changed</h3><p>Three years ago, I started a contract with a new client. At the beginning everything was nice: nice team, nice people, we were helping each other, we felt like family (really). And we started to work on a new system, me and two of my colleagues. The specs were very, very shallow, basically I couldn&#39;t get any serious functional requirements, even though the scope of the system wasn’t clarified for us completely. As system architect, I tried to apply some best practices and put in place some expansion points, in case we’ll need them, but I was pushed back, as “not needed”.</p><p>At that time we were working using Agile methodology (sprints, story points, etc…), we had some CI pipelines, we were delivering each sprint something useful. Then, two years ago the project got a ramp up, and a new program manager started to get involved. Very involved, as in micromanagement.</p><p>We started to do long hours, the requirements were changing from one day to another (in 7 days I re-wrote a piece of code 5 times, no joking). My manager started to work overnights, to the point that he got sick every 2–3 weeks, and had to take 1–2 days off. And he got applause. Yes, you read correctly: he was praised for spending nights to deliver. Yes, deliver, not “fix production bugs”.</p><p>Agile transformed in “rolling boulder”: run some tests, found some problems, raise them the same day, ask for a fix overnight, fix it next day, ask for a new release overnight, you get the idea.</p><p>I tried to raise it several times with the management, they pushed me back with “yes, we know, but it is what it is, this is the way we do things”.</p><p>Obviously, things broke at some point. Those overnight fixes and developments caused some issues in production because they weren’t tested enough. And, as expected, the developers were at fault. Again, raised with management, and got the same answer: this is how we roll, deal with it.</p><p>Then I started to analyze what&#39;s going on, and I realized that all managers were doing the same thing, not only for my program, but others, too. They switched the way they managed projects. Initially I considered it to be caused by pressure to deliver, but then I read something here, on Medium, which opened my eyes: under that pressure they reached their maximum competency and started to panic. Basically, when things go wrong, bad managers start to do micromanagement, ask for more reporting, schedule more meetings and hire more little managers to whip the workers. And everyone tried to please his manager, so they were playing the same game.</p><h3>Other places</h3><p>Recently I was attending a meeting/interview with a different client, which just ended a contract with one of our guys and it was looking for someone with… exactly the same skillset, which raised some questions. And I raised those questions. It was revealed that it was an internal struggle between two managers, both rather at the top of their competency, and the project was total chaos. This guy, someone with alot of experience, tried to put some order in it, but without taking sides, which angered both parties.</p><p>The skillset they were looking for, officially, was “C++ expert, system architect”. We had a good talk about this, about the job description, we seem to on the same page when, at very end, they drop the bomb: “you know, you aren’t going to do any architecture here, we already have everything planned, you are going to mostly maintain our infrastructure [which resumed to write and run bash scripts]”.</p><p>At that point I started to ask what I’m missing. Something wasn’t adding up: why ask for some skillset, then get rid of someone who has it, to try to get someone else with same skillset, to ask him to do some trivial job? The only answer that makes sense was that something else was the problem, and the that was the attitude (it wasn’t the case) or that person got too much spotlight. Then I correlated this case with my own: I was assigned to a different team after I challenged them. I wasn’t bullied, I wasn’t told to shut up, I was just pushed out of the way. <em>In the game they were playing, they needed good technical people to do the work, but also were afraid that their judgment was challenged. In a word, they needed good slaves</em>.</p><h3>A different angle</h3><p>There is another thing I noticed in the past 3–4 years: almost nobody invest in [proper] training. Usually training programs are for juniors, the existing employees are expected to know new technologies, without being allowed or even asked to train on them.</p><p>I am taking interviews for almost all clients we have, and the job specs are narrow focused: they need someone with X skill, they expect someone from their internal team to suddenly know it; if not, they ask for a consultant with that skill. And a cheap one. After they finish with it, they usually don’t renew the contract and expect that their internal team to take over. Without internal training, of course.</p><p>The way they formulate the job specifications is complete nonsense: “junior C++ developer with at least 5 years’ experience in high-performance systems”. There is no such thing.</p><p>The problem is even more serious: the recruiters are not understanding anymore neither job specs, nor the CVs. I tried to explain the nonsense above, and all I got was “but the CV says that he knows C++” and “the client asked for high-performance, so we just added that to requirements”.</p><p>It was an article here, on Medium, from someone who, as team lead, applied himself to the role, with a different name, and he was rejected by recruiters. It proved that they were matching keywords between job requirements and CVs.</p><h3>Ending thoughts</h3><p>I came to some conclusions:<br>1. Everyone is focused on delivering. “Deliver” is the new currency, KPI measures how much you delivered. No one invest in the long-term. <br>You just hire some contractors to do your job, and you don’t have to spend on trainings. Basically, you offload this cost to an external party. <br>But this one comes with downsides too: <br>- An individual must spend time and money to learn new skills. Not everyone is willing to do that if there is no return on short term. <br>Also, this cost leads to <br>- Paying an external party which already has the skill you need means that that someone invested in it, and the price will be higher. So, you actually pay for training, but when that party ends, you won’t retain the knowledge.<br>2. Companies are not led anymore by the people who built them, but by appointed CEO, which responds to investors. And there are KPI to achieve. No one cares how things are going as long as KPI are checked. As such, they come with their own team, or hire suitable people. They lead for several years, ensure that they achieve the KPIs, collect the bonus, then move to another company. “After us, the flood”, there is a saying.<br>3. For internal middle management is an opportunity to grow, as long as they don’t bother the masters. When the masters leave, there is a small void which needs to be filled, and who’s best candidate than oldest person around? In order to survive you must not upset the masters and keep deliver.</p><p>In the end, everyone looks for someone who already knows how to do the job and keep their mouth shut. For a price, of course.</p><p>Maybe I should do this, too. But I’m too old for that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abca148db915" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using generators in C++]]></title>
            <link>https://medium.com/@catalinserafimescu/using-generators-in-c-3ba64d4f2d3f?source=rss-f2fa4b41bcc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ba64d4f2d3f</guid>
            <category><![CDATA[generator]]></category>
            <category><![CDATA[cpp-programming]]></category>
            <dc:creator><![CDATA[Catalin Serafimescu]]></dc:creator>
            <pubDate>Tue, 12 Nov 2024 19:23:54 GMT</pubDate>
            <atom:updated>2024-11-12T19:23:54.560Z</atom:updated>
            <content:encoded><![CDATA[<p>There are several ways one can iterate heavy collection. C++ generators are one of them</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Ox56Xiyw3KTnU_X9jyXpw.jpeg" /></figure><p>Not long ago I had to investigate some issues related to performance of the system I was working on. We were using C++14, and the code was lacking any optimizations C++20 could bring to table. Specifically, we had some large vectors of rather big objects which were passed around by copies. That consumed quite a lot of memory, but also time, as those object had to be created and destroyed.<br>The first thing I did was to remove local copies where possible, or replace partial copies with iterators (simulating views). But I found a case where a new structure, a complex map, was constructed, in order to apply some logic on such vectors, it was iterated, then destroyed. The problem at hand was that it was spiking memory, but also took some time to build, just for a single iteration. I was looking for alternatives and I found that a generator would be perfect choice</p><h3>The problem</h3><p>Let’s assume you have some collections of heavy objects, or some objects which cannot be trivially copied, and you need to apply some logic, some correlations, in order to extract some information. <br>For this academic example, we’ll use simple vectors, the correlation will be stored in a map and the information we want to extract is just for displying purposes.<br>The entities: Customer (CustomerId, CustomerName), Product (ProductId, ProductName, Price) and Order (OrderId, CustomerId, ProductIds).<br>The data: all Customers (100), all Products (100) and all Orders (10k) loaded each in a vector.<br>The information: display all products bought by each customer, uniquely.</p><h3>Naive solution</h3><p>I’m calling it ‘naive’ because some are tempted to resort to it without considering the volume of the data (which happened in my case).<br>This implies creating a map, for each customer holding a list of product names, then display that map.</p><p>Assuming that we already have the entities loaded</p><pre>  std::vector&lt;Product&gt; products = loadProducts(&quot;products.csv&quot;);<br>  std::vector&lt;Customer&gt; customers = loadCustomers(&quot;customers.csv&quot;);<br>  std::vector&lt;Order&gt; orders = loadOrders(&quot;orders.csv&quot;);</pre><p>we can create a map</p><pre>  std::map&lt;Customer, std::set&lt;Product, std::less&lt;&gt;&gt;, std::less&lt;&gt;&gt; customerProductMap;<br><br>  for (const auto&amp; order : orders) {<br>    auto customerIt = std::ranges::find_if(<br>        customers,<br>        [&amp;](const auto&amp; customer)<br>        { return customer.CustomerId == order.CustomerId; });<br><br>    if (customerIt != customers.end()) {<br>      auto&amp; productSet = customerProductMap[*customerIt];<br>      for (const auto&amp; productId : order.Products) {<br>        auto productIt =<br>            std::ranges::find_if(products,<br>                                 [&amp;](const auto&amp; product)<br>                                 { return product.ProductId == productId; });<br>        if (productIt != products.end()) {<br>          productSet.insert(*productIt);<br>        }<br>      }<br>    }<br>  }</pre><p>and print it:</p><pre>  // Example output to verify processing<br>  for (const auto&amp; [customer, productSet] : customerProductMap) {<br>    std::cout &lt;&lt; &quot;CustomerName: &quot; &lt;&lt; customer.CustomerName &lt;&lt; &quot;, Products: &quot;;<br>    for (const auto&amp; product : productSet) {<br>      std::cout &lt;&lt; product.ProductName &lt;&lt; &quot; &quot;;<br>    }<br>    std::cout &lt;&lt; std::endl;<br>  }</pre><p>I used Visual Studio to extract the memory consumption in a nicer way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*SSs2QyjmvQ1yoRXM037yIg.jpeg" /><figcaption>Full map memory usage</figcaption></figure><p>The initial 2.7MB is the size of the original vectors I loaded. The increase was 237KB, the map containing full objects</p><h3>Generators to the rescue</h3><p>I order to avoid building the map with whole objects we can create one with position of the objects in the said vectors. That makes sense, because the vectors should outlive both the map and the generator.</p><pre>  std::map&lt;int, std::set&lt;int&gt;&gt; customerProductMap;<br><br>  for (const auto&amp; order : orders) {<br>    auto&amp; productSet = customerProductMap[order.CustomerId];<br>    std::ranges::copy(order.Products,<br>                      std::inserter(productSet, productSet.end()));<br>  }</pre><p>Now, the generator must convert from customer position to customer name, and from product id to product name.</p><p>In order to be used in <a href="https://en.cppreference.com/w/cpp/language/range-for">range-based loops</a>, we need to provide a type which has begin() and end() methods and we generate the next value on demand (on increment).<br>The implementation below is a result of some enhancements, like providing converters for both key and value, and default converters (<a href="https://en.cppreference.com/w/cpp/utility/functional/identity">std::identity</a>).</p><pre>#pragma once<br>#include &lt;functional&gt;<br>#include &lt;iostream&gt;<br>#include &lt;iterator&gt;<br>#include &lt;map&gt;<br>#include &lt;sstream&gt;<br>#include &lt;string&gt;<br><br>template&lt;typename Key1Type,<br>         typename Key2Type,<br>         typename Value1Type,<br>         typename Value2Type&gt;<br>class MapGenerator<br>{<br>public:<br>  using MapType = std::map&lt;Key1Type, Value1Type&gt;;<br>  using PairType = std::pair&lt;Key2Type, Value2Type&gt;;<br>  using KeyConverter = std::function&lt;Key2Type(Key1Type)&gt;;<br>  using ValueConverter = std::function&lt;Value2Type(Value1Type)&gt;;<br><br>  class Iterator<br>  {<br>  public:<br>    using iterator_category = std::input_iterator_tag;<br>    using value_type = PairType;<br>    using difference_type = std::ptrdiff_t;<br>    using pointer = PairType*;<br>    using reference = PairType&amp;;<br><br>    Iterator(typename MapType::const_iterator it,<br>             KeyConverter keyConverter,<br>             ValueConverter valueConverter)<br>        : it_(it)<br>        , keyConverter_(keyConverter)<br>        , valueConverter_(valueConverter)<br>    {<br>    }<br><br>    PairType operator*() const<br>    {<br>      return {keyConverter_(it_-&gt;first), valueConverter_(it_-&gt;second)};<br>    }<br><br>    Iterator&amp; operator++()<br>    {<br>      ++it_;<br>      return *this;<br>    }<br><br>    bool operator!=(const Iterator&amp; other) const { return it_ != other.it_; }<br><br>  private:<br>    typename MapType::const_iterator it_;<br>    KeyConverter keyConverter_;<br>    ValueConverter valueConverter_;<br>  };<br><br>  MapGenerator(const MapType&amp; map,<br>               KeyConverter keyConverter = std::identity {},<br>               ValueConverter valueConverter = std::identity {})<br>      : map_(map)<br>      , keyConverter_(keyConverter)<br>      , valueConverter_(valueConverter)<br>  {<br>  }<br><br>  Iterator begin() const<br>  {<br>    return Iterator(map_.begin(), keyConverter_, valueConverter_);<br>  }<br><br>  Iterator end() const<br>  {<br>    return Iterator(map_.end(), keyConverter_, valueConverter_);<br>  }<br><br>private:<br>  const MapType&amp; map_;<br>  KeyConverter keyConverter_;<br>  ValueConverter valueConverter_;<br>};</pre><p>Now, let’s see it in practice.<br>We create the map using indexes</p><pre>  std::map&lt;int, std::set&lt;int&gt;&gt; customerProductMap;<br><br>  for (const auto&amp; order : orders) {<br>    auto&amp; productSet = customerProductMap[order.CustomerId];<br>    std::ranges::copy(order.Products,<br>                      std::inserter(productSet, productSet.end()));<br>  }</pre><p>and conversion functions (as lambdas)</p><pre>  auto prodIdsToProdNames = [&amp;products](std::set&lt;int&gt; prodIds)<br>  {<br>    std::set&lt;std::string&gt; productNames;<br><br>    std::ranges::transform(prodIds,<br>                           std::inserter(productNames, productNames.begin()),<br>                           [&amp;products](const int prodId)<br>                           {<br>                             return std::ranges::find_if(<br>                                        products,<br>                                        [&amp;prodId](const auto&amp; product)<br>                                        { return product.ProductId == prodId;<br>                                        })<br>                                 -&gt;ProductName;<br>                           });<br><br>    return productNames;<br>  };<br><br>  auto custIdToCustName = [&amp;customers](int custId)<br>  {<br>    return std::ranges::find_if(customers,<br>                                [&amp;custId](const auto&amp; customer)<br>                                { return customer.CustomerId == custId; })<br>        -&gt;CustomerName;<br>  };</pre><p>then we create the generator and iterate it:</p><pre>  MapGenerator&lt;int, std::string, std::set&lt;int&gt;, std::set&lt;std::string&gt;&gt;<br>      generator(customerProductMap, custIdToCustName, prodIdsToProdNames);<br><br>  // Example output to verify processing<br>  for (const auto&amp; [customerId, productSet] : generator) {<br>    std::cout &lt;&lt; &quot;CustomerId: &quot; &lt;&lt; customerId &lt;&lt; &quot;, Products: &quot;;<br>    for (const auto&amp; productId : productSet) {<br>      std::cout &lt;&lt; productId &lt;&lt; &quot; &quot;;<br>    }<br>    std::cout &lt;&lt; std::endl;<br>  }</pre><p>To be noted that template parameters cannot be derived automatically for lambdas here, but if the converter functions are free-standing, then we didn’t have to specify each template parameter.</p><p>Now, let’s look at the performance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*iF8mpZB_X9vGNM21BpYvAA.jpeg" /><figcaption>Memory usage with generator</figcaption></figure><p>We see that we have the initial 2.7MB for the original vectors, then 0.18KB the lambdas, then 104.9KB the map of indexes… and zero overhead when iterating it.</p><h3>End thoughts</h3><p>I was expecting to see a bigger difference in memory used, much higher consumption by the full map. It seems that the compiler did a good job optimizing it. <br>This is an academic example, but it proved that the generator did not consumed any additional memory. In my specific case the memory it saved was around 8–900MB, but, as I mentioned before, it also saved some run time, as those objects didn’t had to be created and destroyed.</p><p>One thing to pay attention to, is that converting functions/lambdas, and the generator itself must not outlive the collections they are iterating over.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ba64d4f2d3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>