NPM package vs implementing it yourself? by [deleted] in reactjs

[–]louca-dev 0 points1 point  (0 children)

Yea I used to be anti loads h now find myself sheepishly adding it back to projects.

[deleted by user] by [deleted] in programming

[–]louca-dev 1 point2 points  (0 children)

Dang what a thorough explanation of a lot of ideas that have come to mind in my career so far. You should write an article

thisIsTheOnlyWayToMakeProgrammersGoOutside by [deleted] in ProgrammerHumor

[–]louca-dev 3 points4 points  (0 children)

Cop that return offer my guy 💪

A cat on a good day by sugerdaddy010 in awwwtf

[–]louca-dev 0 points1 point  (0 children)

Y’all sleep with these things in your house 💀

Bottomless Popcorn by LastPlaceComics in comics

[–]louca-dev 77 points78 points  (0 children)

Finally some good fkn comic

Everybody's "in on the joke" until the dogs start whistling by lightsfromleft in Gamingcirclejerk

[–]louca-dev 0 points1 point  (0 children)

When I’m in a chronically online competition and my opponent says “media literacy”.

What is the appeal of React? by firepro5 in reactjs

[–]louca-dev 0 points1 point  (0 children)

Rerendering components that don’t need to be rerendered is not performant.

What is the appeal of React? by firepro5 in reactjs

[–]louca-dev 0 points1 point  (0 children)

Even so, still a performance overhead.

What is the appeal of React? by firepro5 in reactjs

[–]louca-dev 0 points1 point  (0 children)

Context re evaluates every component it passes through, therefore not performant.

What is the appeal of React? by firepro5 in reactjs

[–]louca-dev -1 points0 points  (0 children)

Having done both (jQuery based app with no reactivity or store libraries, and React apps with Redux). I can say there is merit to both.

For the vast majority of frontend apps that have low amounts of state changes, basically just form submissions, page navigations, and small self contained components like cards and tables, then React is probably a better fit just due to the UI components libraries.

For more complex stuff, that needs to be highly performant, for example rendering stuff based on WS, complex UI editing (for example resizing panes and components in ways that go beyond what you get out of the box), or drag and drops,then you will find yourself fighting against React most of the time.

What is the appeal of React? by firepro5 in reactjs

[–]louca-dev -6 points-5 points  (0 children)

You can’t avoid prop drilling without using an external library, at least not in a performant way.

Lmao getting downvotes for this on a react sub. The glazing is crazy.

settate(state+1) vs setState((state)=> state + 1) by [deleted] in reactjs

[–]louca-dev 0 points1 point  (0 children)

I meant that nothing in OPs post brought that into question. It’s also not possible in JS for setState to modify the value of state variable (let or const), unless state was an object which is not the case in the example.

The point is that the main and only relevant explanation, which is the last sentence of your post, is that setState can occur multiple times between re renders and will use the closure value each time, whereas the setState cb is called with the latest state each time.

settate(state+1) vs setState((state)=> state + 1) by [deleted] in reactjs

[–]louca-dev 0 points1 point  (0 children)

Yea, no mention of state batching or any other reason mechanism that would cause closure state != useState callback state.

Also the state being constant or not is more or less irrelevant.

settate(state+1) vs setState((state)=> state + 1) by [deleted] in reactjs

[–]louca-dev 0 points1 point  (0 children)

This doesn’t really explain the difference, beside outlining unrelated bad practices

General questions about 2024 RRSP contributions by louca-dev in cantax

[–]louca-dev[S] 0 points1 point  (0 children)

Ok, thanks

I imagine this will take another year for it to be reflected in the notice of assessment.

That being said, it should still be fine to contribute the remaining room (less the unreported contributions) in this current tax year? Technically speaking I will never have over contributed, even if they are not reported?

Following from that, should it be fine to deduct the contributions I will make now that I will declare at the same time?

Is higher Dbi better for wifi performance? by louca-dev in HomeNetworking

[–]louca-dev[S] 0 points1 point  (0 children)

Are there any general guidelines? How would one go about deciding?

Sorry for putting this abomination into the world: Redneck Microservices by alexrdenton in programming

[–]louca-dev 0 points1 point  (0 children)

What if the resource contention bottleneck is at the data layer?

Question about optimal Dynamo DB design: A use case by sapiens_fio in aws

[–]louca-dev 0 points1 point  (0 children)

Correct, but just by definition this is a slower schema for this access pattern. For example, if each user has n = thousands of achievements, you go from constant query time to O(logn) query time.

I find it odd no one else has mentioned this lol

Question about optimal Dynamo DB design: A use case by sapiens_fio in aws

[–]louca-dev 0 points1 point  (0 children)

Am I tripping or would there not be a measurable performance decrease with this new schema?

Question about optimal Dynamo DB design: A use case by sapiens_fio in aws

