« first day (720 days earlier)      last day (4222 days later) » 

7:01 PM
not sure it would be a good idea
 
That's fine
 
@Stephane , keep in mid that the article is from publication in 2004 .. and Fowler for long time has been dismissing the LoD
 
I like differing opinions. It helps me figure out where I stand rather than just following a crowd.
Code has to be pragmatic, not just utopian.
 
the problem with service locators is that code becomes hard to reuse
 
Because you have to keep amending it to work with each serviced class?
 
7:07 PM
because you do not know what classes your locator is trying to instantiate before the code is executed
 
I get that. Thanks
 
that's why alternative name for Service Locator pattern is Registry
 
user895378
Service Locators can also making tracking down bugs a nightmare. When every object has universal access to every other object of the application (through the service locator), it can be difficult to know exactly where the problem lies. You can follow every execution path in your application trying to figure out which bit of code is actually misbehaving.
 
Also, I don't know what your hesitance is, but this is a personal project I've been trying to get help on. I'm very excited about it, but I also don't want to write it how I've written past projects.
@rdlowrey ah. That makes sense, too. Is there a benefit to them in sharing data? Do they fit some idea that DI doesn't work with?
I haven't used locators much. Does this also apply to observers in any way?
 
user895378
@Stephane I don't see one. There's good reason for OO concepts like encapsulation and the Single Responsibility Principle. A class should do one thing -- not act as a crossroads for lots of classes to share information.
 
user895378
7:12 PM
When you have a well-named class whose dependencies are clearly spelled out in the constructor you can extrapolate in one look exactly what the class does.
 
user895378
For me, objects are really about reducing complexity. When you dump a bunch of shared services into a class you've only muddied the waters.
 
What's the best way to make a large number of changes to a db? Sorta like preg_replace except mySQL
 
@SomeKittens You can do regex in sql
Might be painful slow though
 
Doesn't matter, I only need to do this once
bad migration
 
user895378
@Stephane Especially in large applications your objects must adhere to SRP. When you have tons of classes you need to be able to instantly determine their respective purposes. Otherwise you can lose your sanity. Not to mention that if someone else ever has to maintain your code it's even more important that they too be able to easily parse what your API does.
 
what he's referring too is principle of least astonishment
the code should do what you expect it to , and not contain any hidden dependencies or unrelated functionality
 
@SomeKittens In that case go for regex in sql. Just make sure you have a good backup.
 
@rdlowrey That makes sense. Where I'm still a little confused from a procedural environment is how to update two records in two different places based on the results of updating the first. For instance, if a record was over a threshold and I wanted to write a log entry or update a database record that uses the data from the first record.
I've seen observers used for this. I may have gone off on a tagent.
 
user895378
@Stephane Pluggable actions through thing like the Observer or Mediator don't really relate to this discussion. It's important to distinguish though -- a Mediator pattern pattern is not the same thing as a service locator.
 
7:18 PM
I'm clear on that. I'm just thinking about class interactions, now.
 
user895378
@Stephane @ircmaxell has a nice answer on this topic if you're interested:
 
user895378
22
A: PHP Event-Listener best-practice implementation

ircmaxellWell, there's really three different ways of doing this from an implementation perspective (note that these are OO design patterns, but you could implement them functionally or procedurally if you wanted to). 1. Observer Pattern You can implement the Observer Pattern. Basically, you'd have eac...

 
Thanks
 
user895378
As it relates to having other objects respond to, say, a database record being saved ... I generally inject an event mediator instance into the constructor of the data mapper I use to persist the data to the database and attach listeners for the relevant "save" event.
 
user895378
This is one place the popular ORMs really suffer -- my experience is that they all use crappy static methods to persist your data and this makes injecting an application-wide event mediator extremely difficult.
 
7:21 PM
@rdlowrey wouldnt that mean that you have one mapper per domain object ?
 
Observer and Mediator seem limited in what they can pass if you want to use them in a general way. I'm used to passing data and messages.
I've been thinking about the decorator pattern a lot this week. I'll look for more examples of that. Thanks
 
user895378
@tereško I don't necessarily have a one-to-one mapping like that. In all honesty I'm still working out the kinks in my own personal understanding of how best to persist data to the backend in an OO environment.
 
user895378
I'd say @tereško is more knowledgeable when it comes to specifically how to model your DB interactions.
 
@rdlowrey welcome to the club , line forms on the right side =/ ... most of us here are "working out the kinks" in our understanding
 
user895378
Right now I seem to be spending (wasting?) an inordinate amount of time trying to reconcile how best to persist relational data in harmony with OO principles.
 
user895378
7:26 PM
Oct 2 at 13:44, by tereško
i find it hard to be proud of any code that i have written more then a month ago
 
user895378
^ Couldn't agree more with that
 
@rdlowrey Ha, I am in the right place. Except for me it's more like I find it hard to be proud of code I'm going to write. Still feels good when things work even if they aren't right structurally. I'm glad I have projects that hundreds of people use. It puts it in perspective. I might not know a lot about OO (but thanks to you guys it's starting to be less fuzzy), but I can still make something that works.
 
What's wrong with this SQL? "UPDATE jos_easyblog_post SET content = REPLACE(content, 'http://convert.mspwebsite.com/images/easyblog_images//4072', 'images/easyblog_images/4072')"
It's not updating anything
 
7:32 PM
if there are no rows with that particular string in them, 0 rows will be affected
 
user895378
@Stephane This room is a great place to learn as we're all (mostly) constantly working to get better. As long as you remember that "you're doing it wrong" isn't a personal attack and take it as a learning opportunity :)
 
oh duh. I need to escape the /
 
no you don't.
slashes are fine in sql
 
drat.
I wish I was good at this...
 
do you have a row with the string you're trying to replace in it?
 
7:36 PM
yeah
tons of 'em
there was a bad migration
 
and you're sure the string is exactly as you have it in the query?
 
copy/pasted
 
@tereško the OP just burnt it
 
7:38 PM
getAffectedRows returns zero
 
user895378
Is it just me or can you post any terrible question with the tag and get upvotes?
 
css confuses noobs..they'll upvote anyone with the courage to ask about it
lol
 
@rdlowrey try it and tell us :)
 
@rdlowrey noone seems to be paying attention to that stream
 
user895378
7:41 PM
I might go on a noob rampage
 
@hakre Thanks for the decent dupe of hallup i cannot access my array items
 
@SomeKittens then mysql didn't find your string. the sql looks fine, and should do the replace if it found anything
 
Alright, thanks for the help
 
where'd you copy the string from?
the db?
 
7:42 PM
(could be invisible chars made their way into the data)
 
@rdlowrey imposibaru .. you have only limited number of votes per day
 
@cHao yeah.
 
Stop! Beer time
 
PHPmyAdmin
 
@SomeKittens it i had to decide , which was the most terrible software in php , the choice between phpmyadmin and wordpress would take some time
 
@tereško WP for sure. C'mon
 
have actually looked at PMA source ?
 
WP. 14 SQL hits on a page refresh with no new content?
 
terrible in what way? quality of source code?
 
user895378
7:45 PM
@tereško lol true
 
user895378
Foiled again by the daily downvote limit!
 
user895378
/me shakes fist at spoelsky & atwood
 
@tereško Actually yes.
It sucks, but WP is far worse
 
also , you you spam votes , they will be reversed by script for preventing serial downvotes
 
thought the serial vote detection checked the user being downvoted as well as the one voting
 
7:48 PM
@PeeHaa most of people do not want to know how it's made .. its like with sausages
 
:-D
 
hehe
 
i mean, it's perfectly legit to downvote a couple dozen answers that suck...but when they're all posts by one user, that is what's suspicious
 
@cHao it may mean sometimes that user only posts crap
 
@Jocelyn regardless, it still means that someone was looking through their crap for stuff to downvote
that's more than likely targeting the user rather than the posts
 
7:50 PM
@cHao That's called peer reviewing :)
 
@PeeHaa :)
 
Ah, fixed it. Dunno why, but punching it in PHPMyAdmin worked where the PHP script didn't.
 
With a DIC, you load things into an array and then foreach back out the top components, yes?
I'm looking at pimple (for those of you that have linked me to it)
 
user895378
I would avoid anything named "pimple" on general principle. Every time I see that name I wonder what moron thought it would be a good idea to take an ego trip down the ridiculous nomenclature road.
 
@PeeHaa I have more!
 
user895378
Note to self: turn off the cv-pls audio bell on Fridays.
 
7:58 PM
lol
 
Who keeps track of the backlog?
 
I'm not going to use it, I'm just trying to understand how it can/is supposed to work
 
