home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Mediaportal C# programming guidelines
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="koniosis" data-source="post: 9082" data-attributes="member: 11134"><p>Hey guys, new here, been checking out the project. Was looking at this section because I am planning on helping out, I've been working with Managed DirectX for 1.5 years and C# for 4, so hopefully I can add something useful. Anyway I thought I'd give you my 2c on some styles which I've found to be very useful when coding.</p><p></p><p>The first style is with regard to /// xml comments; if you look at Microsoft C# code (the Managed DirectX samples are a good example), they often "in-line" their summaries on variables and I've found this makes things a hell of a lot more readable, since you can view at least three times as many variables per page and your code isn't littered with /// lines. E.g</p><p></p><p>[code]</p><p>///<summary>This is the music playlist</summary></p><p>ArrayList MusicPlaylist = new PlayList();</p><p></p><p>///<summary>This is the movie playlist</summary></p><p>ArrayList MoviePlaylist = new PlayList();</p><p></p><p>// as opposed to:</p><p></p><p>///<summary></p><p>///This is the music playlist</p><p>///</summary></p><p>ArrayList MusicPlaylist = new PlayList();</p><p></p><p>...</p><p>[/code]</p><p></p><p>Although you're probably going to cringe at first (as I did) it just works so well for short comments, so much so that the Whidbey team have said in Orcas they're going to make it an option to have xml comments in this style. Also works well for methods, in fact it's generally much tidier when you're only using single-line summaries. I still suggest multi-line summaries get the full works.</p><p></p><p>Second thing to get the "inline" treatment is Properties. Again, it seems so wrong to mix inline and line broken code, but once again it just works so well. Example:</p><p></p><p>[code]</p><p>public class SomeClass</p><p>{</p><p> private int m_Playlist;</p><p></p><p> public int Playlist { get { return m_Playlist; } set { m_Playlist = value; } }</p><p>}</p><p>[/code]</p><p></p><p>Now obviously if you're going to have more than just a standard assignments inside your Properties it makes more sense for you to use multi-line; but for something so simple the inline approach is very readable and looks tidy. I haven't come across any other situations where inline code is better, just with Properties since they are so predictable (i.e. return x; x = value)</p><p></p><p>Of course, I'm just passing on some useful styles that I've encountered during my time coding C#; which I've also seen implimented by others (e.g. MDX team). I don't mean to come barging in with like "HEY DO IT MY WAY!!". But I do recommend you try converting a class with a lot of Properties and XML comments into these styles and see how you feel about it. Like I said, I was sceptical at first.</p><p></p><p>With best intentions,</p><p></p><p>Koni</p></blockquote><p></p>
[QUOTE="koniosis, post: 9082, member: 11134"] Hey guys, new here, been checking out the project. Was looking at this section because I am planning on helping out, I've been working with Managed DirectX for 1.5 years and C# for 4, so hopefully I can add something useful. Anyway I thought I'd give you my 2c on some styles which I've found to be very useful when coding. The first style is with regard to /// xml comments; if you look at Microsoft C# code (the Managed DirectX samples are a good example), they often "in-line" their summaries on variables and I've found this makes things a hell of a lot more readable, since you can view at least three times as many variables per page and your code isn't littered with /// lines. E.g [code] ///<summary>This is the music playlist</summary> ArrayList MusicPlaylist = new PlayList(); ///<summary>This is the movie playlist</summary> ArrayList MoviePlaylist = new PlayList(); // as opposed to: ///<summary> ///This is the music playlist ///</summary> ArrayList MusicPlaylist = new PlayList(); ... [/code] Although you're probably going to cringe at first (as I did) it just works so well for short comments, so much so that the Whidbey team have said in Orcas they're going to make it an option to have xml comments in this style. Also works well for methods, in fact it's generally much tidier when you're only using single-line summaries. I still suggest multi-line summaries get the full works. Second thing to get the "inline" treatment is Properties. Again, it seems so wrong to mix inline and line broken code, but once again it just works so well. Example: [code] public class SomeClass { private int m_Playlist; public int Playlist { get { return m_Playlist; } set { m_Playlist = value; } } } [/code] Now obviously if you're going to have more than just a standard assignments inside your Properties it makes more sense for you to use multi-line; but for something so simple the inline approach is very readable and looks tidy. I haven't come across any other situations where inline code is better, just with Properties since they are so predictable (i.e. return x; x = value) Of course, I'm just passing on some useful styles that I've encountered during my time coding C#; which I've also seen implimented by others (e.g. MDX team). I don't mean to come barging in with like "HEY DO IT MY WAY!!". But I do recommend you try converting a class with a lot of Properties and XML comments into these styles and see how you feel about it. Like I said, I was sceptical at first. With best intentions, Koni [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Mediaportal C# programming guidelines
Contact us
RSS
Top
Bottom