Tutoriale PHP
  Comunitatea PHP Romania
 

 
Tutoriale PHP
Index » Noutati

PHP in Action: Public constructors considered harmful


Postat:Luni 05 Mai 2008 15:21
Accesari:8
Comentarii:0
Favorite:0
Sursa: http://www.phpdeveloper.org

Del.icio.us
Digg
Technorati
Categorii: Noutati | alfahost_ro

According to the PHP in Action blog, public constructors can be hazardous to your (application's) health and should be replaced.

Everybody who writes object-oriented code knows about constructors. You need them so the program knows how to instantiate objects, right? And you especially need them when a lot of things have to be done while instantiating an object. [...] So why would I be skeptical of public constructors?

The solution, as he sees it, is to make a "constructor" that's actually called statically with parameters that returns an instance of the class it's in as well as performing the action. He argues that this can help make the code much more readable for some types of method calls.

Comentarii


    Ultimele discutii in forum RSS Forum

    Ultimele articole Ultimele articole

    Newsletter


    Email:
     inscriere
     renuntare
     
     Arhiva newsletter

    Site-ul lunii

    blg
     Blgpunctro

    Propune un site

    Online

    150 utilizatori online

    Parteneriat



    Copyright © 2001-2008 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Mortgage | Turbo Tax | Car Loan | Auto Loans | Western Union Money Transfer
    Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
    Powered by Simplis