PHPNews

Line Coverage in Unit Tests

The novice says, “I do not strive for 100% line coverage in tests; I only write tests for the code that is important.” The master says, “If the code is not important, why is it there at all? I will strive to test every line I write; if a line is not important, it should be removed.” (See also The Way of Testivus …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday February 13, 2018


Perfection

The novice says: “Nothing can ever be perfect; anything I choose will be imperfect. Therefore, all choices are equally bad, so I may choose whatever I feel like.” The master says: “Some things are less imperfect than others; I will make the least-imperfect choice that I can.”

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday February 6, 2018


Best Practices

Best practices evolve. Even though they change, they tend to change in the direction of “better”, not “worse”. The novice thinks he is an individual. The novice says: “Best practices are always changing; why bother adhering to something that I know will change? I am free to do what I feel like without referring …

Continue reading »

Written by Paul M. Jones - - Aggregated on Wednesday January 31, 2018


Considering Typehints As Communication

Typehints help communicate across time and space, to people who may never meet you or who might not be able to interrogate you about your code, so those people can understand how you expect the code to work. Adding typehints is a succinct, more-complete form of communication than not-adding them. (It is rare, …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday January 2, 2018


Solving The “Widget Problem” In ADR

The “widget problem” is when you have several panels or content areas on an HTML page that have different data sources. You might have a main content area, then a calendar off to the side, with perhaps a list of recent news items or blog posts, a todo or reminder widget, and maybe other information panels. The …

Continue reading »

Written by Paul M. Jones - - Aggregated on Thursday December 28, 2017


Avoid Dependency Injection

At least, avoid it when building DDD Aggregates: Dependency injection of a Repository or a Domain Service into an Aggregate should generally be viewed as harmful. The motivation may be to look up a dependent object instance from inside the Aggregate. The dependent object could be another Aggregate, or a number of …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday December 5, 2017


Choose Dependency Injection — If You Can

Some people say, “You don’t need to use dependency injection for everything. Sometimes dependency injection is not the best choice.” It occurs to me that the people who say this are the ones who can’t use it for everything. They say “choose what’s best for your situation”, but their situation precludes the use of …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday October 17, 2017


Atlas.Orm 2.0 Is Now Stable

I am very happy to announce that Atlas , a data-mapper for your persistence layer in PHP, is now stable for production use! There are no changes, other than documentation updates, since the beta release two weeks ago. You can get Atlas from Packagist via Composer by adding … "require": { …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday October 17, 2017


A Few Right Ways, But Infinitely More Wrong Ways

A response to the saying: “There’s no one ‘right’ way to do things. There are different ways of doing something that are ‘right’. So stop criticizing my chosen way of doing things — you cannot prove that it is wrong.” For any question, there is a certain number of right answers, but an infinite number of wrong ones. …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday October 10, 2017


Atlas.Orm 2.0.0-beta1 Released

I am very happy to announce that I have just released 2.0.0-beta1 of Atlas , a data mapper for your SQL persistence model. You can get it via Composer as atlas/orm . This new major version requires PHP 7.1 and uses typehints, but best of all, it is backwards compatible with existing 1.x generated Atlas classes! I. …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday October 3, 2017


Quality: Program vs Product

I. Why it is that programmers and their employers have different attitudes toward the quality of a project? Thinking of myself as a programmer, I have sometimes formulated it like this: The programmers who do the work are usually the ones who care more about “quality.” Why? They have a reputation to …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday September 26, 2017


“Before” (not “Beyond”) Design Patterns

(N.b.: This has been languishing at the bottom of my blog heap for years; time to get it into the sun.) The 2013 article Beyond Design Patterns takes the approach of reducing all design patterns to a single pattern: “Abstracting Communication Between ‘Components’.” The author concludes, in part: Instead of …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday September 19, 2017


A “Systems” Addendum To Semantic Versioning

tl;dr: When using semantic versioning, consider not only changes to the public API, but also changes to system requirements. Semantic Versioning concentrates on the public API signature as the determiner of when to change version numbers. If the public API changes in a backwards-incompatible way, then you have …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday September 12, 2017


Original MVC Resources from Reenskaug

This is from Trygve Reenskaug: MVC: Xerox PARC 1978-79 . Some quotes: The essential purpose of MVC is to bridge the gap between the human user’s mental model and the digital model that exists in the computer. The ideal MVC solution supports the user illusion of seeing and manipulating the domain information …

Continue reading »

Written by Paul M. Jones - - Aggregated on Monday August 28, 2017


Slim and Action-Domain-Responder

I’ve had a warm place in my heart for Slim for a long time, and especially so since recognizing the Action-Domain-Responder pattern. In this post, I’ll show how to refactor the Slim tutorial application to ADR. One nice thing about Slim (and most other HTTP user interface frameworks ) is that they are already …

Continue reading »

Written by Paul M. Jones - - Aggregated on Tuesday August 22, 2017


Why MVC doesn’t fit the web

[MVC is] a particular way to break up the responsibilities of parts of a graphical user interface application. One of the prototypical examples is a CAD application: models are the objects being drawn, in the abstract: models of mechanical parts, architectural elevations, whatever the subject of the particular …

Continue reading »

Written by Paul M. Jones - - Aggregated on Friday August 18, 2017