Paul M. Jones

Don't listen to the crowd, they say "jump."

Legacy Refactor Question: What About Singletons?

In my talk and my book on refactoring legacy PHP code, one of the early steps is to start removing globals and replace them with dependency injection (not a container, just injecting dependencies by hand.) I addressed the use of the global keyword and the $_GET (et al) superglobals, but I did not address singletons directly. I had a Reddit correspondent ask about singletons recently, and how to refactor away from them; I answered on Reddit, where you can read the full conversation.


A Round Of Aura 1.x Library Releases

Over the weekend we released updated versions of every 1.x library.

Most of these were “hygiene” releases, with docblock updates, extra tests, and minor bug fixes. However, the Router has two new methods to append and prepend route collections, and the Uri package adds support for schemeless URLs, ftp/ftps schemes, single label hosts, and an updated Public Suffix List.

Many thanks to everyone who made these releases possible, especially to Hari KT for insisting on the need for hygiene releases, and to Jeremy Kendall for his work on the Uri package.

A Round Of 1.x Releases.


Towards Reproductive Rights For Men

The most common argument against men having reproductive rights is the old “keep it in your pants” one, which we would never accept as an argument for why women should be forced into parenthood. Having sex is not consent to parenthood for women, so why should it be for men?

...

What would reproductive rights look like for men? Well, rather similar to what they look like for women. When an unplanned, unwanted pregnancy occurs, the woman, and only the woman will decide if her body will host that pregnancy to term. But even after the child is born, she may opt out of parenting that child by surrendering it for adoption. If men had the same rights, they too would be able to legally surrender their rights and allow the mother or any other individual to assume legal responsibility for the child.

via Let’s Talk About Reproductive Rights And Why Men Should Have Them Too | Thought Catalog.


Bush Admin Blows CIA Cover = "treason"; Obama Admin Does Same Thing = "a mistake"

Many observers seem satisfied with the White House's explanation that the incident was just a regrettable error. And that is indeed what it appears to be. But such assessments represent a remarkable change in tone from the discussion several years ago, when the George W. Bush administration leaked Valerie Plame's identity as part of a bitter fight over the origin and direction of the Iraq war. Back then, it was quite common to hear the words "traitor" and "treason" used to describe top Bush officials involved in the controversy.

To be perfectly clear, this is not about Bush v Obama. It's about how reporters take sides. Via When Bushies blew a CIA cover, it was 'treason'; now, it's a mistake | WashingtonExaminer.com.



The Rise of Crown Government in America

... once you have a chief executive chosen by popular election, you are in trouble. The “extreme” measure of the legislature removing the head of state happens much more readily in parliamentary systems ... we are just about the only country without a parliamentary system that isn’t pretty far along on the autocracy spectrum.

... the problem with popular election of Prime Ministers, and especially of Presidents, is that they become much more powerful than legislatures. They have national legitimacy, they can present a unified front, and they can dominate the news media. Separation of powers is a pipedream.

via The Constitution, the President and Us | askblog.


Do Not Resign -- Make Them Fire You

Make them fire you. If you resign under pressure you have basically no legal standing. Make. Them. Fire. You. If they pressure you to resign, you should write a letter, declining to resign, declining to take any responsibility for your private, off-duty, speech and/or actions. Specifically point out that you are exercising your personal discretion to engage in political and social commentary regarding current events, that you are not willing to be subjected to a hostile work environment for your unorthodox political views, and that you are not willing to explain or defend or justify those personal political views.

Always make them do their own dirty work.

via Vox Popoli: Mailvox: employment advice.


The Template Is Not The View

As server-side web developers, we tend to think of our templating system as providing the View layer in a Model-View-Controller architecture. I have recently come to the conclusion that this is an incorrect approach. Instead, we need to think of the HTTP response as the View.

When an HTTP client makes an HTTP request, what does it get in return? It does not receive only the body of the HTTP response. The client receives the body and the headers of the HTTP response. The response as a whole is what the web application delivers as its presentation to the client.

