Welcome Guest, Not a member yet? Register   Sign In
Learning OOP through CI
#1

[eluser]Schneider707[/eluser]
I wanted some opinions on how to go about my situation.

I just got into PHP...about 3 weeks ago I'd say. I'm doing alright with my code but it gets kinda crazy when all of these functions start building up into huge lists for any application. So I figured I'd keep going and start on OOP to help with application development. I think CI would be a good framework for almost any near future sites im hoping to develop but I don't know OOP. Should I learn OOP before I try CI or learn both at the same time?

It doesn't really matter to me which way it happens, but I don't wanna gimp myself. I also don't wanna learn coding one way and then struggle to integrate what I have already developed.

Make sense?
#2

[eluser]pilotLight_Tre[/eluser]
Hey there,

CI is ALL OOP. So, if you fully understand CI, you should have no problem understanding OOP in PHP. CI has an excellent User Guide that you will probably not find anywhere else (in regards to learning a programming language). To to mention the forums for support from other users.

So to answer your question, you are learning OOP when you are learning CI.

Good luck with everything!
#3

[eluser]Phil Sturgeon[/eluser]
You will have a slight problem in that most PHP coders who learn via CI spend the whole time trying to work out "what is the CI way to do X". If you understand PHP fully you can do whatever you like. If you only know CI you can only use whatever libraries other people have made.

If you can't think of how to do something in CI, just use native PHP to build a library, helper or model and then it will work fine. Then you will be ok!
#4

[eluser]dmorin[/eluser]
Quote:CI is ALL OOP. So, if you fully understand CI, you should have no problem understanding OOP in PHP.

While this is true, it's also a little misleading. In CI, you can basically create huge controller methods in which case, it's just procedural coding within an oop method. Also, because of the loader, most people restrict their ideas to single library classes and just about any oop design pattern requires multiple classes as well as abstract classes or interfaces.

So while CI is OOP, it's very easy to use CI in a procedural way which makes for bloated controllers and less-maintainable code.
#5

[eluser]Tom Schlick[/eluser]
you should also remember that not all the syntax in CI will transfer over to regular OOP. there are hacks that the CI team has put in place for CI to run more smoothly and become easier to learn. it will be a great asset to you to learn how CI uses this. there are thousands of books and articles online about this if you are interested.

Good Luck! and as always we will be here to help you through the troublesome spots Smile
#6

[eluser]drale2k[/eluser]
[quote author="trs21219" date="1233130747"]there are thousands of books and articles online about this if you are interested.

Good Luck! and as always we will be here to help you through the troublesome spots Smile[/quote]

Can you give an advise which book is good? I read atm one but its not so good explained.
#7

[eluser]helmutbjorg[/eluser]
I would suggest if you continue to use codeigniter make sure you don't just use the library, helper, etc functions without searching how they actually work. It would be easy just to look at the final product without learning anything.

For example... if you use the html helper and you try

Code:
echo heading('Hello World', 2);

make sure you investigate how that function actually works...

Code:
/**
* Heading
*
* Generates an HTML heading tag.  First param is the data.
* Second param is the size of the heading tag.
*
* @access    public
* @param    string
* @param    integer
* @return    string
*/    
if ( ! function_exists('heading'))
{
    function heading($data = '', $h = '1')
    {
        return "<h".$h.">".$data."</h".$h.">";
    }
}
#8

[eluser]Myles Wakeham[/eluser]
If you are going to develop more than small scripts in PHP, you'll want to embrace OOP. The fact that you are using CI suggests you are trying to do something other than simple scripts in PHP. Like most programming languages these days, PHP and CI embrace OOP and kinda assume that you are going to use it if you are doing anything serious.

Also CI is based around the MVC design pattern, which is closely coupled with OOP.

In a perfect world, you'd learn OOP, then MVC design pattern fundamentals, then PHP5, etc. If you are doing this in a different order, try and focus on the missing parts of your study so that all of these items are given the appropriate attention and you'll be happy you did.
#9

[eluser]nmweb[/eluser]
I'm inclined to agree with dmorin. CI uses objects and classes more or less as syntactic sugar. Getting to know CI will get you acquainted with OOP syntax but not so much with the mindset that comes with OOP. It might provide for a good stepping stone to web programming or MVC, if you're dead bent on learning OOP I suggest Zend Framework. ZF has interfaces, abstract classes, design patterns, php5 (much better OOP than php4) etc. Better yet, go and learn Java as that's much better geared towards OOP than PHP.

Nonetheless, for simplicity and MVC, CI is a good candidate with a big community.




Theme © iAndrew 2016 - Forum software by © MyBB