The unofficial coding best practise and code formatting conventions for XBMC
#31
I found a decent site that might be of use to XBMC's C++ code. I'll leave it here for you guys and if I find more I'll come back I suppose.

http://www.tantalon.com/pete/cppopt/main.htm
Reply
#32
Do we have any standards for PHP coding?
Reply
#33
PHP/HTML CGL:

Indention
1 tab

Naming
functions and variables should be as descriptive as possible (even if they become quite long) and be written in lowerCamelCase.

Quotes
Where possible, single qoutes should be used. Using double quotes and "hiding" variables within the string is considered bad practices.
So this is a no go: $foo = "We have $count results";
Use this instead: $foo = 'We have' . $count . 'results';

Concatenation
Concatenations should be done with a spaces before and after the ".".
NO: $foo = 'Blah'.$blubb;
YES: $foo = 'Blah' . $blubb;

Code formatting
Code:
/**
* Short description on what function does
*
* @param string $foo Short description of param if not obvious
* @param array $values Again a short description
* @return bool
*/
function dummyFunctionNameInLowerCamelCase($foo, array $values) {
        // some inlne comment
        if ($foo === 'bar') {
            return TRUE;
        } else {
            switch ($foo) {
                default:
                    // default should be defined at beginning
                    foreach ($values as $key => $value) {
                        if ($value == 'bar') {
                            return TRUE;
                        }
                    }
                    break;
                case 'bar':
                    // @todo do something
                    break;
            }
        }

        // booleans should be written in uppercase, so TRUE and FALSE
        return FALSE;
}
Reply
#34
This page comes up empty for me:

http://wiki.xbmc.org/index.php?title=Bas...ource_code

Could the OP be edited to point to the new page (I couldn't find one) or just delete the reference?
Reply
#35
(2013-11-19, 15:11)powlo Wrote: This page comes up empty for me:

http://wiki.xbmc.org/index.php?title=Bas...ource_code

Could the OP be edited to point to the new page (I couldn't find one) or just delete the reference?

You can find the referred page here: http://www.xbmc4xbox.org.uk/wiki/Basic_o...ource_code

However this is just an overview of the XBMC source code for the Xbox version. I just want to get started in developing for XBMC and I am searching for something similar for the Linux oder Windows version. Is there a quick overview of the key functions of XBMC and how it is represented in the source?

Greetings
Reply
#36
Maybe I am a little bit pedantic but personally I would also favor official python style requirements (PEP8) in the official add-on repository Blush
My GitHub. My Add-ons:
Image
Reply
#37
(2013-12-13, 20:30)sphere Wrote: Maybe I am a little bit pedantic but personally I would also favor official python style requirements (PEP8) in the official add-on repository Blush
No idea what this is but if it makes sense for python devs, go ahead.
Reply
#38
(2013-12-13, 20:59)da-anda Wrote:
(2013-12-13, 20:30)sphere Wrote: Maybe I am a little bit pedantic but personally I would also favor official python style requirements (PEP8) in the official add-on repository Blush
No idea what this is but if it makes sense for python devs, go ahead.

no way that will happen as a requirement.
that would scare of a lot of current or potential addons dev.
heck if i should follow it i would remove my addons and won't return.

it's ofcourse good to have it as a recommendation but it will never be manditory
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#39
are there any thoughts on allowing the use of auto for iterators? It would make it a bit more tidy writing loops
Reply

Logout Mark Read Team Forum Stats Members Help
The unofficial coding best practise and code formatting conventions for XBMC0