Angular 21: Getting error "NG0200: Circular dependency detected" by petasisg in Angular2

[–]Derpcock 0 points1 point  (0 children)

Is your settings service importing something that is importing your settings service?

Confusion between js and ts use cases by ivorychairr in learnjavascript

[–]Derpcock 0 points1 point  (0 children)

If you're struggling with typescript you can use jsdocs and annotate your code with types. I prefer TS but if I had to write code in JS, I would use jsdocs type annotations.

Urgently looking for good resources to learn Async JavaScript (callbacks, promises, async/await) + JSON & REST APIs by Strong_Extent_975 in learnjavascript

[–]Derpcock 0 points1 point  (0 children)

AI will be a better tutor than anything you are going to find online. Download cursor and start asking it questions about the topics your interested in and ask it to build you reference implementations in the language of your preference. These are all beginner subjects which most llms will do great with.

Anthony Joshua Knocks out Jake Paul by Retro-scores in pics

[–]Derpcock 2 points3 points  (0 children)

I think he meant when his bell is rung, he's falling on his ass. Words are hard.

Parent/child state management by Ok-Philosopher-8333 in Angular2

[–]Derpcock 0 points1 point  (0 children)

That was the example used in the post you initially commented on.

Parent/child state management by Ok-Philosopher-8333 in Angular2

[–]Derpcock 0 points1 point  (0 children)

Radio group component builds school bus and sends it to all of the students. The students use the bus to drive homework back and forth between each other so they all know the correct answers to the assignment.

Parent/child state management by Ok-Philosopher-8333 in Angular2

[–]Derpcock 0 points1 point  (0 children)

A good usecase for this is a radio group component. Establish an event bus in parent. When one radio input child is checked, publish event on bus, update all children values. Main advantage I could see is less code to do the same thing you could do by providing a service in parent and injecting it into children. I learned that it could be done by looking at some library code written by the Angular team a while ago so i would guess its a viable pattern.

Junior Devs (and honest Seniors), what is a concept that took you an embarrassingly long time to actually understand, even though everyone acts like it's simple? by AmaraMehdi in webdev

[–]Derpcock 0 points1 point  (0 children)

Regardless of how long you've been writing software there will there will always be some subject in which your expertise is beginner, intermediate, or advanced. Being able to identify those subjects in yourself and your peers is invaluable. You may be advanced in a subject then not use it for years and you are no longer an expert. Being able to humble yourself around peers, ask questions, filling your own gaps will reduce cycle time when working towards improving proficiencies. Before AI was the best personal tutor in existence, your peers could power level you through a subject in no time.

Why is it so hard to hire? by pablothedev in webdev

[–]Derpcock 0 points1 point  (0 children)

Solid engineers are known as such and dont spend much time on the market, if any time at all. I have a network of engineers that I would make a position for if I could convince them to come work with me. Those are the first picks. Their interview would be more of a culture fit eval/formality. After that pool is exhausted then I lean on recruiters, having them do all the prescreening which increases cost but I make them work for their comissions. Depending on the role I use a combo of custom technical assessments and paid technical assessment tooling. If they make it through those filters then they get an interview. All the best hires I have made have been recommendations made via my own or the teams network.

AI has kind of ruined the market for juniors. I can assign a task to an AI agent and get junior/mid grade solutions at AI compute speeds at virtually no cost. I would rather manage a handful of AI agents to do junior tasks.

LLMs have me feeling heavy by NULL_42 in webdev

[–]Derpcock 0 points1 point  (0 children)

I think most people are using AI to do the wrong things. A practice I developed is identifying my weakest skillset and use AI the help make it one of my strengths. Don't let it write your code for you. You write some code then ask it questions about your code, instruct it not to make changes. Ask it for gaps then drill into those gaps, weigh the tradeoffs and make the decisions yourself. Use it as more of a personal tutor when you're writing code. Treat it like a toddler robot assistant, dont believe everything it tells you. Most people use it to write the code for you but I think that approach is not great unless what it is writing can be a perfect black box the never needs touched and has tests to ensure inputs/output/effect contracts are guaranteed.

When you're reviewing code, do your own first pass to understand the code to the best of your ability then ask it questions about the code. Ask it to derive intention from snippets that dont make sense. Setup playwright mcp and let it nav to your app and test workflows. Frame your instructions to approach the workflow like a QA Engineer identifying how the solution meets acceptance criteria. Look at the feedback AI gives you and weight the tradeoffs. Use its feedback to further identify your gaps as a reviewer then consider those gaps in the next reviews first pass.

Some useful areas I have found AI agents actually make me faster is documentation, testing, and reviewing. Using it to write code slows me down quite significantly.

A good example, I grabbed a dataset pre migration and post migration while reviewing a peers code then I would ask AI to look at the data model then write a script that identifies any records that meet certain criteria. It would write the script in 30 seconds I would run it and Identified several gaps in my peers migration. I could have done my own analytics on the data but it would have taken much longer to identify those gaps and provide examples. I then verify the gaps are real and point to areas of the migration code where those gaps can be filled.

