D.Mentia
✅ Why is the attempted fix still creating a new copy of the dv each time CallDispose is called?
But then upon the value being changed, it creates a new instance, and then continues method execution from within that new instance apparently? IDK, weird
19 replies
✅ Why is the attempted fix still creating a new copy of the dv each time CallDispose is called?
So then... when exactly is the copy created? When it first enters the Dispose() method, it doesn't know that a value is going to be changed... so it must be entering it on the original instance
19 replies
✅ Why is the attempted fix still creating a new copy of the dv each time CallDispose is called?
tbh I don't get it :lul: like if it's creating a new DisposableValue when you set _disposedYet... which instance is that method running on, the old one or new one?
19 replies
✅ Why is the attempted fix still creating a new copy of the dv each time CallDispose is called?
I'm not sure I explained that accurately but the point is just that the
dv
you have a reference to is not the DisposableValue that has _disposedYet = true. Basically, use a class imo, or maybe dig into how structs work and maybe if you ref it into CallDispose you can make it work19 replies
✅ Why is the attempted fix still creating a new copy of the dv each time CallDispose is called?
which admittedly doesn't sound like it makes much sense when the struct is changing its own values, but I don't think structs typically have any logic in them, assumedly for that reason
19 replies
Questions regarding a linq query
I see, I think...
1. You're grouping by {otherPlayer, itemName}, resulting in one grouping per unique player/item. This means there are multiple groups for a given otherPlayer
2. You're ordering these groupings by price; I'm not sure the purpose of this, and it probably doesn't need to happen
3. You're grouping the new values by otherPlayer; now you have one grouping per otherPlayer, instead of multiple, and each 'row' in that grouping is quantity, price, etc for a given item sold to otherPlayer
4. You're ordering by the sum of prices; so, otherPlayers that have spent the least on all items are first in the results
Everything seems valid except the first order by
8 replies
Questions regarding a linq query
Don't know if I understand the question or the query... but, grouping by {otherPlayer, itemName} is creating one group for each unique pair of player,item - IE, a single player will have many groups, one for each item. It sounds like you maybe intended to instead create one group for each player?
8 replies
Which object creation method is more used?
Ex, Student(string Forename, string Surname), which you then change to Student(string Surname, string Forename) - you've accidentally broken everywhere that's using that constructor, and the compiler isn't going to tell you about it
30 replies
Which object creation method is more used?
Speaking of the actual topic, also worth mentioning, object initializers are more robust to changes. If you add or change the parameters of a method signature or constructor, call sites might still be compile-time valid even if they're now passing the wrong data. But if you change which properties are required, or rename properties, or add new required properties, object initializers will get renamed/updated automatically and will always show call sites that are no longer valid
30 replies
Which object creation method is more used?
I guess TLDR is that it can make dev slightly more tedious, but safer, which is sorta the idea behind a strongly typed language in the first place. And it invalidates a lot of bad practices that are common, which does usually mean extra work to fix those bad practices, but... they were kinda bad in the first place
There's no good reason to do
.Select(x => new Student { Id = x.Id})
instead of .Select(x => x.Id)
, but it's extremely common30 replies
Which object creation method is more used?
fair, you do still need validation in most cases, such as validating lengths of strings or whatever, so it's not perfect compile time safety. But it's the same compile time safety as a real method signature would be (as opposed to a method signature just taking the model as a single param), which is better than nothing
30 replies
Which object creation method is more used?
(that said, EFCore does give you some valid situations where you might want to do something like that, but even those are usually bad practice, such as using Attach on the entity - usually a bad idea as opposed to just querying the change-tracked entity and updating values on it)
30 replies