Welcome Guest, Not a member yet? Register   Sign In
help to understand the CI_Loader code
#11

[eluser]Aken[/eluser]
There's nothing that says class properties MUST be declared at the top of the class. Doing so just depends on your coding style, class intentions, etc.

And obviously there are some limitations to declaring properties elsewhere, such as they'll automatically be given a public scope, and if you use something like isset($this->property) before it is defined, it will obviously come up as false.

Sure leaving out the load declaration might make things slightly harder to find, but it's not technically bad or wrong.
#12

[eluser]Ajaxboy[/eluser]
[quote author="Aken" date="1335211618"]There's nothing that says class properties MUST be declared at the top of the class. Doing so just depends on your coding style, class intentions, etc.[/quote]
There is nothing that says IE should be a browser either.. still is..
[quote author="Aken" date="1335211618"]
And obviously there are some limitations to declaring properties elsewhere, such as they'll automatically be given a public scope,
[/quote]
Wrong. They can also be private and even protected!. And $load obvious has a public scope!

[quote author="Aken" date="1335211618"]
Sure leaving out the load declaration might make things slightly harder to find, but it's not technically bad or wrong.[/quote]
Like there is nothing wrong about using globals, and using worse programming practices.. right... Tongue
#13

[eluser]Aken[/eluser]
[quote author="Ajaxboy" date="1335222726"][quote author="Aken" date="1335211618"]There's nothing that says class properties MUST be declared at the top of the class. Doing so just depends on your coding style, class intentions, etc.[/quote]
There is nothing that says IE should be a browser either.. still is..
[quote author="Aken" date="1335211618"]
And obviously there are some limitations to declaring properties elsewhere, such as they'll automatically be given a public scope,
[/quote]
Wrong. They can also be private and even protected!. And $load obvious has a public scope!

[quote author="Aken" date="1335211618"]
Sure leaving out the load declaration might make things slightly harder to find, but it's not technically bad or wrong.[/quote]
Like there is nothing wrong about using globals, and using worse programming practices.. right... Tongue[/quote]

1) Okay? What does the IE browser have to do with coding practices?

2) I said if you declare/assign properties elsewhere, meaning not at the top of a class, they will automatically be public. I'm well aware of the different property scopes.

Code:
class Foo {

    protected $foo; // Declared as protected.

    public function __construct()
    {
        $this->bar = 'something'; // Not declared, "dynamically" created. Defaults to public; cannot be set otherwise.
    }

}

3) I understand the point you're trying to make, but it's a little dramatic. Poor coding is one thing, but this has no ill performance or security affects. As long as the limitations of assigning non-existing properties are understood, it is really only an issue of readability, maybe an IDE auto-complete issue, etc.




Theme © iAndrew 2016 - Forum software by © MyBB