Saturday, February 26, 2011

Summary

Summary
The MVC framework is a widely used and very effective way of organizing a
complex website. CI uses it to help you sort out your own code, but it is also fairly
flexible about how it does so.

Try to keep in mind the two principles of 'loose coupling' and 'component
singularity' when you write your own code. Don't worry too much whether your
application conforms to the strict theory of MVC or not. The crucial thing is to
understand what the different types of file are, and how they relate to each other.
Then, you can decide whether to write your own code in library or model files, or as
helpers or plug-ins.

We've looked at the CI file structure, and seen how you can, if you want, inspect all
the CI code, but (thankfully!) you don't have to.

We did tinker with one of the original files: the config file, which holds critical site
information in one place to make it easier for us to upgrade or change later on.

We've seen the basic object structure of a controller, and used a simple constructor
to get some data from our config file and put it into a class property. And we've
dynamically passed information from a new controller we wrote, to a new view. So
far, the main thing CI has done for us is to encourage us to use a basic structure as
we start to define our site. As we go on, it will become clear just how important that
structure is.

Also, we looked a the way that CI's components pass data and control between
themselves. It's useful to understand this when you start to write your code.

Lastly, we looked at CI's own URL helper as a good example of a chunk of code, and
we wrote our own rudimentary 'menu' library class

No comments:

Post a Comment