Re: TURBOPY cloud framework + IDE beta available NOW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 31.10.12 18:13, schrieb Adam Richardson:
On Tue, Oct 30, 2012 at 7:33 AM, marco@xxxxxxxxxx <marco@xxxxxxxxxx> wrote:

In times of testability and several design patters, the use of static
calls is
really outdated.
I understand that you can read and write the invocations of the methods
much
faster, but you should think more to the future on that point.

What?

Where is it written that the use of static calls is really outdated?
Functional programming is on the rise, and this is largely because of the
virtues of testability, scalability, and simplified patterns. Using a class
to organize a set of static functions can benefit the code in PHP (allow
for autoloading in PHP because functions can't be autoloaded, essentially
serves as a child namespace, etc.) whilst maintaining the benefits of a
more functional approach (unit testing purely written static functions is
much easier, putting all IO tasks in separate components makes for cleaner
modules, etc.)
I mentioned in an earlier post on the list, why I - and "some others" - think, the use of static methods is somehow outdated.

1. If you have code using static methods and members and use phpunit for testing it, you have to either make sure, that everything is properly resetted after use OR have to run phpunit in a mode where every test is run in a single php call for itself. One is potentially harmful to the test if you forgot some side effects and one is time consuming.

2. When thinking about dependency injection (give everything you use inside, from the ouside in), show me how one can do this with classes WITHOUT passing strings around? And without DI, how do you keep your application flexible to different environments and conditions?

I try to emulate functional approaches in PHP, such as what you'd find in
Scala, Clojure, or Haskell, and static calls in PHP can facilitate this
approach.

While OOP is one way to approach programming, it's not the only way. Even
Rasmus has said he leans procedurally:
http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html
Are you serious quoting that post?

Adam



-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: marco@xxxxxxxxxx

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux