TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-13-2008, 03:53 PM   #1 (permalink)
The Wanderer
 
Join Date: Feb 2008
Posts: 15
Thanks: 2
Mathew is on a distinguished road
Default Super Object

Hi,

I have been using PHP for a number of years now and understand a good amount of OOP (Interfaces, Design Patterns and what not).

I wanted to understand how the Super Object class in CodeIgniter works. I know it uses a Singleton design pattern to return an object, but I don't quite understand how the other classes make use of this, since all clases don't have this implementation?

If someone could provide a small example that would be fantastic.

Kind Regards,
-Mathew
Mathew is offline  
Reply With Quote
The Following User Says Thank You to Mathew For This Useful Post:
delayedinsanity (04-14-2008)
Old 04-13-2008, 04:09 PM   #2 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

What is codeigniter? :S
__________________
Tanax is offline  
Reply With Quote
Old 04-13-2008, 04:14 PM   #3 (permalink)
The Wanderer
 
Join Date: Feb 2008
Posts: 15
Thanks: 2
Mathew is on a distinguished road
Default

It's a framework.

CodeIgniter - Open source PHP web application framework
Mathew is offline  
Reply With Quote
Old 04-13-2008, 05:30 PM   #4 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

This is a bit off topic, and just to clear this up, I have no clue, but... just random musing, I've been looking at a lot of frameworks lately to dissect their code and see what I could learn about how everybody else does their thing. The more I look, the less I understand the usefulness of said frameworks - honestly, even with a background in PHP and XHTML it would seem that most of them have a learning curve that just makes me wonder .. combined with all the code that they come with, depending on how much of it you plan to make use of, it seems to add up to a lot of bloat to me... how useful are these things, seriously? I mean, by the time you've gotten comfortable with the API of your chosen framework, and have decided what components of it you need and what you need to extend, how hard would it be to build a site from the ground up that only does what you need it to do, without all that additional payload. *shrug* sorry, this probably doesn't belong here, but what's done is done. :)
-m
delayedinsanity is offline  
Reply With Quote
Old 04-13-2008, 07:24 PM   #5 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

Well Delayed what if you want your site to do something different in the future? Wait strike that what about WHEN you want your site to do something different? Frameworks make extending the application easier - most frameworks only load the things you call forth so it's not a very big float.

With proper caching and the right kind of server a framework makes little difference as far as speed goes (atleast...any difference to what the user sees). The issue these days is making your application easy to scale and expand. Websites who don't update regularly with new content and features die, thats that.
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
Old 04-14-2008, 12:15 AM   #6 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Of course they do, but you don't need a third-party framework to be dynamic. Not even if you want to get technical and call everything, down to a blog backend or forum system a framework. I'm not trying to maliciously attack them here, just say that hey, if you know enough to code extensions on to a framework, why not just do it yourself in the first place? To which most people would reply that using a public framework all the code is tested and debugged and etc... though exploits pop up for them on a regular basis, the most prolific of these seems to be seagull, so I say, since you should have some knowledge of security anyways, framework or not, perhaps it's still yet better to build your own private framework as it will not be so publicly visible to would-be hackers and all those super intelligent 12 yr olds with moms computer.

I don't know. I'm all for open source, that's not what this is about (I was part of linux.com when it first launched, and if you knew my name and googled it, you'd find my crap posted all over linuxtoday.org and slashdot etc), I guess I'm just wondering if Lexus, BMW and Mercedes were all using Ford model frames, would they still be high end cars? To which I'm sure some will say, oh but Zend IS a Lexus frame. With a few honda parts, and an aftermarket gt cat-back exhaust system. Meh. I could argue both sides of this all by myself, all day. It was just a thought, and sorry again for pulling this away from the topic at hand.

Once again, sorry, no real input on that original topic, but thanks goes out simply for giving me something to study up on. To wit, singleton and other design patterns.
-m
delayedinsanity is offline  
Reply With Quote
Old 04-14-2008, 02:56 PM   #7 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I kind of agree with both arguments, although i would tend to lean towards my own 'framework', there is something i don't like about things not being within my control, i like to be able to see and completely understand the code, therefore bug solving is 100 times faster (in my opinion). Also a good point that delayed pointed out, the code in these frameworks is open source (i am also all for open source and an avid linux user) that makes me feel insecure because i know that thousands if not millions know exactly how the authentication system works for example. Dunno may just be me being paranoid again.

Back to the control thing, i tend to liken it to (going back to delayed's analogy of cars) fixing a car without any knowledge about the car but using a hynes manual, if you had the knowledge in the first place you wouldnt need to sit and read about the brake linkage in a ford fiesta for example, you could just pick up a spanner and be on your merry way. Therefore things, like maintainance and debugging, could get done quicker, on the other hand frameworks do and can save time in implementation and also you kind of know that the framework was writtin by people with an idea of what they are doing. One thing though, i dont understand why they would be easier to extend than you own code, surly leaning a whole new api just to create an extension to a framework is alot more work than just picking your own code up and adding bits to it, for one thing its coded in your style i.e. variable naming/class naming/function names/indentation too name but a few.

Anyway back to the topic if we may, I think (from reading a bit into it) code ignighter kind of compiles all your system objects into a 'super object', so basically your entire site runs from a single object, this apparently is suppsed to eliminate scope problems (that in my mind need not exsist if you design your code properly in the first place).
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 04-14-2008, 03:47 PM   #8 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

So let me get this straight and see if I have the remotest clue what's going on here. In real boiled down layman's terms, codeigniter uses, as it was called, a super object class and a method it calls load_class() to instantiate objects as sub-objects of said super object, allowing everything to be called through, for example $thistoplevel->subobjectclass->subobjectsmethods() as opposed to having $subobjectone->method() and $subclassfortytwo->method() sprinkled about your page?

So even though you have `class Top {}` and `class ImBottom extends Top {}`, working as your extension/plugin/controller, etc, you always call those objects through $Top-> ? If that's the case, isn't that a redundant method of organizing your code? Sounds like a very verbose way to avoid calling parent::__construct().
-m
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
Mathew (04-14-2008)
Old 04-14-2008, 05:34 PM   #9 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

thats what i gather from reading a bit of the code, odd but there u have it.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:05 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design