Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Dont Touch ME
Apr 1, 2018

Bloody posted:

okay now back to git subtrees please

So what was wrong with submodules?

Adbot
ADBOT LOVES YOU

psiox
Oct 15, 2001

Babylon 5 Street Team
when i tried to use git subtrees it was more of a pain than just using submodules- so i just hid that it was submodules from people with a good makefile/whatever tooling

psiox
Oct 15, 2001

Babylon 5 Street Team
imo git submodules are a known quantity of weird and the alternatives are worse

psiox
Oct 15, 2001

Babylon 5 Street Team
comedy option just keep all your deps in the same repo as different refs

https://git-scm.com/docs/git-worktree

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
make way for git subtrac

https://github.com/apenwarr/git-subtrac

CPColin
Sep 9, 2003

Big ol' smile.
I sleep in a big monorepo with my wife

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
is there any forking involved?

Ocean of Milk
Jun 25, 2018

oh yeah

Programmers really need to stop abbreviating random words in unconventional ambigous ways. Like, leg_hands is harder to read than legend_handles anyway, just leave it the gently caress alone, goddamnit!

jesus WEP
Oct 17, 2004


Ocean of Milk posted:

Programmers really need to stop abbreviating random words in unconventional ambigous ways. Like, leg_hands is harder to read than legend_handles anyway, just leave it the gently caress alone, goddamnit!
used to work in a financial domain where a lot of fields were like “cumulative amount” or “cumulative quantity”, so agreed

N.Z.'s Champion
Jun 8, 2003

Yam Slacker

Ocean of Milk posted:

Programmers really need to stop abbreviating random words in unconventional ambigous ways. Like, leg_hands is harder to read than legend_handles anyway, just leave it the gently caress alone, goddamnit!

only the first 6 chars of a variable matter to my compiler from 1980 so now you all must suffer

N.Z.'s Champion
Jun 8, 2003

Yam Slacker
even programmers who use actual dictionary word variable names will still cargo cult generics w/ single letters :(

Soricidus
Oct 21, 2010
freedom-hating statist shill

N.Z.'s Champion posted:

even programmers who use actual dictionary word variable names will still cargo cult generics w/ single letters :(

you can write List<TheTypeOfThingThatIsInTheList> if you like but everyone else is capable of learning what T means

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Soricidus posted:

you can write List<TheTypeOfThingThatIsInTheList> if you like but everyone else is capable of learning what T means

I actually hate using T or whatever for this it's unnecessarily unclear imho

method names is my other main hate though. like GetTheNameOfTheThingByTheIdOfTheThing(int id) or similar. just give it a shorter name like GetThingName and put a summary block on it ffs

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
imo when it's one type parameter like "this is the thing the collection contains" then it's fine

if there's two like a map from keys to values then it could go either way really, K,V is pretty clear but KeyType,ValueType wouldn't be too bad either

if you have more than that like AbstractOrganizerStrategy<T,U,V,W> then gently caress right off, give them proper names or get out of my codebase

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Powerful Two-Hander posted:

I actually hate using T or whatever for this it's unnecessarily unclear imho

method names is my other main hate though. like GetTheNameOfTheThingByTheIdOfTheThing(int id) or similar. just give it a shorter name like GetThingName and put a summary block on it ffs

here's a bike for y'all to shed:

assume your language supports method overloading and dynamic dispatch. which of these two styles do you go with:

1)

code:
getThing(id : uuid) : Thing { .. }
getThing(name : string) : Thing? { .. }
getThing(reference: OtherThingThatHoldsIndirectReferenceToAThing) : Thing { .. }
getThing(searchTerms: string []) : Thing? { .. }
2)

code:
getThingById(id : uuid) : Thing { .. }
tryGetThingByName(name : string) : Thing? { .. }
getThingByOtherClassReference(reference: OtherClassThatHoldsIndirectReferenceToAThing) : Thing { .. }
tryGetThingByBestMatch(searchTerms: string []) : Thing? { .. }

jesus WEP
Oct 17, 2004


Soricidus posted:

you can write List<TheTypeOfThingThatIsInTheList> if you like but everyone else is capable of learning what T means
something like IMapper<TInput, TOutput> is a good compromise of descriptive name and the T prefix signalling that it’s the generic type, imo

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

NihilCredo posted:

here's a bike for y'all to shed:

assume your language supports method overloading and dynamic dispatch. which of these two styles do you go with:

1)

code:
getThing(id : uuid) : Thing { .. }
getThing(name : string) : Thing? { .. }
getThing(reference: OtherThingThatHoldsIndirectReferenceToAThing) : Thing { .. }
getThing(searchTerms: string []) : Thing? { .. }
2)

code:
getThingById(id : uuid) : Thing { .. }
tryGetThingByName(name : string) : Thing? { .. }
getThingByOtherClassReference(reference: OtherClassThatHoldsIndirectReferenceToAThing) : Thing { .. }
tryGetThingByBestMatch(searchTerms: string []) : Thing? { .. }

the second thing and i hope to god the first thing doesn't actually compile because the return types are different. if the return types are the same, the first thing probably. unless one of these methods has wildly different efficiency or runtime costs than the others in which case back to the second thing. i'd only use overloads if it's fully a convenience thing and the different argument forms are like a oneliner pointer chase away from each other.

Ocean of Milk
Jun 25, 2018

oh yeah
First thing when I'm calling it and I know it's just gonna work when I feed it whatever because it's been written by someone much smarter than me.
Second thing when I have to actually look at the class in the IDE to understand what it does, let alone change it.

code:
// these are very probably gonna be one-line wrappers anyway
getThing(id : uuid) : Thing { .. }
getThing(otherThing : SomeOtherParamThatWillAlwaysReturnAThing) : Thing { .. }

// same, but with Optional return
tryGetThing(name : string) : Thing? { .. }
tryGetThing(otherThing : SomethingLikeNameThatMayNotFindAnything) : Thing? { .. }

 // A search may return zero, one, or multiple Things
searchThings(params : SearchParams) : ListThatCanBeEmpty<Thing> { .. }
is what I would write.

Things like getThing(directReferenceHolder: OtherThingThatHoldsIndirectReferenceToAThing) shouldn't exist, just do getThing(directReference: ActualMeaningFulReference), cause IDEs are smart enough to suggest getThing(thingWithIndirectReference.getActualMeaningfulReference()) to you.

Pseudo-edit:

quote:

code:
getThing(searchTerms: string []) : Thing? { .. } 
or
code:
tryGetThingByBestMatch(searchTerms: string []) : Thing?

I had to look at this thing in the second List to even notice what the idea was (by best match).

shoeberto
Jun 13, 2020

which way to the MACHINES?
Option 2 generally from a maintenance perspective, especially when you have a well-formed naming schema, ie "getThingBy[concept]", but otherwise try to keep the method names terse to make it not terribly obnoxious to use.

getThingById
getThingByClass
getThingByName
getThingBySearch

Don't put "try" in the names, since exception handling should be delegated to the caller. If your code expects a return and the specific get method doesn't have something, that's an exception. Make sure the get methods throw a specialized typed exception so callers can handle it appropriately.

Regarding abbreviation talk, we have a fairly active policy against them in any form. Find another way to make your variables terse that doesn't involve arbitrarily shaving out letters that are critical for context. Sometimes names need to be long for clarity. That's what IDEs and autocomplete are for. "legend_handle" is completely within reason imo.

Thank you for coming to my ted talk.

Bloody
Mar 3, 2013

Phobeste posted:

the second thing and i hope to god the first thing doesn't actually compile because the return types are different. if the return types are the same, the first thing probably. unless one of these methods has wildly different efficiency or runtime costs than the others in which case back to the second thing. i'd only use overloads if it's fully a convenience thing and the different argument forms are like a oneliner pointer chase away from each other.

lol why wouldn't the first compile?

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


I don't like the "try" bit either because whenever I've seen it it's been abused to mean "I don't know what I'm actually calling inside this and sometimes it fails and idk why so I'll call it 'try... ' and make the return type nullable", but that's because I see a lot of terrible code (and write it as well)

xtal
Jan 9, 2011

by Fluffdaddy

N.Z.'s Champion posted:

