CodeIgniter Forums
few questions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: few questions (/thread-25667.html)



few questions - El Forum - 12-20-2009

[eluser]Unknown[/eluser]
Hello!

I have few questions.

But first, my current situation:
- I have few years of PHP experience, small one-man projects only.
- I'm ashamed to admit, but due to laziness, I have no knowledge of OOP, so I use procedural style only.
- I never used any framework, and everything I know about MVC is what I've read in Wikipedia article.

Other side of my situation is this: I have BIG one-man project in front of me. I have 3 months to do it. And application will have to be easily maintainable by other people in foreseeable future. So I guess that spaghetti code will have to go away.

I think that this is a great opportunity for me to improve myself as a developer, so I've decided to learn OOP and some MVC framework. From what I heard, CI is easiest to learn and easiest to use -- and that gives it big advantage, because I don't have much time -- and CakePHP is more powerful, but harder to learn. So I'm choosing between CI and Cake. And I have two questions concerning PHP4 compatibility in CI:
- How does it affect PHP5 specific functions, e.g. file_put_contents()?
- Will I have to learn PHP4-style OOP (I'm too lazy to learn PHP4 OOP, if PHP4 will be dead in 2 years)?
- And, completely unrelated to previous questions: do you think that this (mastering at least basic level of OOP/CI/MVC, and then creating application, all in 3 months) is doable, or should I quit the project (and study at some slower pace)?

Thanks,
Flavescent


few questions - El Forum - 12-20-2009

[eluser]Kip zonder Kop[/eluser]
I don't know the exact details of your project and so I can't asses te feasibility of it. General common sense answers to your questions as far as I'm concerned

[quote author="Flavescent" date="1261330228"]
- How does it affect PHP5 specific functions, e.g. file_put_contents()?
[/quote]

It doesn't. Use php5 features as you like.

[quote author="Flavescent" date="1261330228"]
- Will I have to learn PHP4-style OOP (I'm too lazy to learn PHP4 OOP, if PHP4 will be dead in 2 years)?
[/quote]

No, use php5 style as you like.

[quote author="Flavescent" date="1261330228"]
- And, completely unrelated to previous questions: do you think that this (mastering at least basic level of OOP/CI/MVC, and then creating application, all in 3 months) is doable, or should I quit the project (and study at some slower pace)?
[/quote]

If you are really used to large-scale one men spaghetti code, CI will be heaven.


few questions - El Forum - 12-20-2009

[eluser]flaky[/eluser]
Answer to your 3-rd question. (at least my answer)
It's doable. I've done it, after 2 years of only procedural programming, I had to do a project in less than 4 months (mainly statistics), procedural programming wasn't even in consideration. There is where CI came in help. Everything with CI is easier and more configurable, while letting you control the whole process of programming the logic. I finished the project in 3 months (exceeded even my expectations), and I got a renewal contract for the project.

While all this sounds cool there were also some downsides. Because of the amount of work that had to be done in a very short amount of time I had to learn very fast and sometimes I'd create sloppy code.


few questions - El Forum - 12-20-2009

[eluser]Unknown[/eluser]
Kip zonder Kop and flaky, thank you for your answers!

Flavescent


few questions - El Forum - 12-20-2009

[eluser]BrianDHall[/eluser]
PHP4 vs PHP5 style OOP - CI is backwards compatible by avoiding php5-only functions in the core, or when they do use them they try to provide core functions to make it work even on php4 systems. But there is nothing that prevents php5 functionality at all. In fact most extensions to CI require php5, including many of the auth systems and most (if not all) ORM systems.

As to your project, I came to CI in nearly _exactly_ the same position as you. I had a project built by someone else that needed redone and fixing (it wasn't really done at all), had never used OOP at all, and was used to 1-man spaghetti code. CI allows you to improve while not requiring you to learn a 1000 things at once.

I think you'll find it wonderful to work in, and as you learn you may very well find that CakePHP is not particularly more powerful or faster to develop with - CI just does some things very differently than other frameworks (like no command line required), and it seems like it is 'missing' those features. Soon you'll find in CI that with a little proficiency you can largely eliminate CRUD (create, retrieve, update, delete database functionality), creating new controllers/models/views takes no more time than calling up a command line, and the lack of some magic/convention functions can often speed development by making it easier to wrap your head entirely around what is going on.

One tip - on my first project I skipped prebuilt auth systems and ORM to just develop FAST, because I needed a totally rebuilt system in a WEEK that the last developer had 3 months to work on. I couldn't spare the extra day or two it might take to get up and running with them.

On auth, I'm still undecided, as I still use my own built systems. On ORM I use Datamapper OverZealous Extention available over in ignited code forum - which I dearly love, but it may be best to start without it to not overtax your brain. It's very magical, as all ORM systems are, as much as I love it now I don't know that I'd have appreciated it when I started.

Anyway, my Really Import Tip #1 - get a debugger. Seriously, half the problems posted in this forum would be unnecessary if they had a debugger.

I found an IDE with PHP syntax checking really helped, especially with OOP. It's hard to get use to Object::function() and $this->object->etc and when working inside controllers and models there are those extra brackets of the class and function you are working in, its easy to make a mistake even once you are very experienced.

But having a debugger, jeeze. What a difference its made. I still sometimes use var_dump() for a quick peek at a variable, but when anything more complicated is needed stepping into debug mode and advancing through your code one line at a time provides remarkable insight. I personally use Netbeans with its built-in support for Netbeans, and then either WampServer or XAMPP for the localhost server/debugging environment.

The forums here have the info on getting them working with CI, and it's easy (one copy/paste into your php.ini file, maybe a download of a single file for xdebug, and a switch in your CI's config.php file) - and the plus is you learn to setup CI to support query strings, which I think it really should do by default anyhow.

Good luck on your project, and welcome to CI! I think you'll find this one of the more helpful communities around, and CI to be a shockingly easy framework to get into.

I'll warn you its easy to get so used to it to feel you want more challenge, like maybe there are better tools to help you work faster. Note that you don't have to go to a different framework for them, they are available over in Ignited Code or in the forum. Auth, HMVC, ORM, magic/convention (rails style) functionality, use of Zend Framework libraries (they have a lot of them), you name it - it's available in CI, you don't even have to learn another framework to use them. You just aren't required to use them to get started Wink


few questions - El Forum - 12-21-2009

[eluser]jedd[/eluser]
I'll throw in a couple of extra observations.

For an even easier life, and assuming you're coming from the kind of background that I think you are, learn git (or at least some vcs). If you're not using anything at the moment, you'll wonder how you lived without it. Allocate about an hour to read through a couple of git tutorials (eg. [url="http://spheredev.org/wiki/Git_for_the_lazy"]this one[/url], or [url="http://www.kernel.org/pub/software/scm/git/docs/everyday.html"]this[/url] and finally [url="http://progit.org/"]pro git[/url]). It'll save you days worth of time later.

OO - you are not obliged to be OO in your coding style with CI. Arguably PHP's OO facilities don't offer some of the more interesting aspects of OO anyway, but in either case you can continue to treat the process as (mostly) procedural. Models for example are generally used by most people as a library of database calls - an API essentially - rather than instantiating multiple copies of each model. It's also important to remember that there's not a lot of evidence to suggest that OO is superior to procedural, in performance or robustness.