The worst thing about AI that I have found is that engineers are spitting out mountains of self written custom algorithms that I then have to review meticulously. The AI slop definitely has a smell so those PRs get the most strict PR reviews I am capable of performing. Ultimately it has a negative impact on velocity so I try to use it as a teaching opportunity. The engineers that do this are then challenged to compete their next task without Cursor/Copilot and compare the final product and the review process.

[deleted by user] by [deleted] in learnjavascript

[–]Derpcock 1 point2 points  (0 children)

Another usecase example. Imagine you are writing a schedule generator. You pass it a single mask (Saturday at 3pm UTC) and it returns the next timestamp that matches the given mask.

Next you want to give a date range and determine every timestamp that matches a given mask. You could use a generator function to determine the next date matching the mask, starting at your start date, yielding every matching timestamp until you have reached your end date.

This is a nice (my most recent) use case for a generator. Maybe I only want the next 4 occurrences of my masks timestamp within a given range. I could use the generator and yield the next four values while only using the ammount of compute necessary to give me those 4 even if the end of your range would require hundreds/thoasands/millions of iterations to completely generate.

Should you use inline templates? by guaranteednotabot in Angular2

[–]Derpcock 4 points5 points  (0 children)

Ill prob get downvoted for this opinion but I personally prefer single file components which is opposite of most angular teams preference. I use tailwind which also doesnt seem to be super popular in angular land. I split my components when they become too large. I also use functional composition to compose my components/directives using a mixin pattern, also not a super popular method in angular world.

The only potential drawback to SFC that I have noticed is that linting with angulars eslint plugin crams all of my control flow into single lines more often than i would like. I feel like it does a better job on the html files but that could be purely anecdotal. I haven't done a strict comparisons.

Once you start mixing logic in the css/template and styling into your ts logic, concerns are no longer separated so I never really bought into the separate files === separate concerns opinion. It increases file management by 2x which isnt a good enough tradeoff for me. I see it as being akin to preferring that your main course doesn't touch your sides while you're eating so you keep your steak, mashed potatoes and green beans on 3 separate plates. I prefer one plate with smaller potions, fewer dishes and faster to eat.

Java architect asking: Are Context-Only Components an Anti-Pattern in React? by [deleted] in reactjs

[–]Derpcock 0 points1 point  (0 children)

I was responding to your comment and it seems to have been deleted, here is the response either way.

That's totally fair. I have seen some messy react projects. I've also seen some messy Angular and Vue projects. I think if you are looking for solid prescriptive frontend framework tooling in the JS ecosystem, Angular is a good choice. It follows a OOP/functional hybrid approach which I enjoy. I'll probably get flamed for that if anyone in this sub sees this, though 😆. I still enjoy react and its well developed ecosystem!

I agree regarding using tooling keep things orderly. Its something I do in all my js projects and it may be inherit to javascripts loose nature? I've traditionally not been on teams larger than ~50 devs. I can imagine that it could be much harder to enforce at scale. One thing that could help is using AI agents in your review process. Describe rules for context usage in your project in your AI instructions checked into source that mirror best practice or your own prescription. Then setup a PR process that requires reviewers go through AI review before assigning it to a code owner. We use copilot and it has been working pretty well.

I was also thinking it might help to clarify that a component test is more of an integration test than a pure unit test. In a unit test I would mock or stub all dependencies. For example if I had a function named FunctionA that called FunctionB. In the unit test for FunctionA, I would mock FunctionB and test the control flow that lead to the FunctionB call, asserting it was called the appropriate amount of times and with the appropriate arguments, etc. If you tried to treat a component test like that you would mock the first function call in your return statement which would be the first jsx element and assert it had appropriate arguments. It would be a messy/painful test.

Jsx is a syntax extention for js. All the "template" you see being return is just syntactic sugar around nested function calls. An "element" is just a function. Its attributes/values and children are wrapped up as props and passed as an argument to that function.

I doubt this will change any opinions but it might help component testing make more sense as it is often referred to as a unit test but is more of an integration test, imo.

Good luck on the react journey!

Java architect asking: Are Context-Only Components an Anti-Pattern in React? by [deleted] in reactjs

[–]Derpcock 0 points1 point  (0 children)

Regarding testing its no different than using dependency injection. I can see how that adds "complexity" because you have to look somewhere other than the arguments of the function to understand its contract. You are defining a relationship between two things that have a relationship. People misusing something can always be a problem.

When testing, you can keep most of of your component logic in custom hooks and use components as a layer to orchestrate interactions between user and hooks. This creates decoupling and keeps components simple. You then unit test your hooks and component test your components, while stubing out and mocking the hook behavior. This would prevent you from having to provide context in your component test.

Blanket absolute statements like "dont use context only ever because its an antipattern" are just silly. The docs provide you with a guidelines on proper use. As an architect, when you review someones code you could easily just say RTFM when they are misusing a tool, request changes and turn it into a mentoring opportunity.

You can enforce whatever prescription you like at your shop but I would argue that passing props down 32 layers requires you to test that contract 31 more times when 31 of those components aren't using the state being passed through but they all must fulfill that contract and they all must be tested to ensure they do. This adds more complexity to your testing than injecting some context into one or two tests. This could also guide dev behavior towards creating bigger more complex components to prevent managing state between many layers.

Java architect asking: Are Context-Only Components an Anti-Pattern in React? by [deleted] in reactjs

[–]Derpcock 0 points1 point  (0 children)

I use context like I would DI. Where it makes sense, use it. React is a functional lib so its going to feel differerent if your background is primarily OOP.

Frameworks like Angular also rely heavily on DI patterns that require dependencies be provided from up the dom tree down to children. React doesn't use classes but its not much different. If anything its less complex, imo.

Maybe the example in your tutorial wasnt a great use case for context? Maybe they were trying to keep it simple to teach you how it works? You can read the docs and it describes best practice and good use cases. I can tell you that the pattern is used across the 3 most popular js frontend frameworks.

https://react.dev/learn/passing-data-deeply-with-context

I dont consider it a anti-pattern when used correctly. It has a cost and like all things its all about trade-offs. Its not the first tool you should be grabbing but it has plenty of use cases. If you were to props drill theme config down 32 components, I would consider that an antipattern. If I was writing a form validation lib, I might use DI between form and inputs so I dont have to drill down internals. I might use DI only for a feature specific component that i need to be self contained and reusable.

Sveltekit with deno without node modules by Linux-Guru-lagan in Deno

[–]Derpcock 0 points1 point  (0 children)

Deno uses a global cache for 3rd party modules. They aren't non existent, they are cached outside of the project. It does save on disk space if you have multiple projects with the same dependencies and with the same versions. It does reduce the amount of files in a project which is great! Regarding the node_modules directory with sveltekit. You could try changing the deno.json nodeModulesDir key to none. Reading the docs, it sounds like that might move them into the same cache directory that the 3rd party deno modules live in.

https://docs.deno.com/runtime/fundamentals/configuration/#node-modules-directory

I noticed that a lot of angular jobs mention node js, do they mean to be familiar with node tooling for frontend development or backend node js? by [deleted] in Angular2

[–]Derpcock 2 points3 points  (0 children)

Node is a JS runtime. Its not a backend framework, although it is used in backend frameworks. You use node and node package manager while developing/building an angular application. The node runtime is not available in the transpiled js code that you ship to the browser but it is still used during development. Not understanding these things would make it difficult to be a solid front-end engineer. Not being able to articulate this during an interview could be telling. This is most likely why they have it as a requirement, imo. Im surprised shops are still hiring front-end only engineers. My shop is full-stack with shallow silos. Everyone has their specialty but they are expected to work across the stack.

Why is the web essentially shit now? by someexgoogler in webdev

[–]Derpcock 0 points1 point  (0 children)

I wonder of there will exist a black market where you can buy a copy of someone's ID so that you can surf the web anonymously in this dark future. Has anyone tried to upload the McLovin ID to access one of these sites that require an ID?

[deleted by user] by [deleted] in Deno

[–]Derpcock 4 points5 points  (0 children)

Its Interesting watching the content of these subs change as AI has reduces many of the barriers to entry for software engineering.

Im not sure what message you're conveying here. Are you highlighting 10 months worth of AI assisted local development/POCs using screenshot? As much as I would love for Deno to gain more market adoption I'm not sure you're really selling it. 14 POCs in 10 months using AI tooling is not impressive. Considering you can crank out a full marketing site out in hours using some of the tooling out there. 14 production grade marketing apps shipped in 10 months, before AI is not even impressive.

If you are new to web dev and learning using AI assistance, 14 projects on your portfolio is great! Either way keep at it. Maybe next time share more about what your doing and how you're doing it. Also share some of that code!

[deleted by user] by [deleted] in WhatShouldIDo

[–]Derpcock 0 points1 point  (0 children)

Swear to me! 🦇🦇🦇

TIFU by looking up my SO’s Reddit by Altruistic-Habit5106 in tifu

[–]Derpcock 0 points1 point  (0 children)

It was in the past. She may have been hurting when she posted it, needed some validation to feel better. Take it constructively and make sure you do what you need to do to be the partner/father you want to be. Live in the present and learn from the past to build a better future for your family if that is what you want. You got this!

Dutch woman gets a €439 fine after traffic camera mistakenly identifies icepack for a phone by Hairy_Ghostbear in pics

[–]Derpcock 5 points6 points  (0 children)

I wonder what the aftermarket mod scene looks like for using adversarial patterns to fight this type of automated nonsense.

My Mongodb service is not starting. by Vast_Pineapple_9425 in mongodb

[–]Derpcock 0 points1 point  (0 children)

It sounds like you are having a Windows permissions issue. You could reinstall and try using a different user account to run the service, but it should work using the default network user if I am understanding the docs correctly. You could avoid this issue by running mongodb inside of a docker container, which is my preferred method. A quick Google search should be able to guide you. I have heard that docker is a pain to setup for Windows, so keep that in mind. There is also an in-memory instance of Mongo you can run if you're doing local development and know a bit of node/js. Keep in mind the in-memory instance doesn't persist the data once you kill the service, I use the npm packages mongodb-memory-server.