« first day (1390 days earlier)      last day (3557 days later) » 

2:00 PM
$jsonConverter = new JSONConverter();

$jsonConverter->createUserJSONCollectionFromRowSet($rowSet)
how is the static method bad in this case?
 
@ziGi Yes, and the point is that the instance can now be injected into the places where you need to do that, so you can easily swap it out and you are no longer coupled the specific implementation of the UserJSON class
 
posted on August 06, 2014 by kbironneau

/* by ranucci */

 
are you talking about DI now?
 
Looking in this list now: amazon.com/s/…
 
yes
 
2:01 PM
I got you there bud :)
I see the whole picture now
 
user895378
lol @PeeHaa adding "The coding love" to Feeds was a brilliant moment of inspiration.
 
yep. I think I'll do the same to the JS room
 
@DaveRandom what is the difference between DI and Registry?
 
@ziGi Registry is still basically global state, it's just global state pretending not to be
 
and how is then DI not global but local?
you have a DI in each class you use and then you can insert in it create objects you need?
 
2:05 PM
yesterday, by Second Rikudo
@JoeWatkins can you add The coding love's feed to this room?
Thank you, thank you.
 
@ziGi Don't confuse DI with DIC
 
@DaveRandom yo :)
 
I don't know the difference :/
 
hi guys, i need one advice
 
Jul 8 at 7:56, by PeeHaa
Do you people mind if I add http://thecodinglove.com/ to the feeds?
 
2:07 PM
DIC is Dependency Injection Container?
 
@redaa What's your problem?
 
Everybody gets one. - Spiderman
 
@ziGi Dependency injection is a concept, a dependency inject container (which is what you are talking about I think) is a tool to make that easier, it's also not something you should go anywhere near until you understand the point of DI (or possibly ever)
 
@Fabien Yeah, but it was only implemented when I poked Joe about it
 
@DaveRandom I have used DI in PhalconPHP but it is implemented there so I just use it
 
2:08 PM
Somebody must have done a write up on this by now, surely? /cc @rdlowrey
 
I know that DI is preferred
 
@ziGi DI is a concept, it cannot be implemented by a framework.
 
since it allows for local access while Singletons are global
 
That's probably a DIC in Phalcon
 
@SecondRikudo it is a design pattern
 
2:09 PM
No.
 
and design patterns can be implemented
 
DIC can be considered as a design pattern
DI is a concept.
 
Dependency injection is a software design pattern that implements inversion of control and allows a program design to follow the dependency inversion principle. The term was coined by Martin Fowler. An injection is the passing of a dependency (a service) to a dependent object (a client). The service is made part of the client's state. Passing the service to the client, rather than allowing a client to build or find the service, is the fundamental requirement of the pattern. == Overview == Dependency injection is a software design pattern in which one or more dependencies (or services) are injected...
 
DI is better known as PP or "Passing Parameters"
 
Hm I think different people know different things
 
2:09 PM
There really must be some existing DI vs. DIC write up, surely?
 
@ziGi Here's a fun rule to follow: All functions must accept parameters.
 
@SecondRikudo How so?
 
@ziGi Think about this function:
function add() {
    $a = Singleton::getInstance()->a;
    $b = Singleton::getInstance()->b;

    echo $a + $b
}
Is this function useful?
 
@AndreaFaulds i have 3 tables, Orders, Buys, and Products.
i want to display all orders, and foreach order the list of products in it.
Orders contain id, price, date. Buys contains id, Orderid and products: products name.
in my code now i select * from buys WHERE orderid = 2; and store the result and foreach buy in the result i SELECT * from products where buyid= buyid;

now i need to do this in one sql query.
 
not really, why?
 
2:11 PM
Why is it not useful?
 
it's more of a procedure
 
@DaveRandom @ircmaxell's video is partially about clarifying that
 
^ /cc @ziGi
 
I don't understand why you would keep global variables and echo their sum in a function
 
The PHP.net site is not yet clear to me to learn OOP. I would like reading it in a book and learning it so.
 
2:12 PM
@ziGi How would you make it more useful?
 
What is the purpose?
 
@ziGi Adding two numbers of course.
 
Why is there no input
 
@ziGi How would you add that input?
Also, of course there's input
 
if you do
 
2:13 PM
$singleton->a = 5;
$singleton->b = 6;

add();
See? Input.
 
function add($a, $b) { echo $a + $b} and call add(Singleton::$a, Singleton::$b);
it's much better
 
@ziGi That ^ is DI.
 
yeah but it is not readable because you don't know the state of $a and $b
 
Because you are injecting the dependencies.
 
user895378
@SecondRikudo oh, woops. For some reason I thought that was @PeeHaa's doing. Don't mind me.
 
2:14 PM
Sure, but that example is kind of really simplified
 
The add() function depends on two numbers.
 
user895378
@DaveRandom a write-up on phalcon being stupid or a write-up on DI being useful?
 
@ziGi Of course, but the usefulness of DI is still relevant in more complex situations.
 
user895378
Because they're both true.
 
This example isn't that good, I'd just suggest @ircmaxell's excellent video: youtube.com/watch?v=IKD2-MAkXyQ
 
class LoginController {
    public function __construct(AuthenticationService $auth) {
@ziGi compare that to:
class LoginController {
    public function __construct() {
 
@AndreaFaulds can you help ?
 
I didn't remove the dependency, the LoginController still needs the AuthenticationService, but now it's hidden with global state.
 
@rdlowrey proper explanation of DI vs. DIC
 
yes I see
 
2:17 PM
As it's hidden, another developer coming to look at your code is going to have to look a lot harder to see what does what
 
but isn't that more confusing for the programmers?
 
And why ServiceLocator != DIC
 
@ziGi What is?
 
@Jimbo exactly
 
@redaa I'm not sure I can, sorry
 
Hiding the global state
 
It might be better to make a StackOverflow question
 
@ziGi Global state is used to hide dependencies
 
the question is why would you do that?
 
@ziGi Because the fastest way to end dinner is not washing the dishes.
 
2:18 PM
@ziGi Because it's easier and lazier
 
scroll keeps breaking ... someone fix it ... annoying ...
 
@DanLugg lulz
 
@SecondRikudo that's not very nice
 
@ziGi It's true though.
 
@Jimbo I would qualify that to say "...easier at first"
 
2:19 PM
You've eaten, BAM you're done.
 
It definitely does not stay easier
 
@cspray It's always easier
Eventually starting with dinner becomes a huge hassle
 
@cspray This is true. I can now typehint for anything anywhere and bam, I got what I want, no extra configuration
 
I prefer to do more job now to easen my job later
 
@SecondRikudo Eh, until you need to maintain it ;)
 
2:20 PM
But the fastest way to end dinner is to always not wash the dishes.
 
Fastest way to end dinner and get away with it is to not wash the dishes, smash them on the floor, blow up the house and do a runner.
(Code and run)
 
@ziGi That's a good approach
 
Should be illegal like hit and run
 
And I would actually go so far as to say that DI is easier... once you start doing it. Having to keep up with all that global state is eventually going to be not easy. It just has the perception of being easier if you don't know any better.
3
 
yesterday, by Second Rikudo
> Weeks of programming can save you hours of planning.
 
2:21 PM
Of course that's just my opinion ;)
 
@cspray The reason it's not is because they gave it such a superfluous name.
DEPENDENCY INJECTION!
Which sounds suspiciously similar to SQL injection, which is a bad thing
So beginners tend to avoid it
That's why I almost never say "Dependency Injection", I just say "Pass your damn parameters!"
 
PP sounds like PeePee though
 
@Fabien How's PA?
 
@cspray Before I learned about DI (and the rest of SOLID), I always got discouraged a few weeks into a new project. Changing things always became a hassle and progress slowed down considerably. Doing things right from the start makes life much easier.
 
Pass Arguments
 
2:23 PM
Personal Assistant. That'll do.
DIC PP...
 
No, it's not just parameters and arguments though
Some jockstrap on twitter tried to argue that
It's passing objects, not scalars
 
@Jimbo That's the base of it.
What's the difference?
 
So... Zeev opened an RFC for voting without announcing it. That or I never got the email.
 
@SecondRikudo Between an object and a scalar?
 
user895378
misko.hevery.com/2008/11/11/… <-- just watch that if you want to understand DI.
 
2:24 PM
@Jimbo As a dependency
 
@SecondRikudo If I have a method that takes two parameters, strings, I'm not using dependency injection to pass them in. If they take two objects, I should be using dependency injection.
 
user895378
"Don't look for things!"
 
@SecondRikudo Posted some more 'good' ideas
 
@Jimbo Again, what is the difference?
Also, how does that work in languages where everything is an object?
 
@SecondRikudo Scalars are not objects. They're scalars!
Primitives
 
2:26 PM
Ok guys, basically I use DI I just don't know it
:D
 
@Jimbo Sure, but that doesn't stop me from depending on a scalar/primitive!
 
You don't DI primitives. So when someone says "dependency injection is the smart way of saying use parameters", it's not. It's the smart way of saying "pass objects as parameters"
 
user895378
The type (object or scalar) is not the dividing line. It's whether or not an object actually has behavior.
 
user895378
A value object, for example, is no different from a scalar.
 
Thank you ^
That actually makes more sense
 
user895378
2:27 PM
And just because an object has methods you can call doesn't mean it has "behavior"
 
It does, sometimes I'm not good at explaining my point of view :P
 
However, @rdlowrey, how is add($a, $b) not DI?
 
Wich books have you guys here red about PHP programming? I would like to start myself a to-read-list.
 
Why does the behavior (or lack thereof) of a dependency matter?
 
@Duikboot first do, then when you ponder - read!
 
user895378
2:28 PM
@Jimbo It's okay, I've just gotten in lots of DI monkey-poo-slinging fights so I've been able to distill my beliefs down to require the bare minimum explanation :)
 
@Duikboot I would say don't look for PHP books... Find programming books that are language agnostic in my opinion
 
@SecondRikudo The difference can be seen here perhaps: It's not frowned upon to create new in-scope scalars in a method, like $a = 1;, but doing a new Service is.
 
@Duikboot What's your level?
 
user895378
@SecondRikudo It's just semantics at that point, but I wouldn't say $x=4, $y=6 are dependencies. The word "dependency" connotes that it has behavior, and scalars don't have behavior.
 
You mean to learn the structure of programming. Not about the language. For example learn design patterns instead.
 
2:29 PM
@Jimbo So newables vs non-newables?
cc @rdlowrey
 
Similarities? The local scope needs access to them. Differences? One's an object with behaviour, one's a scalar
I guess the inverse as some people say is don't DI newables
I get around that with a factory now
 
@Jimbo A Factory has a single very good and well defined purpose
 
@SecondRikudo To build and return objects
 
user895378
@SecondRikudo That's how I see it. If something is newable I have no problem instantiating inline smack in the middle of my methods.
 
@Jimbo To build and return object whose build process is not trivial and repeating.
 
2:31 PM
I am sorry to say that but I think code.tutsplus.com/tutorials/…
is better than ircwell explanation
 
@SecondRikudo
Well currenty: I am learning Laravel. I write custom drupal modules, I write custom wordpress plugins.. but that is not so clean.. I want to learn OOP... I like Laravel but I feel now I am at a level where I have think more about everything I write and there I am stuck. I tried also doing some basic MVC setups with Silex wich was ok but.. now im stuck and I want to move forward.
 
his explanation is good but for people that know how DI works
 
@SecondRikudo Nah, I move to the "just build" camp in that respect
 
and his examples are not that much extended
 
@ziGi BLASPHEMY!
> If all you need is a proof of concept, then I suggest that you don't waste time with dependency injection and proper architecture.
 
2:32 PM
@SecondRikudo I know he is your friend and supporting friends is good, but I am saying my humble opinion as a guy who has taught many others
 
I disagree with that statement
Proof of concepts more often than not turn into real production apps
 
@SecondRikudo You disagree with everything lately :P
 
@Jimbo I disagree with that notion.
 
xD
 
How do you make a proof of concept, can you explain with some sentences?
 
2:33 PM
@Jimbo I got impaled in the heart, then turned into an ancient evil goddess. So sue me.
 
user895378
@SecondRikudo Are you somewhere behind a proxy server to test if artax works for you?
 
What is the core of PoC
 
@Fabien cc ^
 
and what is /cc
 
@SecondRikudo I knew you were a transexual
 
2:33 PM
@rdlowrey I have a server that uses Tor, is that good?
 
Who was asking here about DI?
 
Question: With regard to PHPDoc's @since and @version, when documenting properties and methods, does @since refer to the version of the class or of the application?
 
I wasn't but they decided to tell me
 
@Jimbo It wasn't really by choice.
 
I have those notes in my Google Drive :p probably some answers from here: paste.jesse-obrien.ca/gRM
 
2:34 PM
@SecondRikudo Ooh I'm on the second disk of FMA (BH)
 
user895378
@SecondRikudo yeah fine. When you have a chance if you just composer install rdlowrey/artax (dev-master), include the vendor/autoload.php and run this is should "just work":
 
user895378
$response = (new Artax\Client)->request('https://www.yahoo.com')->wait();
var_dump($response->getStatus()); // int(200)
 
@Jimbo Nice :) Episode?
 
@SecondRikudo #10 - It's really good but really sad. I'm now just waiting for the violins to come on in each episode where they seem to inject drama
 
Did you watch the original FMA @Jimbo?
 
2:36 PM
@Fabien Nah I was warned away from that
 
What. 406
 
@rdlowrey is wait() here telling the line to not continue unless the request is finished making it effectively synchronous?
 
user895378
@ziGi yes. The client is totally asynchronous and using the wait() call just says "don't proceed until it's finished" -- that way you don't have to know anything about event loops or non-blocking anything to use it for synchronous things.
 
but then your code freezes if the internet connection is slow
 
user895378
@ziGi and how is that different from synchronous code using curl or file_get_contents?
 
user895378
2:38 PM
that's how all synchronous code works.
 
user895378
You obviously should never use wait() in a non-blocking application.
 
well you can always use threads
:D
 
user895378
@ziGi yes, lets install a non-standard extension.
 
user895378
No.
 
user895378
Not when you can achieve concurrency without it.
 
2:39 PM
@rdlowrey Could not parse version constraint (dev-master): Invalid version string "(dev-master)"
 
can anyone tell me what /cc is and what is the core idea and content of a "proof of concept"
 
user895378
@SecondRikudo try 0.8.x-dev
 
I'm running this @rdlowrey
./composer.phar require 'rdlowrey/artax (dev-master)'
 
@rdlowrey Needs a static declaration on the function github.com/rdlowrey/Artax/blob/master/lib/Cookie/…
 
user895378
@SecondRikudo try ./composer.phar install rdlowrey/artax ? I'm still a composer noob
 
user895378
2:41 PM
@Danack it does. fixing momentarily.
 
@rdlowrey I asked the room people, but it was shot down. @JoeWatkins eventually added the thing either way so I won't complain :D
 
@rdlowrey I got a different error
 
user895378
@PeeHaa oh okay, that's what I was thinking :)
 
[dor@importa artax]$ composer require rdlowrey/artax
Please provide a version constraint for the rdlowrey/artax requirement: dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for rdlowrey/artax dev-master -> satisfiable by rdlowrey/artax[dev-master].
    - rdlowrey/artax dev-master requires bagder/ca-bundle dev-master -> no matching package found.
 
user895378
@SecondRikudo Okay, try this instead:
 
user895378
2:42 PM
git clone github.com/rdlowrey/Artax.git
cd Artax
../composer.phar install
 
@PeeHaa shot down? it got 7 stars :P
 
user895378
or try dev-master#422c286893f08473ef44ae2a85295c088a7a1386
 
Yeah, but @DaveRandom didn't like the idea and I always do what dave tells me to do :D
 
paste.jesse-obrien.ca/gRY that a good exersie as start to learn oop
 
So what is /cc
or cc
 
user895378
2:46 PM
@ziGi "carbon copy"
 
oh, like in the email
I saw that you guys are using it here that's why
 
user895378
Yeah. It's a throwback to old school when you had to write on special paper to make copies of things :)
 
I know what carbon copy is
but cc has a few meanings, that's why I was wondering
 
Dirt sandwich
 
cc = closed captioning, common criteria, classification of construction
chief complaint
carbon copy
coupled cluster
compiler construction
 
2:49 PM
Cubic cunt
 
Works well @rdlowrey
 
crusty chump
 
I get an int(200)
And when I used it to access icanhazip I see my Tor IP, so seems like it works well :)
 
user895378
@SecondRikudo sweet. that makes me very happy :) the proxy functionality (especially in tandem with securely encrypted things) is really useful and it's really important for protection from the NSA etc.
 
