News for hackers. Stuff that matters.
Re:Push ifs up and fors down by theteapot on Wednesday November 15, 2023 @08:52PM (#38285011)
Interesting that dependency inversion principal -- [1] is like an extreme case of pushing ifs up by encoding the if into the type interface implemention. Ultimately what you get with DI is pushing an if up some to ... somewhere.

  # Somewhere:
  walruses = [new TransWalrus(), new FrobWalarus()], ...]
  ...
  for(walrus in walruses) { 
   walrus.transfrobnicaterify()
  }
[1] https://en.wikipedia.org/wiki/Dependency_inversion_principle
Re:Push ifs up and fors down by tubthumper8 on Thursday November 16, 2023 @12:21AM (#38286032)
This only works when `frobnicate` and `transmogrify` have the same argument and return types