Cyno

joined 1 year ago
[–] Cyno 1 points 3 months ago

Good point, that sounds nicer than just encoding the name for sure, thanks

[–] Cyno 1 points 3 months ago

Sure, but whoever's fault it was didn't really matter to me at the time. I just remember being annoyed at everyone constantly praising linux and saying how easy it is nowadays while I'm just jumping from one issue into another, that experience made me delay moving my main PC to it since I also have an nvidia GPU there. Had to go through like 3 different ways of installing drivers, various weird containers or bottles or wine and lutris or proton just for it all to constantly freeze or crash my PC.

It was a Dell laptop, not sure about specs but it's at least a few years old model, nothing too high end. The plan was to keep it as a small home server for hosting various stuff, services, media in the end, with varying success.

[–] Cyno 5 points 3 months ago (2 children)

I was so excited about Mint, seemed like the perfect distro to try but then I had nothing but issues on an laptop with nvidia. PopOS worked better right out of the box though

[–] Cyno 1 points 3 months ago* (last edited 3 months ago) (2 children)

A bit late to this thread but what helped me a lot was when I started doing TDD. By testing my code against tests before its fully done or even implemented in the main app codebase (so to speak), I could break down individual tasks in it more easily and see how its interior parts work. It seemed easier to separate it into SRP areas since they'd have to stick to the unit test for that responsibility. Do keep in mind you can take it too far and overengineer it in this way but it was a good kick in the butt to get me to think in a different way.

[–] Cyno 1 points 3 months ago

By automating it you mean something a store procedure that returns the ID and increments the count at the same time or is there a more sophisticated way of doing it?

[–] Cyno 1 points 3 months ago (1 children)

In the context of this small app im writing category is unique by name already so I can just use that if I wanted to go the string route, but agreed - yours is probably the standard way, youtube/reddit do it like that after all.

I'm still wondering about the technical implementation of it - where would you generate the string? Manually in backend before each save, probably using a locking mechanism to prevent accidentally creating 2 identical IDs at the same time? I'd have to do a db hit to make sure it doesn't exist already every time, right? Maybe I just try to insert and see if it crashes due to the uniqueness index? Maybe I use a store procedure in the database to get a unique ID? Do I just hash the timestamp or sth like that?

Whether I generate a number or a string, feels like I always open it up to many issues.

[–] Cyno 1 points 3 months ago (2 children)

This is something I've been considering too, since the name is in this case unique per user I can just use it for everything in frontend rather than the ID. It's not always a good solution though so I was wondering how would I solve it with IDs alone

[–] Cyno 1 points 3 months ago

Deletions would work the same way as with a regular autoincrementing ID, it just always goes up. All it matters is that it doesn't expose how many other IDs are in the DB

[–] Cyno 1 points 3 months ago (1 children)

I have a join table between Category and other entities that can be categorized in this way, but I dont think I need one between User and Category? Different users can't share the same category so it's a 1-n relationship, not n-n.

Even if I did though I still have the same issue since I have to figure out how to autoincrement it, only now in the join table rather than the Category table.

[–] Cyno 28 points 4 months ago (1 children)

You can kinda see this in things like modding communities or anything piracy related too. Users just want easy solutions even if it's at the expense of creators, and creators are doing it more and more for money rather than any personal drive or satisfaction. I can't believe we've reached a point where even mods are being locked behind paywalls, need to be commissioned or sometimes have entire teams funded by patreon to work on them, it's just another business nowadays.

[–] Cyno 2 points 4 months ago (1 children)

I have this instinct drilled into me for years that anything using reflection is bad, both in terms of performance or code clarity/ease of debugging. Your answer is correct though, I could make a generic method using reflection... now I'm just not sure if it's better to just manually hardcode the cases for all types anyway

[–] Cyno 1 points 4 months ago* (last edited 4 months ago) (1 children)

The switch case was based on an enum but it is what I want to get rid of. In the end I ended up doing what you wrote there, expect instead of casting I'm just writing

case Type.Int: return MyTypedMethod<int>(args)
case Type.IntNull: return MyTypedMethod<int?>(args)
// etc for another 10+ different types

It just feels like I'm doing something wrong if i have to manually handle every case in a switch (or if else) statement and I was wondering how could I write, for example, a method that would do the conversion from Type.Long to System.Int64 for me, and then I just pass that type into the generic method instead of having to manually translate it into a type every time it is used.

However, if I have to use reflection maybe hardcoding it manually every time is actually faster and easier to debug so maybe i'm just overthinking it.

That c# 7 structure looks interesting but not sure it solves my issue, I need to get to the part where i have the generic type T in the first place. I dont know how to get a "T" out of a custom field indicating type, so to speak.

edit: as for the invalid code, i just wrote it quickly as example but you are right. Pretend it says switch (field.SomeType) instead of it being a method

view more: ‹ prev next ›