in reply to Re^2: Best practices passing database handles, cgi objects, etc.
in thread Best practices passing database handles, cgi objects, etc.

I fail to see how your OO approach is any better; all it does is wrap some global variables inside a class.

Also, it's silly to store multiple blogs (with identical schemas, I presume?) across multiple databases.

  • Comment on Re^3: Best practices passing database handles, cgi objects, etc.

Replies are listed 'Best First'.
Re^4: Best practices passing database handles, cgi objects, etc.
by Anonymous Monk on Feb 18, 2014 at 13:52 UTC

    I fail to see how your OO approach is any better; all it does is wrap some global variables inside a class.

    That is how its better, its called encapsulation

    You can have $foo and $bar both be of type Classname, with both being able to ->dance and ->sign

    Its better in the same way subroutines are better than not subroutines ( goto )

    Its also why  Main(@ARGV); sub Main { } is better than  MAIN: { } because you can only  goto MAIN , its a label, its not a subroutine, you can't call it

    Its better in that its : testable/mockable, reusable, not fragile Action at a distance (computer programming)

    http://programmers.stackexchange.com/questions/148108/why-is-global-state-so-evil

    You cannot have more than one instance of global state -- its global

    Also, it's silly to store multiple blogs (with identical schemas, I presume?) across multiple databases.

    So is everything you wrote :)

Re^4: Best practices passing database handles, cgi objects, etc.
by tobyink (Canon) on Feb 18, 2014 at 13:40 UTC

    Because classes can have multiple instances.

    (And the blogs may be operated by different people and organizations and be installed on entirely different servers. There may be slight variations in the schemas because of different versions of the blog engine being installed.)

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name