Agrégateur de flux

Joey Hess: our beautiful fake histories

Planet Debian - ven, 10/07/2015 - 17:40

Here's an odd thing about the git bisect command: It has only 1 option (--no-checkout). Compare with eg git commit, which has 36 options by my count.

The difference is largely down to git having a pervasive culture of carefully edited history. We need lots of git commit options to carefully produce commits that look Just Right. Staging only some of the files we've edited, perhaps even staging only some of the changes within a file. Amend that commit if we notice we made a mistake. Create a whole series of beautiful commits, and use rebase later to remix them into a more beautiful whole.

Beautiful fake histories. Because coding is actually messy; our actual edit history contains blind alleys and doublings back on itself; contains periods of many days the code isn't building properly. We want to sweep that complexity away, hide it under the rug. This works well except when it doesn't, when some detail airbrushed out of the only remaining history turns out to be important.

Once we have these beautiful fake histories of changes, we can easily bisect them and find the commit that introduced a bug. So bisect doesn't need a lot of options to control how it works.

I'd like to suggest a new option though. At least as a thought experiment. --merges-only would make bisect only check the merge commits in the range of commits being bisected. The bisection would result in not a single commit, but in the set of commits between two merges.

I suspect this would be useful for faster bisecting some histories of the beautiful fake kind. But I know it would be useful when the history is messy and organic and full of false starts and points where the code doesn't build. Merges, in such histories, are often the points where things reach a certian level of beauty, where that messy feature branch got to the point it all built again (please let this happen today) and was merged into master. Bisecting such points in a messy organic history should work about as well as bisecting carefully gardened histories.

I think I'll save the full rant about beautiful fake history vs messy real history for some other day. Or maybe I've already ranted that rant here before, I can't remember.

Let's just say that I personally come down on the side of liking my git history to reflect the actual code I was working on, even if it was broken and even if I threw it away later. I've indeed taken this to extreme lengths with propellor; in its git history you can see every time I've ever run it, and the version of my config file and code at that point. Apologies to anyone who's been put off by that... But oddly, propellor gets by far more contributions from others than any of my other haskell programs.

All in the form of beaufiully constructed commits, naturally.

Catégories: Elsewhere

Drupal Watchdog: Know Your Audience

Planet Drupal - ven, 10/07/2015 - 17:24
Article

Drupal.org is one of the largest and oldest continuously-operating Drupal websites in the world. The amount of content we have is both a blessing and a curse. Historically developed and maintained by community volunteers, Drupal.org has been growing organically for over a decade. New content keeps being added, while no major changes to information architecture and navigation have made it easily findable. With about 1.2 million pieces of content, the need to overhaul Drupal.org has become obvious. But where do we even start?

It is tempting to jump straight into content strategy, kick off a massive content audit, and talk about content types and archival processes. However, to develop comprehensive content strategy, you need to understand what kind of content is actually needed on your site. And to understand that, you need to know your audience.

Researching the Users

We underwent a user research project which lasted from May to August of 2014. Through a public request for proposal (RFP) process, we partnered with Whitney Hess, a user experience coach, to help guide the Drupal Association staff and community volunteers through the research.

The project kicked off with a full-day workshop at DrupalCon Austin. Participants included representatives from the Drupal Association staff and the Board of Directors, community volunteers, and advisors. Together, we brainstormed objectives for the new Drupal.org and metrics of success, as well as provisional user personas – our ideas about what those personas could be.

With that groundwork in place, we set out to validate (or disprove) our assumptions with real people.

We talked to 30 different users of our website located in the Americas and Europe: people who were new to Drupal, long-term community members, ex-Drupalistas, developers, site builders, designers, content strategists, PMs, and more. We sat down for an hour with each one of them and asked numerous questions about the way they use Drupal.org, things they enjoy about it, and their frustrations.

Once we had the data from the interviews, we started to synthesize it and develop personas.

Catégories: Elsewhere

Gunnar Wolf: Finishing the course on "Free Software and Open Standards"

Planet Debian - ven, 10/07/2015 - 15:01

A couple of months ago, I was invited to give the starting course for the Masters degree in Free Software in the Universidad Andina Simón Bolívar university. UASB is a multinational university, with campuses in (at least) Ecuador, Chile, Bolivia and Colombia; I was doubtful at first regarding the seriousness of this proposal and the viability of the program, but time made my doubts disappear.

Bolivia is going through an interesting process, as they have one of the strongest worded government mandates for migration to free software for the public administration in the next couple of years; this migration has prompted the interest of many professionals in the country. In particular, we have over 40 registered people for this Masters degree. Studying a Masters degree is a long-term commitment which signifies a big time investment, and although many of the student are quite new to the idea of free software, they are willing to spend this time (and money, as the university is privately owned and charges for its enrollment).

I gave this class together with Alejandro Miranda (a.k.a. @pooka), as we have a very good pair-teaching dynamics; we had already given many conferences together, but this is the first time we had the opportunity to share a whole course — and the experience was very good. We have read the students' logs, and many of them clearly agree with this.

I had to skip two of the (ten) lessons, as I travelled from Mexico to Argentina halfway through it (of course, we brought the babies to meet my wife's family and friends!), so we had also the honor of having Esteban Lima fill in for those sessions.

I am very happy and grateful that the University took care to record our presentations and intend to record and put online all of the classes; as we were the first in the program, there were some understandable hiccups and some sessions were lost, but most are available. Here they are, in case you are interested in refering to them:

Topic Video (my server) Video (Youtube) Introduction to free software Watch Watch History Watch Watch Free culture N/A N/A The effects of free software Watch Watch Free software and open standards related to technologic soverignity Watch Watch The free software ecosystem Watch Watch Free software implementation in Bolivia Watch Watch Introduction to intelectual property: Copyright, patents, trademarks, etc. Watch Watch Who is "the community" and why do we speak about it? Watch Watch Current status and challenges for the movement N/A N/A

We have yet another video file (which I have not fully followed through) titled ADSIB - Migration plan. It can also be downloaded from my server or watched online at Youtube.

All in all: This was a great opportunity and a joy to do. I think the material we used and developed fit well what was expected from us, and we had fun giving somewhat heterodox readings on our movement.

Catégories: Elsewhere

Elena 'valhalla' Grandi: Old and new: furoshiki and electronics.

Planet Debian - ven, 10/07/2015 - 12:23
Old and new: furoshiki and electronics.

Yesterday at the local LUG (@Gruppo Linux Como ) somebody commented on the mix of old and new in my cloth-wrapped emergency electronics kit (you know, the kind of things you carry around with a microcontroller board http://espruino.com and a few components in case you suddenly have an idea for a project :-) ).

http://social.gl-como.it/photos/valhalla/image/401bdd78db4a7eb8265a8119cb28c385

This is the kind of things it has right now: components tend to change in time.

http://social.gl-como.it/photos/valhalla/image/7ba4c1372772b4d0374b655613f70c99

And yes, I admit I can only count up to 2, for higher numbers I carry a reference card :-)

http://social.gl-como.it/photos/valhalla/image/2f544e5bef5c08c4ce9490865d22208a

Anyway, there was a bit of conversation on how this looked like a grandmother-ish thing, especially since it was in the same bag with a knitted WIP sock, and I mentioned the Japanese #furoshiki revival and how I believe that good old things are good, and good new things are good, and why not use them both?

Somebody else, who may or not be @Davide De Prisco asked me to let him have the links I mentioned, which include:

* Wikipedia page: Furoshiki https://en.wikipedia.org/wiki/Furoshiki
* Guide from the Japanese Ministry of the Environment on how to use a furoshiki http://www.env.go.jp/en/focus/attach/060403-5.html (and the article http://www.env.go.jp/en/focus/060403.html)
* A website with many other wrapping tecniques http://furoshiki.com/techniques/.
Catégories: Elsewhere

Drupal core announcements: Recording from July 10th 2015 Drupal 8 critical issues discussion

Planet Drupal - ven, 10/07/2015 - 12:10

This was our 7th critical issues discussion meeting to be publicly recorded in a row. (See all prior recordings). Here is the recording of the meeting video and chat from today in the hope that it helps more than just those who were on the meeting:

If you also have significant time to work on critical issues in Drupal 8 and we did not include you, let me know as soon as possible.

The meeting log is as follows (all times are CEST real time at the meeting):


[11:21am] berdir: pfrenssen: that's one scary profile picture ;)
[11:22am] pfrenssen: haha it zooms in nicely :D
[11:23am] jibran: berdir: yay! https://bugs.php.net/bug.php?id=69996&edit=1 got fixed.
[11:26am] jibran: https://www.drupal.org/project/issues/search/drupal?status[0]=1&status[1]=13&status[2]=8&status[3]=14&status[4]=4&priorities[0]=400&categories[0]=1&categories[1]=2&categories[2]=5&version[0]=8.x
[11:27am] jibran: https://www.drupal.org/node/2497243
[11:27am] Druplicon: https://www.drupal.org/node/2497243 => Rebuilding service container results in endless stampede [#2497243] => 139 comments, 34 IRC mentions
[11:27am] GaborHojtsy: jibran: that’s the one that Fabianx-screen is talking about, right? :)
[11:29am] Fabianx-screen: Issues I talked about:
[11:29am] Fabianx-screen: https://www.drupal.org/node/2529516
[11:29am] Druplicon: https://www.drupal.org/node/2529516 => Decouple tests from relying that $container is a container builder [#2529516] => 10 comments, 9 IRC mentions
[11:30am] jibran: https://www.drupal.org/node/2502785
[11:30am] Druplicon: https://www.drupal.org/node/2502785 => Remove support for $form_state->setCached() for GET requests [#2502785] => 119 comments, 23 IRC mentions
[11:30am] jibran: https://www.drupal.org/node/2505989
[11:30am] Druplicon: https://www.drupal.org/node/2505989 => Controllers render caching at the top level and setting a custom page title lose the title on render cache hits [#2505989] => 54 comments, 10 IRC mentions
[11:30am] pfrenssen: I can't talk
[11:30am] Fabianx-screen: https://www.drupal.org/node/2530586
[11:30am] Druplicon: https://www.drupal.org/node/2530586 => Read-Only Container is not working properly. [#2530586] => 0 comments, 4 IRC mentions
[11:30am] pfrenssen: nice construction noises :)
[11:30am] pfrenssen: https://www.drupal.org/node/2524082
[11:30am] Druplicon: https://www.drupal.org/node/2524082 => Config overrides should provide cacheability metadata [#2524082] => 82 comments, 24 IRC mentions
[11:31am] pfrenssen: That's what I am working on. Next steps are to address the last remarks.
[11:31am] pfrenssen: It's clear how to move forward.
[11:31am] GaborHojtsy: pfrenssen: :)
[11:32am] jibran: https://www.drupal.org/node/2525910
[11:32am] Druplicon: https://www.drupal.org/node/2525910 => Ensure token replacements have cacheability metadata and that it is bubbled in any case [#2525910] => 72 comments, 10 IRC mentions
[11:32am] jibran: https://bugs.php.net/bug.php?id=69996&edit=1
[11:33am] GaborHojtsy: https://www.drupal.org/node/2512718
[11:33am] Druplicon: https://www.drupal.org/node/2512718 => EntityManager::getTranslationFromContext() should add the content language cache context to the entity [#2512718] => 144 comments, 46 IRC mentions
[11:35am] GaborHojtsy: https://www.drupal.org/node/2529516
[11:35am] Druplicon: https://www.drupal.org/node/2529516 => Decouple tests from relying that $container is a container builder [#2529516] => 10 comments, 10 IRC mentions
[11:37am] jibran: https://www.drupal.org/node/2528178
[11:37am] Druplicon: https://www.drupal.org/node/2528178 => Provide an upgrade path for #2354889 (block context manager) [#2528178] => 36 comments, 7 IRC mentions
[11:40am] jibran: https://www.drupal.org/node/2454439
[11:40am] Druplicon: https://www.drupal.org/node/2454439 => [META] Support PHP 7 [#2454439] => 126 comments, 25 IRC mentions
[11:40am] berdir: jibran: http://d8php7bot.erwanderbar.de/
[11:42am] pfrenssen: yay! :D
[11:42am] GaborHojtsy: dawehner: alexpott: we are running out of topics to talk about :D any topics you wanted discussed while we are on the call?
[11:42am] GaborHojtsy: dawehner: alexpott: https://plus.google.com/hangouts/_/gspzs5s25ucfasw6puf7muif7ya
[11:43am] alexpott: GaborHojtsy: yep
[11:44am] jibran: https://www.drupal.org/node/2505989
[11:44am] Druplicon: https://www.drupal.org/node/2505989 => Controllers render caching at the top level and setting a custom page title lose the title on render cache hits [#2505989] => 54 comments, 11 IRC mentions
[11:45am] dawehner: GaborHojtsy: oh let me try to join
[11:45am] GaborHojtsy: dawehner: alexpott is discussing title filtering
[11:45am] alexpott: https://www.drupal.org/node/2530474
[11:45am] Druplicon: https://www.drupal.org/node/2530474 => Discuss whether => 0 comments, 1 IRC mention
[11:46am] • dawehner tries to join again
[11:49am] dawehner: alexpott: GaborHojtsy I can't talk probably (given the speed of the net, can kinda listen) but I think allowing is a thing, given that people wanted something like tags
[11:57am] jibran: https://www.drupal.org/node/2493911
[11:57am] Druplicon: https://www.drupal.org/node/2493911 => Update guzzle, goutte and mink-goutte-driver to the latest release [#2493911] => 76 comments, 2 IRC mentions
[11:58am] jibran: https://github.com/guzzle/guzzle/pull/1167
[11:59am] pfrenssen: yay! D:
[12:00pm] pfrenssen: 14
[12:00pm] dawehner: https://www.youtube.com/watch?v=P_yl2WuiW4g
[12:00pm] pfrenssen: have a nice weekend!

Catégories: Elsewhere

KatteKrab: Landscape design: a great analogy for the web

Planet Drupal - ven, 10/07/2015 - 09:16
Friday, July 10, 2015 - 17:16

I often find myself describing the digital domain to people who don't live and breathe it like I do. It's an intangible thing, and many of the concepts are coded in jargon. It doesn't help that every technology tool set uses it's own specific language, sometimes using the same words for very different things, or different words for the same things. What's a page? A widget? A layout? A template? A module, plugin or extension? It varies. The answer "depends".

Analogies can be a helpful communication tool to get the message across, and get everyone thinking in parallel.

One of my favourites, is to compare a web development project, to a landscape design project.

One of the first things you need to know, is who is this landscape for and what sort of landscape is it? The design required for a public park is very different to one suitable for the back courtyard of an inner city terrace house.

You also need to know what the maintenance resources will be. Will this be watered and tended daily? What about budget? Can we afford established plants, or should we plan to watch the garden grow from seeds or seedlings?

The key point of comparison, is that a garden, whether big or small, is a living thing. It will change, it will grow. It may die from neglect. It may become an un-manageable jungle without regular pruning and maintenance.

What analogies do you use to talk about digital design and development?

Image: XIIIfromTOKYO - Plan of the gardens of Versailles - Wikipedia - CC-BY-SA 3.0