@rdlowrey Yup
To the NSA operative who's assigned to monitoring this room: Fuck you. Artax has proxy support now!
 
user895378
2:51 PM
#DealWithIt
 
@rdlowrey Can you bind a request to a proxy too?
 
user895378
@SecondRikudo yes.
 
Without having it as a system overlay?
Awesome, I'll start refactoring my app that currently uses curl with a tiny wrapper.
 
user895378
example incoming ...
 
@PeeHaa I don't remember this, I deny all responsibility
 
user895378
2:53 PM
$response = $client->request($uri, $options = [
    Client::OP_BIND_IP_ADDRESS => $addr
]);
 
@rdlowrey is it safe to use [] instead of array()
 
Every anti- #ORM talk that I’ve discussed over the last 4 years, answered in synthesis: http://goo.gl/KG8Cnm Thanks Gavin!
sorry, had to vent :P
 
@ziGi Depends on whether you like using outdated software
 
user895378
@ziGi PHP didn't exist prior to 5.4 as far as I'm concerned.
 
hahaha :D
 
user895378
2:54 PM
@SecondRikudo Alternatively you could set the bind option client-wide via $client->setOption(Client::OP_BIND_IP_ADDRESS, $addr);
 
user895378
And not have to do it per-request
 
My chump colleague told me he knows about it but it is safer to use array()
 
user895378
Your colleague is wrong.
 
cause he said he didn't like that
and we have to refactor
 
user895378
@Ocramius I don't tell other people not to use ORM if it works for them. It just doesn't work for me :)
 
2:56 PM
@rdlowrey And $addr being something like http://localhost:9040?
@ziGi If you only support PHP 5.4 and above, it's perfecly safe.
 
yes we do
how can I convince my colleague it is good to use it
 
user895378
@SecondRikudo perhaps I misunderstood what you were asking with regard to bind. The examples I posted have to do with the address used to construct TCP packets for a connection. Can you tell me what you are asking about in slightly more detail?
 
@ziGi let me guess, he also doesnt like namespaces?
 
yes!
he said it looks ugly
 
user895378
(you can just post the relevant curl option you're speaking of if you want)
 
2:58 PM
@rdlowrey Let's say I want my request to go through Tor
@rdlowrey Hold on
 
user895378
@ziGi I guarantee that if you ask him to define "safe" he won't be able say anything that doesn't sound stupid.
 
@Patrick how did you know
 
@ziGi Chump developer is chump.
 
curl_setopt($ch, CURLOPT_PROXY, "http://127.0.0.1:9050/");
curl_setopt($ch, CURLOPT_PROXYTYPE, 7);
@rdlowrey Is there an equivalent to this? ^
 
he said it is not a problem that I use [] but it is cooler to see that it is 'array' when it is array()
 
user895378
2:59 PM
@SecondRikudo Oh, artax does that automatically based on environment variables passed to the php binary. But you can manually specify it if you want.
 
and then again we have to change it everywhere so use array() for the moment
 

« first day (1390 days earlier)      last day (3557 days later) »