And I wanted to let those who sent me there know I respected their help
 
8:00 PM
0
A: Javascript URL Redirection

PbxManuse this in your intranet page <SCRIPT LANGUAGE="JavaScript"> setTimeout("location.href='www.MYinternetweb.com'", 5000); </SCRIPT> it will redirect in 5 seconds

 
@Jocelyn offline amazon cloud. right...
 
user895378
@Stephane I won't self-promote with a link or anything but I recently pushed out my own open source injection container if you're interested. I'm working on some wiki entries describing how to use it at the moment. I'm not familiar with the pimple implementation (or any others for that matter), but if you want to hear the rationale for how mine works I'm more than familiar with the topic.
 
user895378
@PeeHaa Nice! I didn't know cv-maybe gets caught by the plugin as well! Excellent work.
 
8:04 PM
Definitely. I'm currently reading this on Decorators if anyone has anything else I can browse: blog.ploeh.dk/2010/09/20/… I'm also reading on Symfony's DIC.
 
:D
 
reminds me of . Great, now that song's in my head.
2
 
@Jocelyn Wow.
> Please any one can help me out the way to archive all Google's data
 
8:08 PM
Jul 25 at 19:13, by SomeKittens
Hey I just posted/And my question's crazy/Here's a link/So ?
4
 
@PeeHaa There are pretty strange questions in sometimes...
 
@Jocelyn Sometimes...
 
user895378
@Stephane My personal DIC, Auryn -- there's a bit of info on the wiki right now, but unfortunately it's half-baked and none of the cool features (like defining injection definitions for interfaces/abstract typehints, defining non-class injection parameters, etc) are discussed at all. Not sure how much help it will be to you in it's current form. The code, on the other hand, is production-ready and I use it extensively
 
With observers, decorators, etc (I don't know about mediators) it seems so restrictive: How can I affect other classes in a simple, yet flexible way involving actual data (not just an an id or a text field?
 
@PeeHaa in that case, sometimes = every day
 
@rdlowrey Awesome. I'll take a look. Congratulations
 
PHPNW Hackathon = not that awesome :x
 
Why static methods are bad?
 
@rdlowrey Wow.. it's really extensive. I'm impressed at how flexible it seems to be.
 
8:14 PM
@Leigh which project did you work on?
 
user895378
@Stephane Unfortunately I don't have any good examples up right now, but thanks. Another cool feature is you can delegate class instantiation to your own callables as well. For example:
 
user895378
$provider->delegate('Namespace\MyClass', $someFactoryClosure);
 
I love the reflection
Assuming no configuration, it seems awesome
 
user895378
I'm not crazy about reflection myself, but I do use a pool (Auryn\ReflectionPool) to cache the reflected objects to minimize the performance impact.
 
user895378
8:18 PM
 
;-)
 
@rdlowrey I just think it's a fun idea.
 
user895378
@Stephane Yeah I'm not against it -- it's just that there are often better ways to solve a problem than Reflection. Not in this case, though (IMHO), so that's why I used it :)
 
rofl: $obj->value = 'Arthur Dent';
 
PHPNW Hackathon = not that awesome :x
 
8:20 PM
I think it's elegant, especially since this is just something that happens once. I think I would probably wire it explicitely, but that's more because I'm just learning this stuff. I'm sure I'll get over that.
 
heh timeout + retry, sorry for double post.
@NikiC Well said Hi to @ircmaxell and he promptly got up and left ;)
 
@Leigh huh?
 
Why static methods are bad?
 
user895378
@Stephane I mainly use it in a framework context. A very basic example:
 
8:22 PM
@Eugene because your code gets bound to specific name of the class
 
user895378
<?php

define('ROUTES_FILE', '/hard/path/to/routes.xml');

$routeLoader = new RouteLoader();
$routes = $routeLoader->parseRoutesFromFile(ROUTES_FILE);
$router = new Router($routes);

$requestDetector = new RequestDetector();
$request = $requestDetector->detectFromSuperglobal($_SERVER);

try {
    $controllerClass = $router->routeRequestToController($request);
    $controller = new $controllerClass();
    $controller->execute();
} catch (RouteNotMatchedException $e) {
    // return 404 response
} catch (Exception $e) {
 
user895378
When you need to instantiate a routed class you won't know which dependencies are needed ahead of time.
 
Boom. My mind.
 
user895378
So in a case like the above I might replace something like $controller = new $controllerClass();
 
user895378
with $controller = $provider->make($controllerClass);
 
8:23 PM
That's awesome
 
$controller->execute(); .. i have an issue with this
 
Sep 5 at 10:49, by Gordon
♫♪ Hey, I just saw you, and this is crazy, but here's my voting, cv maybe … ♫♪
 
user895378
@tereško I do too -- I would never actually do it that way.
 
@Gordon Damnit! It was out of my head for a minute.
 
and it's $controller = new $controllerClass;
 
8:25 PM
@tereško and?
@tereško why?
 
what why ?
 
@tereško why no braces?
 
because there are not required .. obviously
 
user895378
But don't take any architectural cues from the above code -- the point is that a DIC can be helpful in a routed environment where you may not know ahead of time what dependencies you'll need.
 
So? Maybe this is his style of code, to always use them even if not required
 
8:26 PM
@tereško what's wrong with $controller->execute()? /cc @rdlowrey
 
@NikiC Never mind I guess, I'm sitting with the react guys now
 
@Leigh say Hi to igor and edorian
 
@Gordon , that code fragment as whole would come from bootstrap stage of application. Which would mean that all his controllers have execute() method. And since there were no other parameters provided , you either have controllers with single method or they relay on global state to make further executions
 
user895378
@Gordon Well, my personal preference at the moment is an RMR-style implementation where I expect the routed controller class to expose a public method matching the HTTP method verb from the request.
 
@Leigh I still don't quite get what you mean by "Well said Hi to @ircmaxell and he promptly got up and left" ^^
 
user895378
8:28 PM
So yeah, like @tereško just said, the above snippet would mean you make all of your controllers expose some vague, nebulous execute() method ... which I don't really like.
 
@tereško and? there is nothing wrong with controllers being strategies for just that one purpose. only thing puzzling me is how the Request gets into the controller.
 
How is Util::toString( ... ); diff. from $Util = new Util(); $Util->toString( ... );?
 
@NikiC I sat down, he left :p
 
.. Request would be that global state that i mentioned , @Gordon
 
user895378
Re: my last message about requiring an controller method matching the HTTP method verb I would then return a 405 method not allowed response if the relevant method is missing or isn't callable on the routed controller class.
 
pce
8:30 PM
@Eugene sometimes static methods lack of cohesion and then they are just namespaced functions, only.
 
@Leigh okay...
 
@rdlowrey that's one possible implementation but it's certainly not the only implementation. you could have a HandleGetFooController with a single handleRequest() method.
 
user895378
@Gordon You're right. My point in the above code demonstrates how I use a dependency injection container -- the relevant controller class will typehint the Request instance in its constructor and the DIC will automatically provision it to the controller class (because I don't directly instantiate the routed controller class, I use the DIC).
 
@pce so what if they are? Wouldn't that be nicer way to add some container class with functions/methods logically placed there, rather then require_once some file with those functions elsewhere?
 
@tereško not sure what you mean. all he has to do is $controller->execute($request); right? I might be missing context though.
 
8:32 PM
even if you pass in the request , you end up with several challenges that are associated with routing
 
user895378
@Gordon because earlier in a real bootstrap process I would share the Request instance in the context of the DIC
 
@Eugene Util classes are anti patterns. they violate SRP and should be moved onto the classes having the required information on which those operate on.
 
@rdlowrey that's what I expected
 
user895378
@Stephane And that's how I use a DIC to mimic Singleton usage without violating any OO principles or sacrificing testability.
 
Damn I'm learning a lot.. People should post code more often
 
8:35 PM
@Gordon Okey. So how should class be named if it has methods like toString, toInt, toFloat, ...? Extractor, Transformer?
 
@Stephane code rots too fast
 
@Eugene TypeCaster, if it should be a class at all.
 
@Eugene Uhm, wtf do those methods do, if I may ask?
 
@Gordon what can it be if not a class?
 
@tereško you mean it becomes obsolete fast? I love seeing people's responses. I'm going to start posting code directly (if that's not annoying)
 
user895378
8:36 PM
Yeah -- and as mentioned previously, I would probably use words like "terrible" and "abomination" a few weeks from now to describe any code I post today
 
But that's good.
 
@Eugene functions
 
@Stephane , just use pastie.org or gist.github.com
 
@Gordon but if I don't want to have files with functions in my project?
 
roger
 
8:38 PM
@Eugene then stop acting like a child
 
@Eugene Util::toString() is effectively the same as \Util\toString() just that the latter doesnt abuse class scope for a pseudo namespace
 
if you need functions (to, basically, extend php default capabilities), then put them in the file and include at bootstrap stage .. preferably: namespace them
 
@Eugene if you want to have these as methods, make each of the to<Type> methods into a separate interface, e.g. <Type>able and implement them in the methods that need them
 
stackoverflow.com/questions/12411105/… so we can delete that sqli code from SO
 
user895378
It's not a good sign for the long-term prospects of your question when the opening line is:
 
user895378
8:46 PM
> I explain what i need :
 
user895378
And the closing line is:
 
user895378
> How i can do it ?
 
@PeeHaa I posted more links earlier here, if you feel you have too many unused close-votes
 
8:50 PM
@NikiC are you at PHPNW, too?
 
@Gordon no
 
though you already knew that before asking ^^
or at least you ought to know :)
 
@NikiC heh, would have surprised me. chicken! ;)
@NikiC will you be at IPC?
 
what's IPC?
 
i wonder if mods can use "bulk close" option
i guess i will just flag the user
 
Daily vote limit reached :-(
 
9:01 PM
@tereško I already flagged the account
 
9:17 PM
(not a real question)
.. and yes , i am out of votes
 
Wow. Everybody's out of votes with 2 more hours to go :(
 
stackoverflow.com/questions/12754107/explode-task-time I really dont know what is too trivial anymore for this site and the duplicates are just overwhelming. I want to
 
I was out of close votes more than 3 hours ago
 
BTW what did they do to the cv /review? Cannot be that all those questions are suddenly reviewed.
 
9:18 PM
I can't even downvote...
@PeeHaa I noticed they added a "filter by tag", this is very nice
 
Didn't even saw that
Most will be JS / PHP either way :P
 
before they added the filter, I was clicking the "Next" button very often
 
@Jocelyn Really? Even for languages I don't know most of them are pretty obvious I think.
 
@PeeHaa When the post contains many lines of code in a programming language I don't understand, I don't always know if I should vote or not
 
@Jocelyn True
 
> You've reached the maximum of 16 Deletion votes per day; come back in 2 hours
omfg
 
is there a daily limit to the number of comments we can post?
 
@Jocelyn Don't think so
 
posted on October 05, 2012 by blog.phpdeveloper.org » PHP

If you follow me on Twitter you know I’ve been working on a new project for a bit now. I wanted it to gather up a bit of steam before I posted about it here…and it’s about that time. I started up Websec.io with the hopes that it could provide articles about current trends in web security and look forward to some of the things coming down the line. Given that I’m a PHP developer by trade, a lot

 
@Feeds you spammer! :-p
 
> You've reached the maximum of 50 Closure votes per day; come back in 2 hours
 
@PeeHaa I know how it feels...
 
@Jocelyn I like sites like that (when they are any good that is)
 
user895378
I need some appropriate rep-whore love for a quality unit testing answer:
 
user895378
0
A: How should I create a test resource which always times out

rdlowreySuccessful unit testing requires that you test units of code in complete isolation from all outside influences. This means that if your test depends on things like the file system (or in this case some external web server) to function correctly, you're doing it wrong. When your tests depend on an...

 
come back in 2 hours
 
1
Q: CSS styling of keygen tag

Scott HerbertI’m currently trying to have an attractive form part of which includes a keygen tag. This works well, but when I try to apply the same CSS I’m using for the “text” fields to the keygen tag I get a less than optimal effect. Is there a quick reference as to what styles work with the keygen field an...

Anyone knows?
(I've only learned of keygen today :D)
 
@MadaraUchiha .. emm ... as i understand it , it is not a visible tag
 
10:08 PM
@tereško Well something is visible
That <select> like thingy
Impossible to style? (shadow DOM)?
 
just leave it be
wait till HTML5 is finished
also , the styling for form elements has been flaky for ages .. it would be naive to expect that newly added tag would act as documented
 
@tereško Some of it, yes.
Never heard of a very few are completely unstylable ones.
 
@MadaraUchiha <input type="file" /> ?
you can reliably change the color of that elements border ... aaaaand ... that's about it
 
10:49 PM
 

« first day (720 days earlier)      last day (4222 days later) »