Templating systems, as far as I can tell, deal only with the body of the HTTP response. In practice, the rest of the response is generally handled by the Controller; for example, setting the status, setting cookies, and modifying headers.

Let's say we accept the idea that the HTTP response is the View (i.e., the presentation that is delivered to the client). If we accept that idea, then for a clean separation of concerns a la SeparatedPresentation, we need to combine both the template work and the header work into their own layer. That layer needs to be completely separated from the Controller and Model.

Thus, anything that deals with the response, including the setting of headers, should be considered the View layer. If you are setting headers in a Controller, you are losing that clean separation of concerns. To remedy this, your Controller needs to hand off to a layer that builds the response on its own; this is the proper place for the tempalting system to be invoked, not the Controller.

In summary: the template is not the View. The response is the View. We should separate our concerns accordingly.

Afterword

If you like the line of thinking presented here, please check out the Action-Domain-Responder refinement of the MVC pattern. It's still a work-in-progress so be sure to leave your comments and criticism either here on this blog or as a new issue at Github.



Federal magistrate orders arrestee to apologize and recant, as a condition of bail

The arrestee alleges she was assaulted and beaten by a Federal agent; the magistrate, before he will let her post bail, wants her to recant her allegations as a condition of bail.

This seems to me clearly unconstitutional: It’s an order compelling speech, on threat of imprisonment, which would itself normally be a First Amendment violation; but on top of that, it was issued without a trial, and thus without any final factual findings supporting its validity.

I’m aware that, once someone is convicted, courts have considerable latitude to impose speech restrictions as a condition of parole or probation, and might even be able to impose speech compulsions. But that is after someone’s guilt has been proven beyond a reasonable doubt in a criminal trial. The defendant here hasn’t been convicted of anything; she continues to be presumed innocent until proven guilty.

via Arrestee alleges government misconduct; federal magistrate orders arrestee to apologize and recant, as a condition of bail.

Here's a little more, from a different article:

One agent, realizing they did not have a warrant for that address, directed other agents to leave the premises. Then, according to Branson, another agent, the one who allegedly choked Arielle Lipsen, told Branson he had to leave. At that point, Branson asked to see a warrant.

“He said, ’I don’t need to show you a F-----g warrant.’"

Branson said, "I need to see a warrant, based on the fourth amendment…"

"The agent answered ‘Oh you’re a F-----g lawyer now. We can do this the easy way or the hard way and put his finger on the trigger of his M16. That’s when I just backed up,” Branson said.

According to Branson the alleged assault to Lipsen happened in plain view, on the sidewalk in front of a residence.

“It happened outside on the sidewalk, " stated Branson, "She wasn’t even on the property. She was standing on the sidewalk.”

It only gets worse from there. Via Bold witness to alleged abuse by federal agents comes forward.


"The Only Reason You Think You Are Smart Is Because An Idiot Called You A Genius"

This article about being able to be graduated by university applies to developers, too: begin by substituting "your first few projects" for "high school" and "the development community at large" for "college".

You may think you are smart because you got high grades in high school, but the reality is that you’re not really as smart as you think you are; you just went to a high school where everyone was stupid so you just seem smart in comparison.

Compared to the much smarter students who normally attend our college, you’re going to find yourself at the bottom of the class. While the smarter students find passing their classes to be relatively easy, and even fun, that’s not going to be the case for you. For you, college will be hard work, difficult and unpleasant, if you want to graduate.

You have the ability to graduate if you put in the effort, and take advantage of the extra tutoring services we have available for you, but college will not be a fun experience for you. I still recommend that you attend our college, but if you think that you’re not willing to work very hard, to study while the smarter kids are having fun at beer parties, then you would be better off not attending our college.

via Who gets to graduate? | Lion of the Blogosphere.

(Title quote from Moses Ngone.)