Re: TURBOPY cloud framework + IDE beta available NOW

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

 



On Wed, Oct 31, 2012 at 4:46 PM, Marco Behnke <marco@xxxxxxxxxx> wrote:

>
> 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.
>

There are "potentially harmful" conditions are present in all unit tests.
If there's an error in the test, you find it and fix it, whether it's due
to a failure to reset the static properties, accidental mutation of data,
instantiating the wrong object, etc.


> 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?
> Posted by Rasmus <http://toys.lerdorf.com/authors/1-Rasmus> on **Monday,
> February 27. 2006
> **
>

Yes, seriously, I quoted that post. There is nothing inherently wrong with
a procedural approach to programming, an OO approach to programming, a
functional approach to programming, an AO approach to programming, etc.
Each has there advantages, and not all are available when programming in
particular languages.

When I code in C, I'm not thinking in OO terms. Although I do sometimes use
function pointers in a way that allows me to emulate functional
programming, I'm mostly thinking in procedural terms because the language
affords this.

When I coded in Clojure, I learned to think in immutable terms and embrace
meta-programming.

As I'm learning Go, I'm learning how to think in terms of data and
algorithms involving a clean, convenient separation using interfaces.

When I code in PHP, I tend to take a functional programming approach. But,
I'll sometimes use OOP principles if the situation feels right (although
this is rare.)

Now, back to your comment on DI. DI is cool for OOP, but I don't find I
need it as much when I'm working from a functional programming paradigm.
Others have spoken on the topic of DI in functional languages, but I tend
to use other approaches, such as passing in first-class functions (PHP's
Closure objects create the appearance of this.)

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

[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