samedi 30 septembre 2017

Separate operation class to work with data classes

I've noticed two different design patterns for strings.

  1. The one in PHP that strings are just a bag of bytes, with a lot of extentions to work with them (standard string functions, multibyte string, iconv, intl)

  2. The one in JavaScript where strings are classes that have methods to work with the string.

Obviously the 2nd method is easier to maintain. But to my surprise the 1st design pattern is found more often in PHP. I've also seen a PEAR package for complex numbers, but also here the complex numbers have:

  • there own data class
  • a single operation class

But why? Is there some performance penalty that really matter nowadays with PHP 7?

Aucun commentaire:

Enregistrer un commentaire