Results 1 to 2 of 2

Thread: Reduce dependencies on global objects

  1. #1
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,915
    Blog Entries
    88
    Thanks
    519
    Thanked 846 Times in 551 Posts

    Default Reduce dependencies on global objects

    DamonW suggested cutting down the number of globals used throughout Hotaru. Most of these are global objects such as $db, $post, $current_user and $cage. Apparently using so many globals can be a security issue and is bad practice in object-oriented programming because it makes it difficult for other applications to use classes dependent on globals.

    So perhaps this should be a priority for future revisions. The question is, what's the best way to go about it?

    Useful links:

    http://stackoverflow.com/questions/1...obal-variables
    http://blog.case.edu/gps10/2006/07/2...mming_practice
    http://ubuntuforums.org/showthread.php?t=741263
    Last edited by Nick; 09-29-2009 at 01:53 PM. Reason: Added useful links

  2. #2
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,915
    Blog Entries
    88
    Thanks
    519
    Thanked 846 Times in 551 Posts

    Default

    Here's where I get confused. Classes should be self-sufficient so they can be used in other applications, but in order for them to be self-sufficient, they would need to be independent of language files and utility functions, not to mention those darn globals!

    I understand the idea of classes being libraries of common functions that applications can use, but how are you expected to wrap your entire program up in these classes if there's nothing to bind them together?

    Perhaps I'm thinking too much?

    Edit: I was thinking too much. Now I've made a start on 0.7 and have removed all the globals from the core. Just bug fixing and then will start on plugins.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Docs] Global Constants and Variables
    By Nick in forum Developing Plugins
    Replies: 0
    Last Post: 09-28-2009, 12:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •