Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Best Way to Code

    Hi guys,

    Im building a site from scratch and Im doing it with only me and my friend so far. When i started I was told to learn HTML and CSS first, which i did and then moved onto PHP, some javascript, and then messed around with joomla to understand how CMS worked.
    I have a pretty good idea of how coding works as i did COBOL and PASCAL in college, and some C++ on my own.
    The thing is that when I looked in some of the Joomla php files I can see that it is coded completly different to what ive seen on tutorials on the web. Id like to know if there is a definete best way to code, and where i could find out the best way to build a site from scratch without creating the site then having to scrap all the code ive worked on in the future to replace it with better coding conventions. As it would save alot of time, I like jumping in the deep end. :-)

    Cheers. Jim.

    PS. If you look inside the joomla index.php file youll know what i mean...

    PHP Code:
    <?php

    // Set flag that this is a parent file.
    define('_JEXEC'1);
    define('DS'DIRECTORY_SEPARATOR);

    if (
    file_exists(dirname(__FILE__) . '/defines.php')) {
        include_once 
    dirname(__FILE__) . '/defines.php';
    }

    if (!
    defined('_JDEFINES')) {
        
    define('JPATH_BASE'dirname(__FILE__));
        require_once 
    JPATH_BASE.'/includes/defines.php';
    }

    require_once 
    JPATH_BASE.'/includes/framework.php';

    // Mark afterLoad in the profiler.
    JDEBUG $_PROFILER->mark('afterLoad') : null;

    // Instantiate the application.
    $app JFactory::getApplication('site');

    // Initialise the application.
    $app->initialise();

    // Mark afterIntialise in the profiler.
    JDEBUG $_PROFILER->mark('afterInitialise') : null;

    // Route the application.
    $app->route();

    // Mark afterRoute in the profiler.
    JDEBUG $_PROFILER->mark('afterRoute') : null;

    // Dispatch the application.
    $app->dispatch();

    // Mark afterDispatch in the profiler.
    JDEBUG $_PROFILER->mark('afterDispatch') : null;

    // Render the application.
    $app->render();

    // Mark afterRender in the profiler.
    JDEBUG $_PROFILER->mark('afterRender') : null;

    // Return the response.
    echo $app;

  • #2
    Regular Coder
    Join Date
    Aug 2011
    Posts
    120
    Thanks
    1
    Thanked 15 Times in 15 Posts
    Well, no I don't know what you mean.

    It's just like any application that you look at in that it is divided into multiple levels of abstraction. True, that you cannot tell what is going on just by looking at one file of php any more than you can tell how a C++ program works by reading main(). Programing simply is not that transparent.

    The real work of that file you posted is in 'framework.php' and its included files. If you understand the programming language at all, then you just keep going deeper in the includes until you get to some code that you understand. Then you've hit the lowest level of abstraction of the application in question. Everything else should simply call those functions in some sequence that will only make sense when you know what each one of them do.

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i don't understand what you are saying because i m well known of this code but in your way of describe i never understand.




    fort st john

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,641
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Cobol and Pascal are procedural programming languages.

    PHP is an object oriented language.

    There are huge differences between these two types of languages.

    Being familiar with a dozen or more procedural languages it still took me a couple of years to work out how object oriented really works.

    Presumably if you don't understand this difference the C++ you wrote was actually C rather than C++ as C is a procedural language and C++ adds the extra constructs needed to make it object oriented.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    seminaljim (04-07-2012)

  • #5
    New Coder
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks akonlaura, i think i need to work on the object-orientated stuff. Do you know where is a good source of information on the OOP side of things.

    And Jackson, I know that there is multiple levels of abstraction! I understand how includes work.

    I was hoping that someone could point my in the direction of a source to learn the best tips and techniques of creating a site from scratch in the same way.


  •  

    Posting Permissions

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