Catégories: Elsewhere

Drupal CMS Guides at Daymuse Studios: Elegant Drupal 7 Administration: Mobile Theme, Menu, Modules

Planet Drupal - ven, 10/07/2015 - 01:29

Use this system of Drupal admin theme and modules to create a mobile-friendly, modern Drupal 7 administration user experience. Improve workflow, help users.

Catégories: Elsewhere

Sven Hoexter: Ubuntu 14.04 upstart and bonding

Planet Debian - jeu, 09/07/2015 - 22:45

As usual when you add something new to your technology stack you'll find a "new" issue. A bit late in the game I made my first contact today with Ubuntu in the 14.04 incarnation when a colleague tried to stop and start a bond with:

ifdown bond0 && ifup bond0

About an hour later I had a virtual machine running and found the same bug in the pre-up ifenslave script which I later found to be already described in LP1269921.

Apparantly Ubuntu integrated parts of the networking stuff with upstart and udev but did not care about how to cater people with bonding setups. At least the official documentation is very sparse on that topic.

While someone from sysEleven rewrote the whole ifenslave script (the gist linked in the bugreport is dead at the moment), I found that way to invasive and not well to handle. You can either push it via a configuration management system and overwrite a package owned script, or you roll you own package. So after some tinkering I decided to go with a different dirty workaround and setup the bond itself via pre-up snippets. In my test case it looks like this:

auto eth1 eth2 bond0 iface eth1 inet manual bond-master bond0 iface eth2 inet manual bond-master bond0 iface bond0 inet static address 192.168.1.1 netmask 255.255.255.0 bond-primary eth1 bond-slaves eth1 eth2 pre-up echo +bond0 > /sys/class/net/bonding_masters || true pre-up ifenslave bond0 eth1 eth2

I'm not yet sure if that breaks some other features of the ifenslave integration in ifupdown, but it seems to work so far. Let's see how far I can get with it.