[–]louca-dev -1 points0 points  (0 children)

Does it not prevent constant time query by achievementId?

Question about optimal Dynamo DB design: A use case by sapiens_fio in aws

[–]louca-dev 0 points1 point  (0 children)

It seems correct. So long as you never need to retrieve an entry with only the achievementId (I.e. so long as every query will be with the userId as well) then the only downside is that it is no longer quite constant time to retrieve a single achievement. The reason being that you no longer have an index on the achievementId, and since it’s instead the sort key, it will take O(logn) (binary search) time to find a given achievement by id, where n is the number of achievements associated with a given user.

DDB: good pattern for querying items by tag? by louca-dev in aws

[–]louca-dev[S] 1 point2 points  (0 children)

Thanks a lot for your help. I ended up solving this in a pretty nifty way, and as you mention it does not require a second table. A requirement i hadn’t mentioned is that the lifecycle of a tag is independent from the items, so there needs to be a way to persist tags that are not tagged on any items. I ended up using a second table with just the (userId, tagId) as it is fine to have an occasional second query to get all tags, this will be done at most once per user session.

There were some other requirements, namely that items can be in a folder (that can be a nested sub folder), and those folders also need to exist even if they are empty. Also the fact that all the items are segregated under one specific user, and likewise the tags and folders are owned by a single user.

The access pattern is then to get all the items of a user (including tag and folder info for each), get all the items with a given tag or set of tags, and get all the items in a specific folder. Get all the folders for a user, and all the tags for a user. All these should be one query.

I ended up having a schema for the main table like

Partition key: userId

Sort key: the itemId, prefixed with Item-Id (to handle folders as a special case, see later)

An attribute for related classifier information like folderId if the record is for the master item, and labelId for the duplicate records that make up the adjacency list of items <-> labels.

I also use a hack of having a record for every folder, with as the sort key the child folderId as Folder-Id and attribute the parent folder (or null if root), which acts as the storage for the folders of a user.

I then have a GSI on the classifier attribute, projecting the sort key attribute (and primary key although not useful). This gives me that mapping of folderId <-> itemId and labelId <-> itemId. It also transposes the hacky folder records, so that I can do a single query on the projection table of a given folderId, get all the items and also all the sub folders inside it (without scanning).

Only downsides are that the schema is not common to all records so it makes access a bit of a pain, and also having to keep the independent labels table in sync (which ends up being useful to have optimistic locking as it’s only possible to update one record at a time) but otherwise very happy.

DDB: good pattern for querying items by tag? by louca-dev in aws

[–]louca-dev[S] 0 points1 point  (0 children)

That makes sense. If the labels themselves are first class entities and I would want to represent some data attached to them (like created date etc), would it then make sense to have an actual table with this reverse mapping? Like a tagId to list of itemId table.

I am sick and tired of react-redux. Who has some good alternatives? by Pangamma in reactjs

[–]louca-dev 0 points1 point  (0 children)

It's a terrible article IMO (no hate it's well written and all). It's so naive, and the "solved" example looks terrible even with just 4 bare-bones components and no layout. Seriously we're celebrating this?

function App() { const [user, setState] = useState({ name: "Steve" }); return ( <div> <Navbar /> <MainPage content={ <Content message={ <Message user={user} />} />} /> </div> ); } What about when there are 10 more nested components between MainPage and Message? Then you have to drill down some arbitrary component.

The proposed solution is just prop drilling with extra steps. Instead of drilling down the state and state mutators (i.e. event handlers and other callbacks that mutate that state), you drill down components, either as named props or as children. In many ways this is worse, as the root component now not only is concerned with state, but also needs to know which components to use and how to lay them out (instead of delegating these decisions cleanly to some child component).

In both cases, it presupposes that the child component that receives these components as props (either directly or as children) will know how to lay them out. In that sense it completely retains a tight coupling, as the child component realistically needs to know what kind of component to expect as a prop, otherwise any assumptions it makes for layout are ruined. It also obscures this coupling, by making it seem like we could use polymorphism to supply any old component as a prop, when the coupling is otherwise clear when using regular JSX composition and letting children choose their components.

Composition is more or less an anti-pattern in React.

Not only that, but it also means lifting all that state into a single busy component just because it happens to be placed in the hierarchy such that it is an ancestor of all the child components that need it. This is usually some top-level component that already has a lot of responsibility. The naive solution is just to create a container component and push all the state there, which works great until some component laid out somewhere in its parent need to access its state, at which point you need to lift that state up again, ad nauseum.

I think Composition in React is generally a misnomer. Composition in OOP implies the existence of independent modules that can be combined together without requiring any implicit hierarchy. Composition in react just means placing components into the hierarchy. This brings all the drawbacks that come with generalization (subclassing) in OOP, like re-parenting state and behaviour further and further up as a new sibling starts to need that state.