even programmers who use actual dictionary word variable names will still cargo cult generics w/ single letters :(

It's called math honey

Bloody
Mar 3, 2013

the first is correct. no need to repeat the type of the parameters in the method name, unless you're working in some hellscape like js or python where that isn't immediately obvious to the developer

Bloody
Mar 3, 2013

trygetthing is useful when set presence and value are both being determined at once, like in a dictionary. being given a return value alone is not sufficient without also signaling success in some manner, either by wrapping the T of the dictionary in a Result or by returning a (bool, T) by some means

Forums Medic
Oct 2, 2010

i be out there in orbit

Shaggar posted:

here's a bike for y'all to shred:

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

Bloody posted:

lol why wouldn't the first compile?

oh i guess it does yeah. it's kind of gross to me to do that though imo optionals shouldn't be covariant with concrete results

Bloody
Mar 3, 2013

yeah there's an issue there for sure. seems unlikely that get thing is gonna return a thing for every possible uuid but not every possible string

Ocean of Milk
Jun 25, 2018

oh yeah

xtal posted:

It's called math honey

If this is any indication, mathematicians also write at least a few lines of prose (often an entire paragraph) for every line of equations.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Phobeste posted:

oh i guess it does yeah. it's kind of gross to me to do that though imo optionals shouldn't be covariant with concrete results

the return type is irrelevant, they could return the same type or four completely different types and it wouldn't matter

the reason it compiles is because the _parameter_ types are unambiguously distinct (uuid, string, class, string list), so the parametric polymorphism can be statically checked

jesus WEP
Oct 17, 2004


i only like try in a method name when it’s a tryget pattern like bool TryGetGoodPosts(int userId, out string[] goodPosts). of course that example would always return false

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

NihilCredo posted:

the return type is irrelevant, they could return the same type or four completely different types and it wouldn't matter

the reason it compiles is because the _parameter_ types are unambiguously distinct (uuid, string, class, string list), so the parametric polymorphism can be statically checked

i get that i'm saying it shouldn't work that way because it's gross to have the kind of the return vary. the return varying by type (e.g. float -> float and int -> int) is fine but it's gross, to me, that you can have int -> int and float -> float?.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



it's fine, op

capitalizing method names, however, is a crime against humanity

Ocean of Milk
Jun 25, 2018

oh yeah
Yeah there's this notion in some OOP texts/systems that methods with different parameters but the same name are somehow "the same", which is bizarre to anyone used to method overloading in statically typed systems. The term "method overloading" itself becomes weird, like why do we even have a special name for the idea that getThing(name : String) and getThing(id: Uuid) are not the same method? There's no inherent connection between the two except you call them with the same name. But that's what arguments are for.

Corla Plankun
May 8, 2007

improve the lives of everyone
they are the same in the sense that anyone reading your code will gloss over the difference at first, and that is the only sameness that actually matters when you're talking about writing code for work that other people or future you will have to read

Bloody
Mar 3, 2013

if they have the same name then the differences should be gloss over able

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Ocean of Milk posted:

Yeah there's this notion in some OOP texts/systems that methods with different parameters but the same name are somehow "the same", which is bizarre to anyone used to method overloading in statically typed systems. The term "method overloading" itself becomes weird, like why do we even have a special name for the idea that getThing(name : String) and getThing(id: Uuid) are not the same method? There's no inherent connection between the two except you call them with the same name. But that's what arguments are for.

the reason they're connected is because oop subtyping can interact with dynamic dispatching in funny ways

code:
class geek
class nerd : geek
class dork : geek

getThing : geek -> thing
getThing : dork -> thing


var g : geek = random() > 0.5 ? new nerd() : new dork()

var thing = getThing(g)
some oop users expect this code to have a 50% chance of calling either overload. THEY HAVE PLAYED US FOR ABSOLUTE FOOLS

12 rats tied together
Sep 7, 2006

modern languages like rust, golang, python, et.c intentionally not supporting overloads is one of the best decisions each of them has made

CPColin
Sep 9, 2003

Big ol' smile.

jesus WEP posted:

used to work in a financial domain where a lot of fields were like “cumulative amount” or “cumulative quantity”, so agreed

My predecessor abbreviated "functional access profile" all over the place.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
it actually makes total sense for Calculator.Add(float, float) to return a float, while Calculator.Add(int, int) returns an int

Adbot
ADBOT LOVES YOU

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE
code:
tryGetThingByBestMatch(searchTerms: string []) : Thing?
i'd call this findThing, tryGet sounds more like it'll throw if it doesn't find a Thing

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply