4
jestdotty
15d

in JavaScript I would just call something what it is and then keep changing the data type as I get more data to add to it because you can

in rust because it's not dynamic types but static and everything is a static struct I need to find like 9 different names for all the different intermediary data types and holy shit I don't understand what to name everything and this is annoying me

I never understood why people complained about naming problems. I found it fun. now I hate it.

stats object. cool. well it converts an address to stats. an address has swaps. each swap was done on a mint. so I guess I make a MintStats object? wrong. because that's confusing.

swaps -> swaps divided by the mint they belong in -> stats for each mint swap set -> then you can add all the mint swap set stats to the address stats object

now what the fuck do you call all these

there's also something I called a MintAttitude and it's an enum. these types just keep growing out of trees. fuk. I don't like long names either. I should probably just call it Attitude but call it via mint::Attitude and get the same clarity result with far less redundancy (which I hate, another annoying thing)

swaps -> ??? mint history? -> MintStats -> then I have a "MintData" that has the history and stats wrapped in it -> MintsData that has many mints and their MintData -> then I can convert MintsData into AddressStats but what and I hate this and also I have a Mint object that does something totally different elsewhere. I hate this. data isn't even descriptive but to call something history when it also has stats seems imprecise.

brain spaghetti. classification part of my brain is shit. no historical training / experience either. I just see everything like vague blobs. bah. naming required clear delineations which is hard enough on its own to get used to

Comments
  • 2
    Like tsoding says, you've people caring about clean code and people that just get shit done :P

    Yeah, something i can't figure out what to do in naming is:

    - server_run

    - run_server

    prefixing with server is kinda nice since you'll have all server stuff together in autocomplete. But run_server is more natural but need some remembering.

    In dem old days it was very common to name your variables containing the type. Why that's quite clear, some people don't recommend it because of refactoring when the type changes. Ever heard of replace?

    I prefer long descriptive names above short names but in the C world it's quite common do small stupid abbreviations. For some reason, the weird abbreviations are very good to remember strncmp, strstr, strchr, fprintf sprintf
  • 6
    I don't think changing the meaning of a variable is ever a good idea. Unless its a generic function that takes in and spits out the data type you feed it.

    I won't do this even in Javascript.
  • 1
    Can you create a builder object that takes the pieces as you go and from which you can compound everything into a result?
  • 1
    @Demolishun IT'S HOW MY BRAIN WORKS

    IT'S LIKE CARS GOING THROUGH TUNNELS EXCEPT THERE'S WORKERS IN THERE THAT CHANGE THE WHEELS AND NOW YOU GOT A VAN, VROOM VROOM
  • 1
    @spongessuck sounds like more work instead of less!
  • 2
    @jestdotty would you rather code more or come up with more names :P
  • 0
    Can't you extend types by just doing something like this?

    type With(propname)<T> = T & {
    propname: proptype;
    }

    I'm unfamiliar with rust, but you could chain this together like so:

    type BaseUser = {
    name: string;
    mail: string;
    }

    type User = WithPermission<BaseUser>;
    //-> props of BaseUser & { perms: Permissions };

    type SystemUser = WithAdminFlag<User>;
    //-> props of User & { isAdmin: boolean };

    ...and so on.

    I like using this pattern which I've taken to calling "type promotion" in typescript.

    Defining all possible permutations of, say, a User and creating the "With"-types helps me immensely in naming my variables when using the types in code.
Add Comment