grates on me when I hear programmers talking about using “constructor injection” or “setter injection”. Sorry, but what you’re talking about is “passing parameters”, or if you prefer “passing arguments”.
And you're a retard - DI is not passing scalar values about...
I feel like writing a blog post "Why Dependency Injection is not programming 101"... when working with medium to lage codebases unless your bootstrap is just a complete mess it's not simple to inject everything in the right place
@Jack If you have a medium to large codebase, it isn't simple to just inject everything in the right place. You'll need a DiC for that, so it's not programming 101
It's not just the concept right? It's how to employ it and use it properly
@JoeWatkins I figured that might be the case, being that static is not supported for args. Why is that exactly? I made a mental wild stab in the dark that the class entry to check against is stored at compile time and cannot be altered at run time for some reason, but I couldn't come up with a good reason why it couldn't be fetched dynamically during run time checks
@JoeWatkins Yeh fair enough. The lack of static seems to be very slightly, in a way, at odds with the covariant behaviour of explicit classes, but I can totally see your point
@SecondRikudo lol. DI would be overengineering and slow (because I'd need to parse annotations and then use reflection to assign value), so I am proud of my fast service locator and flexibility. Now ban me if you want/can. :p
I'm able to find store having lowest & highest price of a particular item but cant retrive what store has that item at that rate. pastebin.com/mPQ8KSNB any suggestion to fix the bug?
@Leri No but... use one that caches those reflections for you. I literally place the DiC where the controller instantiation happens, read aliases for concrete -> interface from a config file so you can do your runtime polymorphism and that's it for the whole project
@Jimbo Yeah, but android is pretty f*cked up there because it preference inheritance over composition when it comes to Activity/Fragment (think of controller in terms of MVC). That forces you to create unnecessary hierarchies. IMHO, that's dirtier that SL.
@Leri I feel you bro. There is alternatives to Google's Activity/Fragment right. Sane people who wrap Activity/Fragment into a more (real) developer friendly components.
public static function getInstance() : self { return new static(); } valid public static function getInstance() : self { return new self(); } valid
so no point supporting static I don't think ... plus it's horrible ... I can see the use in supporting self, but since it's meaningless to distinguish between the two because of the nature of the check being performed why complicate things I think ...
@JoeWatkins Yeh but hinting for static could imply a lot more functionality (I'm think in terms of IDEs here)
class A
{
public function super(): static { return $this; }
}
class B extends A
{
public function a() {}
public function b() {}
public function c() {}
}
Don't worry I'm not trying to persuade you to do it, just sayin' is all
@JoeWatkins not really relevant, consider that if I hint for self and I do $b = new B; $b->super()->a(); then the IDE will probably go "nope, super returns an A, you don't have the method a() available"
@JoeWatkins Indeed, it's basically for the sake of self-documenting code. Like I say, I'm not trying to persuade you to do it if it will anger the bison.
also, not that I like the idea but I have heard it mentioned, static blocks in class entries... that syntax might disbar us from doing that .. or at least make it messier and have to expect++
@Leri Well, they are kinda negated, despite not being formally supported, by the fact that you can just run something in-file, which'd be like a static constructor.
@JoeWatkins What's the use case? Notably, where is that used in Java where simply putting that in main() or a constructor wouldn't accomplish the exact same thing?
@DaveRandom I can speak from C#. Since it's compiled, unless you dynamically load assemblies, all static constructors should fire on initialization of the application assembly.
think they are, think their proper name is static initializers because nothing is being constructed is it ... I don't remember a version without it ...
not really advocating it, but don't like to put anything in the way of another feature ...
Opencart: I'm able to run the loop and get the values out of the conditional assignments. But am not able to get whose value it is. the loop also runs hypothetically, echo'ing shows it doesnt have logic but output is perfect http://pastebin.com/mPQ8KSNB
@DanLugg Yeh but you'd do somemodule.someclass.init() from main(). You can see from main() what's be initialized. In a way I guess this is a stylistic preference, but I'd rather do it that way - I don't want black boxes magically doing shit unless I asked them to
@DaveRandom It's magic. What you're suggesting should work equally well. I forget when static constructors are called with respect to main; might be before. But yes, explicitly calling them should have the same effect in most cases.
Oh wait; okay. In C# its only before the first static member being referenced, or the first instance being created.
@DanLugg That I can sort of get behind I suppose because the consumer triggered it, but I see no reason why it couldn't just be defined as a regular magic method (public static function __init() or sth)
@DaveRandom Actually yea. Given those rules, it'd basically be like dropping top-level code into a class file. Because both circumstances would both be covered with autoloading in PHP.
@DanLugg Oh that's very true, there's really no point in it in PHP. That also neatly illustrates just how wrong it is IMO, if I ever see class Foo {} Foo::doStuff(); I generally close the file and pretend I didn't see it.
java is an enterprise language, and code that is never looked at is horrible ... they have to exist in a world where nearly all code is horrible, nearly all libraries are incomprehensible and huge, nearly everything is a mess, the justification could simply be the more options you have, even if they would appear hacky and promote bad practice, the easier it is to make enterprise from all the shitty code and practices ...
what we wouldn't show to our friends the enterprise are happy to sell to their customers ... for damn sure ...
@DaveRandom And stop using that file. And the package from which it hails. And anything by the author of said package. Or his children, or friends, or previous dog's owners sister-in-laws.
@DanLugg Yeh. Especially the last one. I hate her, always showing up at my house and asking to borrow a cup of sugar or some eggs or one of my children.
you know, there's no psr, there's no standards almost, there's only that which the language allows or enforces for java ... bear that in mind when I say, I've used it before ... php is just getting used to the idea of packages, composer and what not, fast forward twenty years .... imagine the huge range of things that will be out in the wild, that people will build upon, that's where java is, I've had to use it just because of the strange way in which some library is designed
That's not to say I think "GOLLY GEE THESE ARE TERRIBLE LIKE THAT SISTER-IN-LAW", but I've just never found a practical use for which there wasn't a more sensible (given whatever circumstances) workaround.
it's easier for me to write static {} and ignore what I am doing than cost the project I'm working on another week ... always ... in enterprise programming that's what we think about ... not "what will reddit users think" ...
maybe 20 is too optimistic ... I hope it's different ... I hope in my lifetime, I'm wowed again ... I hope something comes along that is completely different or we're not moving forward ...
The Singularity Is Near: When Humans Transcend Biology is a 2005 non-fiction book about artificial intelligence and the future of humanity by inventor and futurist Ray Kurzweil.
This is his first book to embrace the Singularity as a term, but the ideas contained within are derived from his previous books, the The Age of Spiritual Machines (1999) and The Age of Intelligent Machines (1990).
Kurzweil describes his law of accelerating returns which predicts an exponential increase in technologies like computers, genetics, nanotechnology, robotics and artificial intelligence. He says this wil...
Raymond "Ray" Kurzweil (/ˈkɜrzwaɪl/ kurz-wyl; born February 12, 1948) is an American author, scientist, inventor, futurist, and is a director of engineering at Google.
@DaveRandom LSP violation, it shouldn't be available in that case, because you're calling a method on A, that can't know about additional information in child classes. Hence, you're violating LSP, and therefore it's ok to not support that case
so ... pretty funny right ?? I mean it's pretty funny that hhvm is the software that solves all our problems yet here we are, a few months in, reading a page in the manual that is a direct result of a ... flawed type system ...
not a flawed type system, a flawed implementation of it.
as they can absolutely do those sorts of checks they claim to not be able to
either 1) At compile time, spend another pass looking at possible inheritance and doing the checks there, or 2) at runtime when running the instantiator...
yeah that's what I mean .... in short, they fucked up ... that would not be allowed to pass, internals might have their problems, but not in a million years would that get passed ... crazy decision ....
can you point to another language, in use today, that does that ? I can't think of one, wouldn't be surprised if there isn't one, because it's a horrible decision to let limitations of your software bubble to the surface when they are avoidable, provably, by every other team I can think or know of that tackled the same problem ...
you could argue if it's good practice or not, but for it to error out, is most definitely a limitation (a warning may be appropriate, but an error is not)
@ircmaxell I personally like this idea of checking eagerly. I don't see why a constructor would, for example, need to call a metod that can be overridden
"It is very important for Hack to be able to check the codebase quickly.....Here is an example of the first fix: doOtherInit()" - that sounds like something I'd fuck up.
Java solved that particular problem with class casting. Which I think is a better approach than just blatant "let's add magic language constructs which do nothing but tell the compiler how to interprate things"
/me needs to step away. This is like a minefield of weirdness
@ircmaxell At least, from looking at Joe's patch I don't see why a colon is there. Is it just copying a syntax from somewhere else (Hack)? /cc @JoeWatkins
@ircmaxell From my experience in C# it leads to: if (foo != default(<Insert type of Foo here>)) { code }
@andho You have to do neither. You should know when your method may return null. It's insane to check for null when variable was just created by factory (unless you explicitly define that factory may not create object).
@Leri all this syntax inside code statements make it so hard to read code (referring to the Insert type of Foo here thingy there). Method and Class declarations I could tolerate
@Leri Oh likewise, I don't find anything unreadable about it. I'm just saying IME that quite often types'll be constrained to an interface. Even structs implementing the interface are boxed/nullable (IIRC)
@DanLugg Yeah, when you have where T : ISomeInterfacedefault(T) == null. Anyway, I rarely use that kind of constraints. Mostly I have where T : class. Because if I know interface, I don't need generic [in most cases].