www.webdeveloper.com
Page 5 of 14 FirstFirst ... 34567 ... LastLast
Results 61 to 75 of 198

Thread: My questions thread.

  1. #61
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    Much of the above is why I was more interested in being part of a development team within a company rather than an independent freelancer -- I'm good at programming, not so hot at sales, marketing, contract negotiation, contract management, etc., etc., and so forth.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  2. #62
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Quote Originally Posted by mistin.ca View Post
    Prior to commencing work you outline your "scope of work" which indicates what is included in your price, and anything beyond that is billed at your hourly rate... at the same time you should be held responsible for what was in the scope - if something doesn't work you should ensure it does after the fact with bug fixes, etc.
    So you have, like, your basic package? What do you include in it? I only know about web applications from a game context but I'm thinking a basic game package would be all the essentials like registration, login, basic moderation tools for admins, basic game mechanics like the ability to for players to breed animals, a forum so players can negotiate sales and stuff, etc. I'm guessing its the nice-to-have features that I should charge extra for? Stuff like a chat room, a fancier forum, more game-related activities, etc.
    The better I get at programming, the more I appreciate arrays. Handy dandy things they are.

  3. #63
    Join Date
    Jul 2012
    Location
    Vancouver
    Posts
    61
    Quote Originally Posted by evenstar7139 View Post
    So you have, like, your basic package? What do you include in it? I only know about web applications from a game context but I'm thinking a basic game package would be all the essentials like registration, login, basic moderation tools for admins, basic game mechanics like the ability to for players to breed animals, a forum so players can negotiate sales and stuff, etc. I'm guessing its the nice-to-have features that I should charge extra for? Stuff like a chat room, a fancier forum, more game-related activities, etc.
    I'm just referring to general work, any project should have a scope of work.

    If you're talking about selling 1 application to the masses that's slightly different.. you should be providing product support and general assistance on getting it deployed on their system.. but this is also why so many people moved to saas models, and different levels of service/features

  4. #64
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Ahh! I ran into some problems that have been stumping me since yesterday. I can't code a darn thing until I untangle myself from this confusion Here goes:


    #1 I have a MVC pattern going (I think) but I can't figure out A) where the interface is. Is it the controllers? B) Where is the implementation? Is it the models? C) The index.php in the root, and the stuff in libs, are they implementation, interface, or neither? For your reference, my file scheme is much like this: http://jream.com/public/lab/mvc.tutorial.part.1.zip

    #2 I have rewrite rules and a bootstrap class letting me access a controller and, optionally, a method through the URL. How do I make my hyperlinks on my site? Should I do them this way:

    PHP Code:
    <a href='http://www.mydomain.com/controllername/methodname/paramater'>Link Text Here</a
    #3 Where would a form validation class go? Model or controller? It deals with data coming in from the user, which seems like a controller kind of thing, but it's manipulating data, isn't it? All database and data-manipulation jobs are that of the model, yes?

    #4 I'm trying to wrap my head around what a controller's counterpart would have been in my old procedural PHP code. With that site, one .php page handled about everything for its particular umm...entity. Like the signup script. Signup is distinct entity, I guess? Anyway, signup.php dealt with user registration. With the exception of require statements that brought in the layout HTML and database connection, everything it needed was contained within the one file.

    A) With OOP would I replace this with a Signup controller? B) Would the controller be very skinny because it would mostly just be having the model do stuff for it? Like, maybe the controller would have a method that pretty much says "Model check and see if this username has already been registered." and then depending on what the model says, it decides what to do after that. C) Are all calls to the controller's methods going to happen through the URL?

    #5 I've been unable to get a clear grasp of the terms "application logic" and "business logic," despite vigorous Googling. Do I need to know what they mean to be a good programmer?

    Whoever answers should get cookies <3 You must be very patient
    The better I get at programming, the more I appreciate arrays. Handy dandy things they are.

  5. #65
    Join Date
    Jul 2012
    Location
    Vancouver
    Posts
    61
    Quote Originally Posted by evenstar7139 View Post
    Ahh! I ran into some problems that have been stumping me since yesterday. I can't code a darn thing until I untangle myself from this confusion Here goes:


    #1 I have a MVC pattern going (I think) but I can't figure out A) where the interface is. Is it the controllers? B) Where is the implementation? Is it the models? C) The index.php in the root, and the stuff in libs, are they implementation, interface, or neither? For your reference, my file scheme is much like this: http://jream.com/public/lab/mvc.tutorial.part.1.zip

    #2 I have rewrite rules and a bootstrap class letting me access a controller and, optionally, a method through the URL. How do I make my hyperlinks on my site? Should I do them this way:

    PHP Code:
    <a href='http://www.mydomain.com/controllername/methodname/paramater'>Link Text Here</a
    #3 Where would a form validation class go? Model or controller? It deals with data coming in from the user, which seems like a controller kind of thing, but it's manipulating data, isn't it? All database and data-manipulation jobs are that of the model, yes?

    #4 I'm trying to wrap my head around what a controller's counterpart would have been in my old procedural PHP code. With that site, one .php page handled about everything for its particular umm...entity. Like the signup script. Signup is distinct entity, I guess? Anyway, signup.php dealt with user registration. With the exception of require statements that brought in the layout HTML and database connection, everything it needed was contained within the one file.

    A) With OOP would I replace this with a Signup controller? B) Would the controller be very skinny because it would mostly just be having the model do stuff for it? Like, maybe the controller would have a method that pretty much says "Model check and see if this username has already been registered." and then depending on what the model says, it decides what to do after that. C) Are all calls to the controller's methods going to happen through the URL?

    #5 I've been unable to get a clear grasp of the terms "application logic" and "business logic," despite vigorous Googling. Do I need to know what they mean to be a good programmer?

    Whoever answers should get cookies <3 You must be very patient
    1. Are you referring to class interfaces, or the actual UI (user interface)..

    Typically >
    index auto loads your bootstrap / controller / model / view.
    bootstrap parses information on which controller to load, your controller handles the "framework" of the app so to speak, which does all data handling through the model - after everything is done your view is loaded and user output is done there..

    2. That's generally how you do them, /controller/method/slug_passed_to_function/2/3/4/5/6/7/8/

    3. Form validation would be considered a helper or library. Controllers don't handle data coming from the user, that's what models do.. controllers just tell everything where to go, what to do, etc.

    4. You controllers counterpart is essentially your if(isset($_POST["username"]] ) { do_signup(); }

    With OOP your controller would handle what to do ie; user/signup, user/authenticate, etc. Your controller would then call your model to do the actual checks, registration, authentications.. then output to your views.

    5. Depends on what you're referring to, the terms themselves are very ambiguous

  6. #66
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    Sign-up might be one method in a user authorization controller. It might make use of one or more other "library" classes/packages/whatevers to do the actual down-in-the-weeds work, and quite likely interacting with one or more models used for keeping track of user-related data. That controller would then invoke applicable views for things like sign-up/registration, log-in, log-out, and so forth.

    In general, try to keep your controllers pretty lean: they should mainly be concerned with playing "traffic cop", figuring out what, models, views, library methods/functions, etc. to invoke based upon inputs/responses from other layers of the system. When you find your controller methods are going from tens of lines to hundreds of lines, you're probably putting too much business logic into them instead of keeping it compartmentalized in the models and libraries.

    PS:
    Business logic: the logic that applies to whatever real-world problem you are solving, e.g.: "If a user selects to walk their dog, add one health point and one contentment point to their dog's status."
    Application logic: how the application will actually do all the things necessary to allow the implementation of the correct business logic, e.g.: "If the user selects the 'walk dog' option, invoke the Dog model and run its walk() method, which in turn will invoke the DogActivity model to determine what attributes are to be affected and by how much, and apply those changes."
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #67
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Quote Originally Posted by mistin.ca View Post
    1. Are you referring to class interfaces, or the actual UI (user interface)..

    Typically >
    index auto loads your bootstrap / controller / model / view.
    bootstrap parses information on which controller to load, your controller handles the "framework" of the app so to speak, which does all data handling through the model - after everything is done your view is loaded and user output is done there..

    2. That's generally how you do them, /controller/method/slug_passed_to_function/2/3/4/5/6/7/8/

    3. Form validation would be considered a helper or library. Controllers don't handle data coming from the user, that's what models do.. controllers just tell everything where to go, what to do, etc.

    4. You controllers counterpart is essentially your if(isset($_POST["username"]] ) { do_signup(); }

    With OOP your controller would handle what to do ie; user/signup, user/authenticate, etc. Your controller would then call your model to do the actual checks, registration, authentications.. then output to your views.

    5. Depends on what you're referring to, the terms themselves are very ambiguous
    #1 Class interface.

    #5 I was speaking in terms of models and controllers.


    Quote Originally Posted by NogDog View Post
    Sign-up might be one method in a user authorization controller. It might make use of one or more other "library" classes/packages/whatevers to do the actual down-in-the-weeds work, and quite likely interacting with one or more models used for keeping track of user-related data. That controller would then invoke applicable views for things like sign-up/registration, log-in, log-out, and so forth.
    A signup...umm...thingy...darn my terminology...anyway, it can be nothing more than a method? How could one method figure out whether or not to display the signup form, whether or not a form has been submitted, whether or not the form was completely filled out, whether or not the values are valid, whether or not to add a row to the user table in the database, etc. Wouldn't these be multiple methods inside some larger class?

    And if signup just was a method, what kind of class would it be in?
    The better I get at programming, the more I appreciate arrays. Handy dandy things they are.

  8. #68
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    Quote Originally Posted by evenstar7139 View Post
    ...
    A signup...umm...thingy...darn my terminology...anyway, it can be nothing more than a method? How could one method figure out whether or not to display the signup form, whether or not a form has been submitted, whether or not the form was completely filled out, whether or not the values are valid, whether or not to add a row to the user table in the database, etc. Wouldn't these be multiple methods inside some larger class?

    And if signup just was a method, what kind of class would it be in?
    This may be a bit simplistic, thus making some of the methods seem really short, but maybe not, since I'm not adding much in the way of defensive coding and such...but it's just to give you an idea:
    PHP Code:
    <?php
    class UserAuth extends Controller
    {
        public function 
    index()
        {
            
    // invoked when no method specified
        
    }
        
        public function 
    register()
        {
            if(isset(
    $_POST['submit'])) {
                if( ! 
    $this->validateRegistration($_POST$errors)) {
                    
    $this->load_view('register'$errors);
                    return;
                }
                if( ! 
    $this->processRegistration($_POST$errors)) {
                    
    $this->load_view('register'$errors);
                    return;
                }
                
    $this->load_view('register_success');
            }
            else {
                
    $this->load_view('register');
            }
        }
        
        public function 
    login()
        {
            
    // login control here
        
    }
        
        public function 
    logout()
        {
            
    // logout control here
        
    }
        
        private function 
    validateRegistration($data, &$errors)
        {
            
    $validator $this->load_library('form_validation');
            
    $fields = array(
                
    // define the fields and attributes to be validated
            
    );
            return 
    $validator($data$fields$errors);
        }
        
        private function 
    processRegistration($data, &$errors){
            
    $user $this->load_model('User');
            return 
    $user->add($data['name'], $data['password']);
        }
    }
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  9. #69
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Numbered for convenience:

    #1 Hmm, so do you recommend I have a class called "controller" that all my controllers extend?

    #2 Do I do the same with my models?

    #3 Also, my understanding of a library is a bit sketchy. A) Is it a black hole that all your non-model and non-controller classes go in? B) Is this where you put any classes you download (I think these are called packages?)

    #4 I have an autoloader (shown below). How would that effect the design of the userAuth class?

    PHP Code:
    function __autoload($classname)
    {
        
    $dir '';
       if (
    str_replace('_'''$classname) != $classname
        {
            
    $classArray explode('_'$classname);
           
    $dir $classArray[0].'/';
        }
        
        
        if (
    preg_match('/\\\\/'$classname))
        {
            
    $path str_replace('/'DIRECTORY_SEPARATOR$classname);
        }
        else
        {
           
    $path str_replace('_'DIRECTORY_SEPARATOR$classname);    
        }
        
        
    $path $_SERVER['DOCUMENT_ROOT'].'/mvc/controllers/'.$dir.$classname.'.class.php';
        require_once 
    $path;
    }   

    spl_autoload_register('__autoload'); 
    My autoloader is kind of lame but the general idea was all controllers would be in the controllers folder. If a class has a name with a _ in it, like, oh I don't know, forum_post, the autoloader would look in the forum subdirectory of controllers for forum_post.class.php So we'd end up with a path like home2/mysite/public_html/mvc/controllers/forum/forum_post.class.php Or at least it's supposed to work that way. I'm not sure how well it works. My brain is fried at the moment. Too much PHP, lol
    The better I get at programming, the more I appreciate arrays. Handy dandy things they are.

  10. #70
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    #1 and #2: Yes, if you plan to re-use your framework and want to include common processing for all controllers and models in base classes for them.

    #3: Yet another ambiguous term, in this case a catch-all for anything that does not easily fit into your controller or model paradigm -- either it's 3rd party or non-MVC code that you want to easily include into your application, or it just doesn't seem to fit in well as either a model or controller.

    #4: I'm used to the CI design where, from within the controller, you call a "load" method for models and libraries, and that method handles the inclusion of the necessary class, much the way an __autoload() does (based on whether you're using the load-model or load-library method).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  11. #71
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Quote Originally Posted by NogDog View Post
    #4: I'm used to the CI design where, from within the controller, you call a "load" method for models and libraries, and that method handles the inclusion of the necessary class, much the way an __autoload() does (based on whether you're using the load-model or load-library method).
    1) Does this happen just within the controller class or does it happen in children too?

    2) When you say load-model or load-library methods, you mean "method" as in a function inside a class, right? Not that load-model and load-library are two mutually exclusive class ways of designing a class, right?

    3) Lastly, can you conjure up an example of a class loading classes in the way you described? I think if I could see it, it would really help.

    And blah I just have so many question's don't I. That's how stuck I've gotten myself with OOP. Oh well the fog is slowly lifting.
    The better I get at programming, the more I appreciate arrays. Handy dandy things they are.

  12. #72
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    See Reply #68. In that code example, I'm talking about the lines such as:
    PHP Code:
    $validator $this->load_library('form_validation'); 
    Typically, the load_library() method would be one of the things defined in your Controller base class, such that it's available to all controllers derived from it. You might have a similar Controller::load_model() method, or as also appears in that example, a Controller::load_view() method.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  13. #73
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Something just occurred to me. My autoloader loads a controller. The controller would inherit controller::load_model, controller::load_view, and controller::load_library from its parent.

    So I would have four different types of loading going on, wouldn't I?
    The better I get at programming, the more I appreciate arrays. Handy dandy things they are.

  14. #74
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    Possibly.

    Nothing of this sort is set in stone, as far a I'm concerned -- it's just guidelines, suggestions, common practice, etc.; which doesn't mean it has to be one specific way.

    I've personally not had any reason/desire to write my own MVC framework, when there are already good ones out there. Don't get me wrong: it will likely be a great learning experience for you -- but anything I'm telling you is based either on theory or how I've seen it done in other frameworks, not from how I did it myself.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  15. #75
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Well, as noob as I am to OOP, seeing ANY method of assembling things together is a godsend. Otherwise, I'm left with whatever I can jerry-rig on my own. I'm sure this wouldn't be pretty. It might not even qualify as OOP.

    Haha, had I not started studying my butt off, I might have just ended up with a bunch of procedural code that just happened to be in classes. That kinda kills the point of it all, doesn't it?

    1) Okay, so, I'm a little confused on how to pass multiple arguments to a controller via the URL. Would you do it like this? mysite.com/controllername/methodname/arg1/arg2/arg3

    2) What if the arguments are, like, long strings? Like umm...what if somebody wants to post on the forum. They fill out a form that asks for a title and a message and press submit. How would I deliver that to the controller? It couldn't go through the URL, could it?

    2) Also are controllers the ONLY things you're going to interact with via url? Do you EVER directly interact with the library, view, or methods?
    The better I get at programming, the more I appreciate arrays. Handy dandy things they are.

Thread Information

Users Browsing this Thread

There are currently 5 users browsing this thread. (0 members and 5 guests)

Posting Permissions

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



Recent Articles