Page 3 of 6 FirstFirst 12345 ... LastLast
Results 21 to 30 of 58

Thread: In this thread we will discuss CodeIgniter!

  1. #21
    Join Date
    Jun 2008
    Posts
    74
    Rep Power
    0

    Default

    Quote Originally Posted by owen View Post
    I am what you call a old school programmer. I've written a few articles on the topic but programming procedurally more times than not allows me to be highly dynamic. The thought behind using something like CI would be to produce something "standard" very quickly.
    I do not think that you have answered my question. I've already attributed primarily using procedural programming to being an old school programmer. So the question still stands: Why are you mostly on the procedural side? or; Why are you an old school programmer?

    What I'm looking for is something like this:

    That you have used both procedural and oop programming and applied them to the same task and have found procedural programming to be more efficient, easier to test, reusable etc... and reasons and possible examples that justify your opinion/decision.

    Also i do not understand what you mean by "programming procedurally allows you do be more dynamic". Please define dynamic in that context.

    Also, please expound on this statement:
    "The thought behind using something like CI would be to produce something "standard" very quickly."

    What do you mean by standard?

    Your reply will be much appreciated.
    Last edited by jayrulez; Mar 7, 2011 at 06:27 PM.

  2. #22
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    You can read my Programming: The downsides of Modularity article or one of my other articles on programming. I was trying not to derail the thread with a complicated discussion of programming systematics but programming procedurally actually surpasses OOP. Objects and Classes are "features" of a programming language. Procedural programmers use all of these "features" of a language. Alotta people nowadays are preaching OOP like its a paradigm but it is really not. By saying I am old school procedural programmer means that I use Objects but I don't "OOP" all my code or otherwise force my way into a the OOP/MVC corner.

  3. #23
    Join Date
    Jun 2008
    Posts
    74
    Rep Power
    0

    Default

    Quote Originally Posted by owen View Post
    You can read my Programming: The downsides of Modularity article or one of my other articles on programming. I was trying not to derail the thread with a complicated discussion of programming systematics but programming procedurally actually surpasses OOP. Objects and Classes are "features" of a programming language. Procedural programmers use all of these "features" of a language. Alotta people nowadays are preaching OOP like its a paradigm but it is really not. By saying I am old school procedural programmer means that I use Objects but I don't "OOP" all my code or otherwise force my way into a the OOP/MVC corner.
    The link to your article is not working but if this is the same article, then I think you have a misconception. Modularity in programming is a concept. The examples you have used in the article do not show disadvantages of modularity; but rather show the shortcomings of programmers (inexperienced ones I'd say). Modularity increases efficiency, not reduce it as your article suggests. The example you used in your article is a very poor implementation of modularity and is unwarranted in the context. Modular code is expected to be reusable; your example does not show where the "modules" you have created were reused. So there was no good reason to make it modular rather than present the first example.

    Procedural programming has its place, modular programming has its place. It is up to the programmer to decide what to implement where. The concept modularity does not have rules that state how a program must be modularized; but rather, it makes suggestions i.e the separation of concerns. There are good implementations and bad implementations of both procedural programming and modular programming. You should not write off those bad implementations as disadvantages of the concept; rather you should recognize them as the bad practices of the programmers implementing the concept(s).

  4. #24
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    Are you on Flow internet? my hosting is annoying me to no end.

    You see this is the discussion i was trying to avoid. In order to write an article I have to have a topic and in order to have a topic I would have to state a fact. The fact I stated was "the downsides of modularity" NOT that "modularity is bad". The example is the point of the article, without, it the article would have no point, the point is the example. Now bad implementations are the reason why there are programmers, if there were no bad implementations then all programs could be written by machines. The article demonstrates a point, you either disagree or agree but you must first understand the point that the article is trying to convey.

    You would first have to look at the example as it is. THEN you would have to try to write the example in OOP. Then maybe MVC, so on and so forth. At which point you will understand what the article trying to convey to the reader. It is not first grade programming. It is a clear application of a concept to a real world example, an example which is more common than you may think.

    Anyway I would suggest you start another thread or email me if you want to further discuss programming theory.

  5. #25
    Join Date
    Jun 2009
    Posts
    40
    Rep Power
    0

    Default

    I was subscribed to this thread, not sure why I didn't receive email notifications of these replies.
    Jay, I have to say that I disagree with you on most points you made. It appears that you have not used CI very extensively.

    Quote Originally Posted by jayrulez View Post
    Codeigniter is for people who do not care much about improving their knowledge of the technology they use. The development pace is so slow that it hasn't really seen an improvement moving from the initial version to version 2. Version 2 was the perfect opportunity for them to do a ground up rewrite of the framework, but they just patched a few things and changed some text then tried to push the release as ground breaking improvements. All their devs sing about day and night is "preserving backwards compatibility". I agree, breaking backwards compatibility is not a good thing, but sometimes it's absolutely necessary in order to move forward. Their reason for promoting backward compatibility to that extent is that they believe that a project using CI 1.7.3 must run smoothly with little or no changes if the developer upgrades the framework to 2.0. That is utter nonsense. If the code works, then there is no reason that the dev must absolutely upgrade the framework in their deployments. If they want to update the framework, then they should thoroughly read the documentation of the new release and also the change log so they become aware of the changes they need to make to their code base. Problem solved.

    Other frameworks like symfony, zend and cakephp have taken the initiative to leverage the best of php the latest php improvements such as namespace, lambadas, security fixes and many more.

    I've been following the development of symfony2.0 for a while now and I've been impressed with the improvements over symfony1. It has seen a huge performance boost in terms of page execution time and memory consumption. It implements well known design concepts and conventions, it is very extensible and flexible. Working with it over the past few days, it reminds me of working with .NET mvc. I would encourage anyone that is competent in .NET MVC to use sysfony2 if they ever need to use a php framework.
    CI was designed to be a small footprint framework without the bloating, offering devs a solid foundation with the opportunity to extend the framework to their individual needs. I don't know what you feel should be added into the 'essential base' that CI aims for. Most 'libraries', such as authentication are available from third parties on github or other. I didn't really see the devs singing about backwards compatibility. What features could you add to this PHP framework besides updating it for the most current version of PHP (ie. start using namespaces etc.)?

    It is a publicly known fact that EL (EllisLabs) have had internal problems with producing updates not only for EE (ExpressionEngine) but also CI. Their stance was that CI came out of the development of EE, similar to RoR from 37Signal projects. They felt that they did not owe anything to the community to update or respond to their requests. This caused a lot of controversy and EllisLab responded by pushing out CIv2.0 and creating a volunteer engineering team to EL on CI Reactor. Reactor would be the dev (head) version, whereas the official EL would be maintained by EL staff and considered more 'stable'.

    If you have ever actually used Zend, Symfony (as bad as the other 2) or CakePHP you would know they are extremely bloated and slow compared to CI. Plus, good luck getting started using Zend; way too complicated. CI is small, extensible and has some of the best documentation out there.

    Quote Originally Posted by jayrulez View Post
    In my honest opinion, codeigniter either needs a rewrite to make it even remotely useful or it needs to save developers who are just diving into the world of php frameworks the trouble and close down the project.
    Again, I ask, specifically what needs to be implemented that isnt there already. Namespaces are still a luxury, not a necessity for 99.9% of apps. Most of the times, it just allows better organization.

    Quote Originally Posted by jayrulez View Post
    If i wanted create an application with a lot of forms and table is codeigniter, this is what i would have to do:

    After constructing the database, I would then have to create model to represent each table. . . .
    [Truncated quote due to length]
    This is what the MVC framework is. If you want to knock that, knock the use of MVC, not CI. Besides, you can easily implement HMVC if desired.

    Quote Originally Posted by jayrulez View Post
    If i had 20 tables, and need 20 forms, then I'd have to repeat that procedure 20 times. Also, their implementation of OOP and MVC is extremely flawed. They do not use auto loading of classes, instead they use a hack of a loader helper. You see it's use here:
    PHP Code:
            $this->load->helper(array('form''url'));

            
    $this->load->library('form_validation'); 
    You can autoload classes, such as helper, libraries, models and the database in config/autoload.php

    As for form validation, realistically, when are you going to have 20 forms? You working for government?

    You can offload validations into private functions.
    Quote Originally Posted by jayrulez View Post
    Also the validation rules are associated with a model, why are they placed in the controller action?
    They are not associated with a model. They are associated with the view. They are ensuring the data being passed from the view to the controller to the model are correct.

    Controllers, do what the name suggests, control everything, including validation.
    Models simply interact with the database.
    Views display the data.

    Quote Originally Posted by jayrulez View Post
    And here:
    PHP Code:
    $this->form_validation->set_rules('username''Username''required'); 
    Why is form validation a property of the controller?

    It is not, it is a propery of the CI superclass. Think you need to understand how it works.

    Quote Originally Posted by jayrulez View Post
    I think they have misinterpreted what MVC is.

    I could site a lot more flaws, inconsistencies etc... but this is getting boring.


    Let us say I wanted to accomplish the same thing using for example Yii.

    I'd just need to open the code generator, enter the name of my database, it will extract the list of table in the database. I could then generate a model for all table sin the database. I could then use the crud generator to generate both controller actions and forms for the models. After that, I'd just edit anything that needs to be edited like adding extra validation rules etc.

    That's rapid application development.
    I think you have misinterpreted what MVC is. I would like you to list some more flaws and inconsistencies.



    Quote Originally Posted by jayrulez View Post
    I believe that you would have to direct that question at them to get a honest answer. I could only make assumptions. I think it boils down to what you have been exposed to, your current level of knowledge and your tastes.

    When I just started using frameworks, Codeignitor was the first one a tried. Why?
    - My knowledge of the technology was not impressive and I found it impossible to understand less use giants like Zend and symfony.
    - There were a lot of blog posts and reviews that boasted that codeigniter was the fastest framework and the easiest to use. For a while, it was like I discovered gold because i considered it a huge improvement over procedural php which I was accustomed to. However, after a while, my thirst for knowledge grew and eventually outgrew codeigniter (Fortunately, soon enough for me to abandon the codeigniter camp before a became a tainted fanboy).

    I started looking elsewhere for something that would suite my needs. I evaluated literally over a hundred frameworks. I went as far as using frameworks written in different languages (chinese/mandarin) at one point (I was very impressed with the knowledge of the foreigners) [hellp thinphp http://thinkphp.cn hello I-Framework http://ifphp.cn ]. I've rolled with they ones that claimed to be the fastest :-O http://doophp.com ... I could go on and on and on... but let us move on.

    Eventually my knowledge grew in height to a point where I was able to see eye to eye with the big boys like Zend and symfony. They were good. However, they both had what a considered to be a dealbreaker for me. They were slow. So I continued by journey down framework road. It was then that I met Yii. We connected right away. The way it was so extensible, it had speed, the code was 100% beautiful OOP. I felt right at home with it. It provides the tools that help me to develop quickly especially when i've been sleeping on a project for weeks then the client ask me to show him/her something. I just tell him I'll put it up "later tonight". I then just run a crud on the database, drop in a few GridViews, ListViews, DetailViews etc and customize the hell out of those bad boys. By morning, I still have a client and a happy one at that.

    [Truncated quote due to length]
    Honestly, for the amount of frameworks you went through that didn't suit your needs, you should have rolled your own framework. I think you were looking for a framework that did everything you specifically wanted, but still being fast. The chance of that isn't going to happen. I took CI, made my changes, implemented my own consistently used models, libraries and helpers and use that as a base for all applications.

  6. #26
    Join Date
    Jun 2008
    Posts
    74
    Rep Power
    0

    Default

    1. Real autoloading
    2. Layouts
    3. Template inheritance
    4. Proper authentication (and optional authorization) mechanism
    5. A "real" session class
    6. Asset management
    7. PDO (a proper database abstraction layer).
    8. Proper implementation of active record.
    9. A form framework/component
    10. Proper unit testing (for those who actually test code)
    11. Environment management (dev, testing, staging, production...)
    12. Database migration
    13. Translation component for i18n applications.
    14. Database migration

    You'd be surprised to know how much forms some people have to work with.
    Last year I was on a team working on an application for a NY based entrepeneur. The application consisted of over 50 forms.



    How about better code organization.

    I found it quite easy to get started with zend after I gave it a second try.

    You can autoload classes, such as helper, libraries, models and the database in config/autoload.php
    If I do that, then those classes will be loaded even in requests that do not need them. That's unnecessary overhead. Real autoloading allows classes to be loaded when they are needed.

    Validation is associated with the model (data layer if you want to call it that). You do not validate views, you validate data. The model is responsible for encapsulating your data models so it is only logical that valitation be associated with models.

    If you want to do validation from your view, then I suggest you use javascript for that (Client Side Validation).

    If you are in the scope of a class eg:

    PHP Code:
    class MyClass
    {
        public function 
    __construct()
        {
            
    // I am here
        
    }

    $this refers to the instance of the class. Now any property or method accessed with $this belongs to the class whose instance is $this or one of its possible ancestors.

    So when i say

    PHP Code:
    $this->form_validation->set_rules('username''Username''required'); 
    Why is form validation a property of the controller?
    Then form_validation is undoubtedly a property of the controller since $this is used in the context of a controller. If that is wrong, please correct me. However, if you insist that it is wrong, I suggest that you become acquainted with object oriented programming.

    Back at you I think you have misinterpreted MVC and I find that is something that is not uncommon among Codeigniter programmers. (No offence intended, just check the community forums for the kind of questions asked.)

    I have rolled out my own framework, but I cannot be bothered to maintain and improve it. Hence, I've dropped it and joined two communities namely Yii and Symfony2.

    I suggest you read the article you sent me, compare CI's implementation of MVC with that of other frameworks if you find the time. It can only serve to increase your knowledge and expose you to other ways of doing things.

    I guess CI is satisfactory for a 1 man team but when you work in teams on larger applications, you will appreciate the beauty of a framework that's well put together.
    Last edited by jayrulez; Mar 12, 2011 at 03:28 AM.

  7. #27
    Join Date
    Jun 2008
    Posts
    74
    Rep Power
    0

    Default

    And just to prove my point, I will issue you a challenge. Will both create the a simple application, you doing it in codeigniter and I will use the yii framework then we can compare codes after to find out which framework is more efficient. If you accept this challenge, then you can decide on the application we build or you can let me do it.

  8. #28
    Join Date
    Jun 2009
    Posts
    40
    Rep Power
    0

    Default

    Quote Originally Posted by jayrulez View Post
    1. Real autoloading
    2. Layouts
    3. Template inheritance
    4. Proper authentication (and optional authorization) mechanism
    5. A "real" session class
    6. Asset management
    7. PDO (a proper database abstraction layer).
    8. Proper implementation of active record.
    9. A form framework/component
    10. Proper unit testing (for those who actually test code)
    11. Environment management (dev, testing, staging, production...)
    12. Database migration
    13. Translation component for i18n applications.
    14. Database migration


    If I do that, then those classes will be loaded even in requests that do not need them. That's unnecessary overhead. Real autoloading allows classes to be loaded when they are needed.
    The overheads for most classes are so small that autoloading them through config/autoload.php makes sense, especially for those which you are going to be using regularly such as sessions. Otherwise, you can specifically load them in each necessary function or in the constructor class.

    Again, most of your points above are available as 3rd party libraries or helpers (layouts, template inheritance, authentication, migrations, database abstraction). Environment management can be simply handled in your config files; I utilize that regularly. The AR implementation could be better, but it works just fine.

    Quote Originally Posted by jayrulez View Post
    Validation is associated with the model (data layer if you want to call it that). You do not validate views, you validate data. The model is responsible for encapsulating your data models so it is only logical that valitation be associated with models.

    If you want to do validation from your view, then I suggest you use javascript for that (Client Side Validation).
    You are validating the data that is coming from the view, passing through the controller, to the model. The models should technically only do database calls. You can validate the data inside the model instead of the controller if you want, but that is a purely personal choice.

    Quote Originally Posted by jayrulez View Post
    If you are in the scope of a class eg:

    PHP Code:
    class MyClass
    {
        public function 
    __construct()
        {
            
    // I am here
        
    }

    $this refers to the instance of the class. Now any property or method accessed with $this belongs to the class whose instance is $this or one of its possible ancestors.

    So when i say



    Then form_validation is undoubtedly a property of the controller since $this is used in the context of a controller. If that is wrong, please correct me. However, if you insist that it is wrong, I suggest that you become acquainted with object oriented programming.
    Remember, this is how the controllers are setup:

    PHP Code:
    class MyClass extends CI_Controller
    {

    The important part being extends CI_Controller and when the validation library is loaded:

    PHP Code:
    $this->CI =& get_instance(); 
    Quote Originally Posted by jayrulez View Post
    Back at you I think you have misinterpreted MVC and I find that is something that is not uncommon among Codeigniter programmers. (No offence intended, just check the community forums for the kind of questions asked.)

    I have rolled out my own framework, but I cannot be bothered to maintain and improve it. Hence, I've dropped it and joined two communities namely Yii and Symfony2.

    I suggest you read the article you sent me, compare CI's implementation of MVC with that of other frameworks if you find the time. It can only serve to increase your knowledge and expose you to other ways of doing things.

    I guess CI is satisfactory for a 1 man team but when you work in teams on larger applications, you will appreciate the beauty of a framework that's well put together.
    I am not saying that CI is perfect and the "be all, end all". Quite the opposite.

    I am saying CodeIgniter is a fantastic base that offers all of the foundation functions that a basic PHP application would require. Should you require further and more complex functions, you can write them. But it makes no sense to build a framework, in my opinion, where a lot of the functions do not get used or are for specific instances. You are bloating it.

    Once you understand that was the intention of CI, you will be less likely to complain about what it does not have and then simply extend it as you need.

    As for your challenge, what do you have in mind? Don't go give me a week long application to write; don't have the time! haha

  9. #29
    Join Date
    Jun 2008
    Posts
    74
    Rep Power
    0

    Default

    Again, most of your points above are available as 3rd party libraries or helpers (layouts, template inheritance, authentication (This is not an authentication component, It's a user management extension,Don't just look at the name, check the code. And it's not generic enough, it's too specific.), migrations, database abstraction) (I did say proper, this doesn't make use of pdo and all it has to offer). Environment management can be simply handled in your config files; I utilize that regularly. The AR implementation could be better, but it works just fine.



    You are validating the data that is coming from the view, passing through the controller, to the model. The models should technically only do database calls. You can validate the data inside the model instead of the controller if you want, but that is a purely personal choice.
    Data doesn't come from forms, data comes from urls via $_GET, web services etc... You do not always have access to or control over the forms. For example, I might offer an api that allows others to create records in my site but they should implement the form etc.. themselves. I will not have control over that form or access to it. So following your logic, how do I validate the data that is being sent to my database?



    Remember, this is how the controllers are setup:

    PHP Code:
    class MyClass extends CI_Controller
    {

    I am aware. That was just an example to highlight how class properties/methods work.

    The important part being extends CI_Controller and when the validation library is loaded:

    PHP Code:
    $this->CI =& get_instance(); 


    I am not saying that CI is perfect and the "be all, end all". Quite the opposite.

    I am saying CodeIgniter is a fantastic base that offers all of the foundation functions that a basic PHP application would require. Should you require further and more complex functions, you can write them. But it makes no sense to build a framework, in my opinion, where a lot of the functions do not get used or are for specific instances. You are bloating it.

    For the work I do, I need a lot of tools that the average developer will not need. There are a lot of things that it doesn't make any sense to write because they are provided by other libraries/frameworks. One of the large pitfalls with CI is that it is that the components are so tightly coupled that you have to break an arm and a leg just to integrate external tools/libraries. It is also painful to change the existing behaviour.

    Once you understand that was the intention of CI, you will be less likely to complain about what it does not have and then simply extend it as you need.
    Point above: extending is painful in CI.

    As for your challenge, what do you have in mind? Don't go give me a week long application to write; don't have the time! haha[/QUOTE]
    For the challenge, It has to be something that will interact with the database, and works with forms & validation and also simple authentication & authorization. It should take maybe 2-4 hours.

    So let us make it a simple blog application:

    We will work with 3 tables. A user table, a post table and a comment table.

    Table structures are as follows:

    User (id:integer, username:string, email_address:string, password:string, create_time:integer, update_time:integer) The id should increment automatically, the username must be unique and be between 5 and 32 characters long and should be stored as lower case, the email address must be unique and in the format of a valid email address i.e identifier@domain.tld (store as lower case), the password must be encrypted, create_time must record the time that the user created his/her account, update_time may be null.

    Post (id, user_id, title, content, create_time, update_time)
    The id should automatically increment, the user_id should reference the user.id,
    the title must be between 10 and 255 characters long, the content cannot be empty (use a text field if you are using mysql). create_time is time time the blog post was created, update_time may be null.

    Comment (id, post_id, user_id, content, create_time, update_time)

    id again should auto... increment, post_id should reference a post.id, user_id is the id of the user that made the comment, content is the comment and create_time, the time the comment was made. The update_time may be null.

    All authenticated users can make posts. Only authenticated users may comment on a post. All users are able to view blog posts and their comments. A user should be able to login with their (username/email address) and password.

    On page with the list of blogs:

    for each blog post, the title should be linked to a page where you can view the full blog post and all the comments related to that post.

    Each blog post in that list should look like this:

    [post title] by [link to user who made post] at [time post was made]
    [content of post, if content is long than 300 characters, it should be truncuated to 300 and ... appended to the end]
    [# of comments]

    Only 10 blogs should be on a page, other blog posts will be accessible by using pagination at the bottom of the page.

    On the blog view page, you can view the full blog post and the list of comments on the blog. Only 20 comments should be displayed, other comments should be accessible by using pagination. Also there should be the form to comment on the blog post.

    The owner of the comment should be able to delete the comment from the blog view page.

    When you click on the username from a comment or blog, you should have a view that shows the user's username, email address, the total number of blogs posts they made and a link to their last blog post.

    That is all. If I didn't explain any of the requirements properly, please let me know. Let me know how long it will take you to do this.

    I did not post the database structure because I am not sure which dbms you will be using.

  10. #30
    Join Date
    Jun 2008
    Posts
    74
    Rep Power
    0

    Default

    The database structure for mysql using innodb:

    Code:
    CREATE TABLE IF NOT EXISTS `comment` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `user_id` int(11) unsigned NOT NULL,
      `post_id` int(11) unsigned NOT NULL,
      `content` text NOT NULL,
      `create_time` int(11) unsigned NOT NULL,
      `update_time` int(11) unsigned DEFAULT NULL,
      PRIMARY KEY (`id`),
      KEY `FK_comment_user` (`user_id`),
      KEY `FK_comment_post` (`post_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    CREATE TABLE IF NOT EXISTS `post` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `user_id` int(11) unsigned NOT NULL,
      `title` varchar(255) NOT NULL,
      `content` text NOT NULL,
      `create_time` int(11) unsigned NOT NULL,
      `update_time` int(11) unsigned DEFAULT NULL,
      PRIMARY KEY (`id`),
      KEY `FK_post_user` (`user_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    CREATE TABLE IF NOT EXISTS `user` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `username` varchar(32) NOT NULL,
      `email_address` varchar(50) NOT NULL,
      `password` varchar(32) NOT NULL,
      `create_time` int(11) unsigned NOT NULL,
      `update_time` int(11) unsigned DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `username` (`username`),
      UNIQUE KEY `email_address` (`email_address`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    
    ALTER TABLE `comment`
      ADD CONSTRAINT `FK_comment_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
      ADD CONSTRAINT `FK_comment_post` FOREIGN KEY (`post_id`) REFERENCES `post` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
    
    ALTER TABLE `post`
      ADD CONSTRAINT `FK_post_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •