• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confusing name of view()-method in the tutorial

#1
This week I'm starting with a new course about frameworks and CI at SAE Zurich Institute.
Because I'm the teacher, I'm reading the documentation very attentively.

Two things seems to me not to be optimally solved in the tutorials:
- There is no really "Hello World" example
- In the "Static Page"-Example there is a method named "view()" in the CI_Controller Class.
This is very confusing for students who are new in the MVC world, because at the beginning it's very hard to understand the difference between controllers, Models and views (and to call the methods belonging to it)
I guess the reason for "view()" is "view the pages". It's has nothing to do with the "view"-expression coming from the MVC-Model

PLEASE rename this method for didactic reasons with an another word like "show()" or "showPage()". I think thousands of newbies would be grateful for this.
Thank you!
Reply

#2
Actually the method view() does not "show" anything. The showing action takes place much later after the controller is done executing. This happens without developer intervention.

To be pedantic, show() is a method of the loader class not the controller. So $this->load->view("someview"); is utilizing the "load" property of the controller ($this) to call the loader method "view" which will "include" the file "someview". Views are not classes in the CodeIgniter framework. They are php files that contain html and potentially template language markup. Because they are not classes views have no methods. But they might contain functions and frequently include php code along with the markup.

Defining a controller method called show() or showPage() that makes the call to view() would be a good instructional project for your students.

On the other hand, changing the name would be entertaining mostly because of the s__ storm is would cause due to the broken backward compatibility.
Reply

#3
Hi sponti,

Good luck with teaching CI. It is a fabulous framework and really easy to get going with.

(04-10-2017, 04:44 AM)sponti Wrote: - There is no really "Hello World" example
The 'Hello World' page is really the default page that is displayed when you first load CI. You can see the Welcome controller calling the welcome_view.

(04-10-2017, 04:44 AM)sponti Wrote: - In the "Static Page"-Example there is a method named "view()" in the CI_Controller Class.
This is very confusing for students who are new in the MVC world, because at the beginning it's very hard to understand the difference between controllers, Models and views (and to call the methods belonging to it)
I think you are absolutely right here. A simple change to the example and this possible source of confusion could be removed. It could easily be

PHP Code:
<?php
class Pages extends CI_Controller {

        public function 
display_page($page 'home')
        {
        }

As seen here in the tutorial as method 'view': https://www.codeigniter.com/user_guide/t...pages.html

In fact, perhaps it would also be a good idea to call the default controller 'Hello_world' and default view 'hello_world_view'.

So just wanted to say I agree with you and I hope you enjoy CI as much as we all do. The documentation is pretty spectacular when you get into it, but as always, is a labour of love by dedicated volunteers.

Best wishes,

Paul.
Reply

#4
Dear all,

thank you very much for your posts!

I'm teaching web technologies (like PHP OOP) since a long time and I am web developer as well.

I've realized several projects with CI and I really love this framework. I my opinion, the documentation of CI is ten times better than the one of Symfony and a hundred times better than the one of ZEND Framework.

CI is the best choice to explain basic principles in a PHP-framework like routing, MVC-pattern, form helpers, DB interaction, etc. My intention is to make an outstanding thing even better.

So again: The tutorial is for most of new users/learners the first contact with CI, but:

CI has it's own, native, given names (somehow like keywords) for methods. One of this "keyword" ist "view()".

But in the example, the word "view()" is used for a [controller-method] with I can baptize by myself. It has an influence on the routing

The same word "view()" is in the bottom of the same script (!!!), but there it has completely different meaning (!!!), because here it loads a view.

This fact is poison for a newbie, and I do not want anyone to be confused, because I really love CI. I think there's a real, deep need for changing the tutorials on this point!

Maybe this forum is not the best place for this topic, because it's not me that needs help. I have chosen this forum because of the hint "Not sure where else to ask something?"

Best wishes
Reply

#5
(04-12-2017, 01:31 PM)sponti Wrote: This fact is poison for a newbie, and I do not want anyone to be confused, because I really love CI. I think there's a real, deep need for changing the tutorials on this point!

I appreciate the desire to make the tutorial better, but ... "poison" and "deep need for change" (bolded), really?

For 5 years in CI, I've seen zero people that have had a problem with this. Perhaps if you're trying to teach people completely new to programming, it might be a minor issue for them, but even in that case: a) you're supposed to already know how PHP works; and b) we can't dumb down everything to "idiot" level ...

That being said, our documentation is also on GitHub and you're welcome to submit patches for it, just as anybody else is.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.