The unofficial coding best practise and code formatting conventions for XBMC
Gamester17
Team-XBMC Forum Moderator Joined: Sep 2003 Reputation: 9 Location: Sweden |
fyi, mplayer (which xbmc a/v player is based on) has a strict policy against code beautification!, and i have to agree with that when it comes to our mplayer-core in xbmc and for all other code that's been ported from other sources (eg. not written from scartch). if for exampel our mplayer-core code was 'beautified' then it would be harder to update it from the latest mplayer cvs as the code would not be layed-out the same, same goes all other libs and code we use in xbmc that we update quite often (like libcdio, filezilla, ffmpeg, xvid, etc...). only code that can be beautified without consequenses are the xbmc code that has been written from scratch by our own developers, (like the xbmc-gui).
Always read the XBMC online-manual, FAQ and search the forum before posting. Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. For troubleshooting and bug reporting please make sure you read this first. |
| find quote |
stcogoli
Member Posts: 93 Joined: Jul 2004 Reputation: 0 |
2004-11-11 20:33
Post: #22
hi, i just have a quick question, maybe slightly off-topic but i didn't know where else to ask. i read on the c++ faq lite (http://www.parashift.com/c++-faq-lite/fr...l#faq-16.7) that the value returned by the "new" operator should not be checked for zero as it throws on exceptions. this seems to be the way new is called most of the time in xbmc code but then i stumbled upon this msdn bit (http://msdn.microsoft.com/library/defaul...ess_25.asp) which states the opposite.
Quote:if unsuccessful, by default new returns zero.so which is true, should i check my news or not? |
| find quote |
Gamester17
Team-XBMC Forum Moderator Joined: Sep 2003 Reputation: 9 Location: Sweden |
tought i :bump: this, 'even' mediaportal now have guide-lines, maybe we can use that as a base (though obviously remove the c# stuff)
....what do you all think? is anyone (developer) willing to put together a draft of a basic guideline for adding new code and changing old one? Always read the XBMC online-manual, FAQ and search the forum before posting. Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. For troubleshooting and bug reporting please make sure you read this first. |
| find quote |
Gamester17
Team-XBMC Forum Moderator Joined: Sep 2003 Reputation: 9 Location: Sweden |
i like to bump this discussion once again with a link to a essay titled "comments are more important than code" (which been 'slashdotted')
Always read the XBMC online-manual, FAQ and search the forum before posting. Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. For troubleshooting and bug reporting please make sure you read this first. |
| find quote |
deadken
Junior Member Posts: 13 Joined: Dec 2004 Reputation: 0 |
Also, maybe a brief statements on line endings would be useful?
(This post was last modified: 2007-11-23 17:04 by Gamester17.)
|
| find quote |
dteirney
Team-XBMC Developer Posts: 820 Joined: Jul 2007 Reputation: 6 Location: New Zealand |
2009-06-01 11:33
Post: #26
Sorry to drege up an old topic, but this thread is still useful for those of us just starting out in the code. I've run into a variety of switch statement formats. One of which seems better than the current documented standard (although with the Quote thingy in the wiki the spaces might have just gone away).
Code: switch (cmd) |
| find quote |
jmarshall
Team-XBMC Developer Posts: 24,523 Joined: Oct 2003 Reputation: 138 |
2009-06-01 11:42
Post: #27
Thanks - yeah, the formatting just went haywire.
Cheers, Jonathan Always read the XBMC online-manual, FAQ and search the forum before posting. Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. For troubleshooting and bug reporting please make sure you read this first. ![]() |
| find quote |
gsnerf
Junior Member Posts: 4 Joined: Nov 2009 Reputation: 0 |
2009-11-24 15:07
Post: #28
Hi there,
as no one here really responded to the doxygen proposals of Gamester17 and I saw in the wiki a guideline saying one _should_ use doxygen to comment the code: what doc-style for doxygen should one use? Doxygen allows for multiple comment types (see http://www.stack.nl/~dimitri/doxygen/docblocks.html) and I didn't really found any reference of doxygen doc in the code as of yet. |
| find quote |
spiff
Grumpy Bastard Developer Joined: Nov 2003 Reputation: 82 |
2009-11-24 15:16
Post: #29
![]() jmarshall has started doing some doxy, see e.g. utils/JobManager.h Always read the XBMC online-manual, FAQ and search the forum before posting. Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. For troubleshooting and bug reporting please make sure you read this first. |
| find quote |
Montellese
Team-XBMC Developer Joined: Jan 2009 Reputation: 20 Location: Switzerland |
Hey everyone
I'm currently working on making XBMCs JSON RPC api compliant with the JSON RPC 2.0 specification (see Trac Ticket #10095 in combination with Track Ticket #10763). During development I came across the following two questions: 1. How should the code (mainly methods and members) be documented? I saw some files using doxygen style with \brief, \param and \return. Is this the prefered way to do it? And do you use some kind of groups with \ingroup or something like that? 2. I'm working on using a Service Mapping Description (SMD) to describe all the methods in XBMCs JSON RPC api but that requires quite some text. Until now I copied the text into the code (simply to be able to test if it works at all) but the SMD gets bigger and bigger and has reached a size of a few ten kBs (uncompressed). So I have to get away from the "copy into the code" hack and need a way to read the SMD from a file. How are additional files handled by XBMC? It's not like some configuration file which can be changed by the user manually. If someone would change something in the SMD it would probably cause json rpc methods to fail. Where would such a file be stored and under which path could I access it in the code? Or is there a different approach for such files? Thanks for your help. Always read the XBMC online-manual, FAQ and search the forum before posting. Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. For troubleshooting and bug reporting please make sure you read this first. ![]() |
| find quote |

![[Image: badge.gif]](http://www.ohloh.net/projects/9132/badge.gif)


Search
Help