Catégories: Elsewhere

Acquia: Front End Performance Strategy: Scripts

Planet Drupal - jeu, 09/07/2015 - 21:31

In the last installment of this series, we considered CSS optimization. This time we’re going to look at the impact of scripts.

Remember, as architects and developers, it’s up to us to inform stakeholders about the impacts of their choices, offer compromises where we can, and implement in smart and responsible ways.

So, picking up on our last post, most everything about the way Drupal handles CSS holds true for JavaScript, with a few notable exceptions.

CSS aggregation removes whitespace, but JavaScript aggregation done using Drupal core's aggregation system doesn't do that or any other form of minification or uglification. It simply concatenates our scripts.

Like CSS, JavaScript also has three groups:

  • Library - Libraries, via drupal_add_library
  • Default - Modules
  • Themes - Your theme

Drupal creates aggregates for each of these three groups in the head, but can also deploy to the footer when the scope is set to ‘footer.’

When and where to load your JS

Drupal_add_js features a great option in the options array called scope that allows us to load JavaScript in the footer. This helps decrease our visual page load times by moving render-blocking JavaScript out of the way to a place where it won't impede the loading of other assets (like images, styles, other scripts).

The options array also provides an option called type which defaults to ‘file.’ When using the default option of ‘file,’ it tells Drupal that this is a script hosted on our site, so it's eligible to be aggregated. Combined with the every_page flag set to ‘true,’ just like with our CSS, these scripts get aggregated with the scripts added using ‘.info’ files into the big site-wide aggregates. If the every_page option is left out, or it is set to ‘false,’ then these scripts are aggregated as one-offs outside of our main three site-wide JavaScript aggregate files, again, just like with our CSS.

The type option can also be used to create inline scripts, which can be handy in a couple of ways. It will print our JavaScript directly into our header or footer depending on scope, but it's also useful for dynamically loading external scripts so they become asynchronous. Going forward, the async_js module is probably the way to go. I personally haven't had the opportunity to try it out, but I look forward to the chance. If you've used it, let us know in the comments how it worked out for you.

The third 'type' is the one we use for loading external scripts, which we seem to do often these days. Using an asynchronous method, mentioned above, is important because of the additional round-trip time to get the script. However, a slightly less effective way to handle it without using the older method of an inline script, or an additional module, is simply scoping the script to the footer and setting the type option to external (which prevents it from being aggregated).

Unlike with CSS, I'm less inclined to add JavaScript on every page because I like to scope JavaScript to the footer whenever possible. Since it isn't blocking render down there, the additional HTTP request doesn't really bother me. Generally, if it's on most pages, or a page visited by most users, go ahead and add it to every page. If it isn't and it's scoped to the footer, then only add it when it is needed. If it has to be in the header, and on an obscure page that isn't frequently visited by users, you're probably going to need to do some A/B testing to compare the performance hit on the obscure page by not including it on all pages vs. the performance hit on all the other pages by including it on all pages. I like to err on the side of the majority, meaning, I tend to only include the JavaScript on the obscure pages.

JavaScript: Know when to say when

You can do almost anything with JavaScript, and leveraging a framework like jQuery makes it easier to want to do everything with JavaScript. However, in addition to blocking page render and increasing the size of the page that has to be processed by the browser, there are other performance considerations with JavaScript.

It runs locally, in the browser, which means it uses a visitor's memory and processor. Poorly written or heavy use of JavaScript can lead to a poor user experience in the form of everything from delayed and choppy animations to browsers becoming unresponsive and/or crashing. For simple animations, consider using CSS3 animations, benchmark them using a tool like Chrome's dev tools or Firebug, and go with the least expensive performance option (these usually end up being the smoothest animations as well).

These script performance problems are often magnified on mobile devices where the hardware resources are more scarce and we often resort to using more JavaScript to solve challenges presented by the smaller viewport. This should reinforce the importance of a mobile first strategy, not only for design but also for development. It also highlights the need for open communication between the product owners, the design team, and the development team.

Conclusion

Scripts, like styles, contribute front-end implementations that can seriously hamper Drupal’s back-end magic. By favoring stylesheet aggregation and reigning in exuberant preprocessing, we can save the browser a lot of work. Applying the same principles to JavaScript, while properly placing scripts in the header or footer-based on function, can also improve our page-load times.

Next time, in our final post of the series, we’ll take a grab-bag look at some subtle, more specialized techniques that just might shave off those last few milliseconds. Stay tuned for a post covering Content Delivery Networks (CDN), semantic HTML, and how to encourage improved client-side content selection.

Tags:  acquia drupal planet
Catégories: Elsewhere

Acquia: Quick Tips for Writing Object Oriented Code in PHP

Planet Drupal - jeu, 09/07/2015 - 21:15

Recently I began working on a D8 module, but this isn't a story about a D8 module. The work I did provided me an opportunity to get back to my pre-Drupal object oriented (OO) roots. Writing OO code in PHP presented some curve balls I wasn’t prepared for. Here are some of the issues I encountered:

PSR-4 Autoloading: How to set up your files to be loaded

First things first, how do you include OO code in your project? In D7 you had to add the files to a .info file for a module or do module_load_include. In D8 all you have to do is follow PSR-4 namespacing. If you follow the PSR-4 folder and namespace structure your classes will be auto-detected. No more need to add them to a .info file! If you are writing code for D8 then it’s done. Great. In D7 you can use the XAutoload module to get PSR-4 autoloading in D7 today!

Namespacing In PHP: Loading your files

Namespacing in PHP can be confusing and misleading. In Java or .NET, in a file you first import other namespaces you intend to use. In the example below we use the “using” keyword. Then you declare the namespace wrapper for the code that is being implemented.

using System;
using Microsoft.VisualBasic.Devices;
namespace SampleNamespace
{
    class SampleClass
    {
    }
}
PHP is VERY different. It’s actually the opposite. First you declare the namespace then inside the namespace you have your “includes.” In PHP including the use statements outside of the namespace would contaminate the global-scope.

namespace SampleNamespace
use GuzzleHttp;
use GuzzleHttp\Subscriber;

class SampleClass
{
}
Now this is where things get tricky. If there is a class called Client inside GuzzleHttp then you would expect that you could use it by writing the following.

namespace SampleNamespace
use GuzzleHttp;

class SampleClass {
function sampleFunction(){
          $myClient  = new Client();
      }
}
And you would be wrong. The way that PHP interprets classes are RELATIVE to the current file’s namespace. So it actually sees “$myClient = new Client();” as “ $myClient = new SampleNamespace\Client();” which does not exist so the declaration fails. To work around this you can reference the actual class in the use statement. If you have multiple classes you must have an include for each one. It’s more verbose than what you might expect coming from .Net or Java e.g.:

namespace SampleNamespace
use GuzzleHttp\Client;
use GuzzleHttp\Subscriber\Mock;

class SampleClass {
function sampleFunction(){
          $myClient  = new Client();
   $mock = new Mock();
      }
} Dynamic Typing: A variable can be anything!

PHP is a dynamically typed language. It provides great flexibility and velocity when coding, especially procedural code. However, this can be a nightmare when you are writing OO code. It means that you cannot make assumptions about the type being passed into an object. If you make assumptions and those assumptions are invalid your code can behave unpredictably. What are you to do?

Type Hint ALL THE THINGS:

You might be surprised to know that PHP allows you to apply and enforce function param types. PHP 5 introduced the concept of type hinting. With type hinting you can set type on objects. e.g
function sampleFunction(MySampleClass $a){

If a type hint is violated, an InvalidArgumentException is thrown. There is a catch to type-hinting in PHP, it doesn’t work for scalar types e.g (string, int, bool). There is also no type hinting on return types. You’ll have to wait for PHP 7 for both. In order to work around the scalar limitation in PHP5 you’ll need to write your own functions.

Setting up your code for an IDE

One of the advantages to writing Object Oriented code is that it works really nicely with an IDE like PHPStorm. If you have written type hinted code PHPStorm will pick up on it and help you with auto completion as you work. For the things that aren’t explicitly hinted you can use PHPDoc comments. e.g

/**
* Gets a specific setting by its name/ID.
*
* @param string $id
*   The name/ID of the setting to retrieve.
*
* @return ZoneSettingBase
*   The setting object given the ID passed in.
*/
public function getSettingById($id) {
return $this->settings[$id];
}
PHPDoc comments are actually mandatory as part of drupal-coding standards. Their omission causes coder’s code sniffer to fail.

You can also type-hint variables:

/* @var GuzzleHttp\Client $client/*
private $client;
While these hints are comments and not syntax they make the developer experience a lot more pleasant. No Enums :(

PHP still doesn’t have a formal enumeration type so you will have to get creative and roll your own.

I often create CONST arrays and throw an exception if a function param is not in that array. It’s a poor-man’s enum. There is currently a proposal to add enums to PHP7. We’ll see if it makes the cut!

Associative Arrays

Associative arrays reflect the dynamic typed heritage of PHP. They are incredibly flexible and a quick and easy way to move data from one point of your app to another that being said the lack of structure requires a developer to know everything about the underlying implementation of the array. Also without a debugger they have no way to determine what is actually in an array. The dynamic nature of these arrays makes them undocumentable. That makes coding with someone else’s array hard. The idea of OO is that you have structured data and layers of abstraction so that a dev doesn’t need to know the low-level implementation details. When going OO you should try to convert arrays into structured, documentable classes that hide the underlying implementation. If you need to accept an array as input parse it and break it out into objects as soon as possible. Developers will praise you for it!

No Function Overloading

PHP does not natively support function overloading. Since PHP is dynamic it’s possible to come up with some Frankenstein solutions to get around this. However, Frankenstein code often confuses other developers interacting with your code and is to be avoided. For better or worse you need to accept this constraint.

Dusting off the design cobwebs. How to assign responsibility to classes.

The lack of overloading can actually be beneficial especially in the context of class constructors. Like normal functions you cannot have multiple constructors in PHP (You can technically write a static class method to work around this constraint). This sounds like a pain. However, it forces you to articulate the single responsibility of a class. Often overloaded class constructors can be a sign that a class is taking on too many responsibilities. For example if you have a constructor that take params and another for parsing an array you might ask why should my class know about another representation. Maybe it's a break in tiered architecture and violating a separation of responsibilities. In this case something that might be perceived as a limitation is actually supportive and liberating.

Go Forth and Write OO Code

As we transition into D8 writing solid PHP OO code is more important than ever. D8 is built around OO classes. Even in Drupal 7 we can start to strive towards an OO world. Obviously in Drupal 7 most problems don’t lend themselves to an OO approach. However, even having that option gives you new tools to solve problems in Drupal! The resulting code has a clarity and aesthetic that most procedural code just can’t match.

Finding those opportunities to apply an OO solution keeps you sharp and ready to hit the ground running on Drupal 8.

Tags:  acquia drupal planet
Catégories: Elsewhere

Cruiskeen Consulting: Drupal 8 and hosting requirements

Planet Drupal - jeu, 09/07/2015 - 19:05

I'm writing a little bit today about some of the concerns that folks are having about Drupal 8, the new hosting requirements it imposes, and particularly the concerns that smaller organizations will not be able to find Drupal 8 compatible hosting plans. There is a lot going on with us and with other hosting companies at the moment to support Drupal 8 and other PHP software that has more modern requirements. We don't think this will be an issue with most reliable hosting companies by the time Drupal 8 ships.

Catégories: Elsewhere

Acquia: Sustainable contribution 2/2 - Giving back is the same as making money.

Planet Drupal - jeu, 09/07/2015 - 18:35
Language Undefined

Part 2 of 2 - I spoke with John Faber, Managing Partner with Chapter Three, on March 17th, 2015.

In part 1 to talk about the business advantages of contribution and sustainability when basing your business on open source software. We also touch on Drupal 8's potential power as a toolset and for attracting new developers, doing business in an open source context, and more!

Catégories: Elsewhere

Drupal Bits at Web-Dev: Drush sql-query output

Planet Drupal - jeu, 09/07/2015 - 16:47

Despite several tries, I have never had any luck using the native sql output formatting commands to work with drush

Catégories: Elsewhere

Drupalize.Me: Learning Drupal 8 from Boilerplate Code

Planet Drupal - jeu, 09/07/2015 - 15:02
Drupal 8 represents a lot of changes and a steep learning curve for many Drupal developers and themers. While many of these changes are exciting, there are many things to learn just to get started. One way to learn about the code involved with Drupal 8 modules and themes is to take a look at core's modules and themes for examples to follow. Another, is to use a code scaffolding tool like Drupal Console to generate boilerplate code and comments that you learn from and then customize.
Catégories: Elsewhere

Simon Kainz: DUCK challenge: week 1

Planet Debian - jeu, 09/07/2015 - 12:00

After announcing the DUCK challenge last week the following packages were fixed and uploaded into unstable:

A big "Thank You" to you.

The list of the fixed and updated packages is availabe here. I will try to update this ~daily. If I missed one of your uploads, please drop me a line.

There is still lots of time till the end of DebConf15 and the end of the DUCK Challenge, so please get involved.

Catégories: Elsewhere

Drupal core announcements: Drupal 8's minimum PHP version increased to 5.5.9

Planet Drupal - jeu, 09/07/2015 - 06:17

Pursuant to the discussion at [policy] Require PHP 5.5, the minimum PHP version of Drupal 8 has been raised to 5.5.9, and this change will be included in the next Drupal 8 beta (8.0.0-beta13).

(PHP 5.5.9 was chosen because it is also the same minimum version as Ubuntu's LTS, which in turn influenced Symfony 3.0, Travis CI, etc.)

This is a future-proofing move which buys us a few things:

  • Some nice language features and a built-in opcode cache.
  • Compatibility with the latest versions of various external dependencies, including Guzzle 6 and the upcoming Symfony 3.0
  • Better security for our end users, since PHP 5.4 will become end of life September 15, 2015 (most likely prior to Drupal 8's release).

We looked extensively into the adoption and hosting support of PHP 5.5 prior to making this move. While there is not widespread adoption of PHP 5.5 as of today, we nevertheless found that most hosts offer the option for PHP 5.5, due to PHP's security policy.

Catégories: Elsewhere

Mediacurrent: Mediacurrent Dropcast: Episode 7

Planet Drupal - jeu, 09/07/2015 - 04:39

In this episode we celebrate the founding of our country by talking up a few modules we have discovered and enjoy. Ryan talks about the Image Field Focus module and how it makes cropping a joy without the gamble of a cropping image style. Bob waxes poetic about the WYSIWYG Field module, which is very similar to his WysiField module. As always we keep you up to date about Drupal 8 and Ryan brings it home with The Final Bell. This was recorded on the day before all went out for the holiday weekend so there are times where we derail the train. At least this time we have an excuse.

Catégories: Elsewhere

Drupal core announcements: API module seeking co-maintainer

Planet Drupal - jeu, 09/07/2015 - 00:24

For the past 8+ years, Neil Drumm (drumm) has been maintaining the API module, and I've been co-maintaining it for the past 3+ years. (This is the module that builds and displays the Drupal API reference site api.drupal.org). Both of us have "some" other responsibilities in the Drupal ecosystem, and we'd like to find a new co-maintainer.

The ideal person would be:
- A good PHP coder familiar with and willing to follow the Drupal project's coding standards
- Familiar with the api.drupal.org site and its features
- Familiar with the API docs standards
- Familiar with both Drupal 7 and Drupal 8 core code (or at least familiar with the kinds of code it contains and the Drupalisms that it has), since both are displayed on the site
Of course, all of these "ideals" are negotiable and/or learnable, and it could be that a few co-maintainers would be better than just one.

The next step would be for the person or people who are interested to start making patches for a few issues, and once a few of those have happened, we would consider making you an official co-maintainer. The project page has a link to documentation for how to get a local API site set up, and the module also has a robust set of tests. The code in the API module is somewhat obtuse, but I'd be happy to start anyone out with a quick tour (or help you find an issue to work on). The module runs on Drupal 7 only at this time, and this is unlikely to need to change anytime soon (it displays Drupal 8 code but runs on Drupal 7, like the other *.drupal.org sites).

So if you're interested, you can either jump in and find an API module issue to work on and make a patch, or use my contact form or IRC to contact me and discuss.

Sorry... by policy, comments on this post are disabled, since it is going into the Core group (as well as Documentation).

Catégories: Elsewhere

DrupalCon News: Save 100€ on Barcelona Tickets: Buy by Friday

Planet Drupal - mer, 08/07/2015 - 20:32

Are you planning on attending DrupalCon Barcelona? If you are, we hope you’ll get your tickets this week and save 100€ in the process.

Every DrupalCon has varied ticket pricing levels, and DrupalCon Barcelona is no different. We’re offering earlybird pricing so that frugal DrupalCon attendees can get their tickets for less, but that pricing expires on Friday at 23:59 Barcelona local time (UTC +2).

For those looking at purchasing tickets, be aware that prices are as follows as we lead up to the convention:

Catégories: Elsewhere

Pages

Subscribe to jfhovinne agrégateur