does anyone know a good technique to keep track of your braces in C#?
Hello all, Does anyone know any methods I could use when practicing programming in C# (I'm kind of just learning, so it can get annoying sometimes), to keep my braces straight? I will be writing something simple, and then before I know it, I'll have fifty errors show up all because of one brace not closed or two braces in the wrong place. Very annoying when fifty errors come up because of a single problem. And not only in keeping track of braces, I'm also confused as to what goes in between braces since C# gets layered sometimes in terms of code blocks. Books demonstrate examples well, however, they do not do a very good job telling you where braces go to begin with and why. Responses would be great on this. Thanks.
Re: does anyone know a good technique to keep track of your braces in C#?
Sounds like you have too much nesting. If you have more than a couple of levels maybe try separating it out into new methods. Hard to tell without seeing the code. On Thu, Feb 14, 2013 at 10:37 AM, Katherine Moss katherine.m...@gordon.eduwrote: Hello all, Does anyone know any methods I could use when practicing programming in C# (I'm kind of just learning, so it can get annoying sometimes), to keep my braces straight? I will be writing something simple, and then before I know it, I'll have fifty errors show up all because of one brace not closed or two braces in the wrong place. Very annoying when fifty errors come up because of a single problem. And not only in keeping track of braces, I'm also confused as to what goes in between braces since C# gets layered sometimes in terms of code blocks. Books demonstrate examples well, however, they do not do a very good job telling you where braces go to begin with and why. Responses would be great on this. Thanks.
Re: does anyone know a good technique to keep track of your braces in C#?
On Thu, Feb 14, 2013 at 10:37 AM, Katherine Moss katherine.m...@gordon.eduwrote: Hello all, Does anyone know any methods I could use when practicing programming in C# (I'm kind of just learning, so it can get annoying sometimes), to keep my braces straight? I will be writing something simple, and then before I know it, I'll have fifty errors show up all because of one brace not closed or two braces in the wrong place. Very annoying when fifty errors come up because of a single problem. And not only in keeping track of braces, I'm also confused as to what goes in between braces since C# gets layered sometimes in terms of code blocks. Books demonstrate examples well, however, they do not do a very good job telling you where braces go to begin with and why. Responses would be great on this. Thanks. If you're in a team, they are going to have a standard on this some do function( parm ) { code } others something like function ( parm ) { code } And variations. None are right or wrong, but you'd be advised not to make up your own in a workplace :) Visual Studio isn't too bad these days with doing auto-layout of braces, and there's utilities that you can apply to code to make it comply with the layout you want. -- Meski http://courteous.ly/aAOZcv Going to Starbucks for coffee is like going to prison for sex. Sure, you'll get it, but it's going to be rough - Adam Hills
Re: does anyone know a good technique to keep track of your braces in C#?
Jumping between braces in Visual Studio : CTRL + ] http://stackoverflow.com/questions/1501921/go-to-matching-brace-in-visual-studio Also you can use Ctrl + K + D ( C# keybining to get the VS to format it for you). Regards Arjang On 14 February 2013 07:37, Katherine Moss katherine.m...@gordon.edu wrote: Hello all, Does anyone know any methods I could use when practicing programming in C# (I'm kind of just learning, so it can get annoying sometimes), to keep my braces straight? I will be writing something simple, and then before I know it, I'll have fifty errors show up all because of one brace not closed or two braces in the wrong place. Very annoying when fifty errors come up because of a single problem. And not only in keeping track of braces, I'm also confused as to what goes in between braces since C# gets layered sometimes in terms of code blocks. Books demonstrate examples well, however, they do not do a very good job telling you where braces go to begin with and why. Responses would be great on this. Thanks.
RE: does anyone know a good technique to keep track of your braces in C#?
If looking for a programing language that is more suited to a text reader, then I'd suggest VB, where blocks are more self descriptive, eg: If ... Then ... Else .. End If. |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of Ben Scott |Sent: Thursday, 14 February 2013 10:59 AM |To: ozDotNet |Subject: Re: does anyone know a good technique to keep track of your braces in |C#? | |Katherine, from what I understand you are vision-impaired? I can understand that |braces would quickly become a problem for you. Maybe you could look into a |language like F# which uses tabs for nesting rather than braces. There would be a |learning curve but that may be worthwhile in the long term. Other alternatives |are Ruby and Coffeescript - Coffeescript may be a good start as you may be able |to leverage that in to developing Javascript-based Windows 8 apps. | |Other than that I would recommend just making sure each brace is on a new line |so that you can see the nesting. It is tempting to cram as much on each line but in |the long run spreading it out makes it much easier to maintain. Also use a brace |whenever you can, so no shortcuts like: | |if (something) Foo(); | |Instead always do: | |if (something) |{ |Foo(); |} | | | | |On Thu, Feb 14, 2013 at 9:42 AM, Craig van Nieuwkerk crai...@gmail.com |wrote: | | | Sounds like you have too much nesting. If you have more than a couple |of levels maybe try separating it out into new methods. Hard to tell without |seeing the code. | | | On Thu, Feb 14, 2013 at 10:37 AM, Katherine Moss |katherine.m...@gordon.edu wrote: | | | Hello all, | Does anyone know any methods I could use when practicing |programming in C# (I'm kind of just learning, so it can get annoying sometimes), |to keep my braces straight? I will be writing something simple, and then before I |know it, I'll have fifty errors show up all because of one brace not closed or two |braces in the wrong place. Very annoying when fifty errors come up because of a |single problem. And not only in keeping track of braces, I'm also confused as to |what goes in between braces since C# gets layered sometimes in terms of code |blocks. Books demonstrate examples well, however, they do not do a very good |job telling you where braces go to begin with and why. Responses would be |great on this. Thanks. | | | |
Re: does anyone know a good technique to keep track of your braces in C#?
I'd also add that braces, parentheses, or anything that comes in pairs, should be inserted at the same time. ie, immediately type your opening and closing braces and then move your insertion point in between them. If you're putting existing code in new braces, you still try to do this as a single operation. either be careful to put them in the correct place at that time, checking to make sure they are, or have them inserted for you. eg, select the code, CTRL + K + X, select Visual C#, then select what you want, such as if. I do all of this and the only time I've ever had mismatched braces is by accidentally deleting one. David If we can hit that bullseye, the rest of the dominoes will fall like a house of cards... checkmate! -Zapp Brannigan, Futurama
Re: IIS has no folders
You sure you are not running iis express in vs? On 14 Feb 2013 12:01, Grant Maw grant@gmail.com wrote: All Has anyone seen this behaviour before? We have no Application Pools folder or Sites folder in this IIS8 instance of IIS. We know IIS is running because we can run websites that are auto-created by Visual Studio when loading up a project. Removed/reinstalled all the components etc, to no avail. I am posting here so that in 30 seconds I will work it out myself, but failing that, any thoughts on what's going on would be appreciated :) Thanks Grant
RE: does anyone know a good technique to keep track of your braces in C#?
Please correct me if I am wrong on this. You're telling me that braces are free for the programmer to place them where they want in C#? I know that in most of the demos I have from books, there are always braces in particular places every time with no fail. Is this a C# convention, or is this a standard that Wily is using? For instance: Namespace Demo { Static void main(string [] args) } { Console.WriteLine(this is a demo); Console.ReadKey(); } } } Or something like that. I'm not sure since I don't have the file open in front of me, but are you saying that is just a chosen way of writing it and that people are relatively free with braces? And about other languages. I chose C# because it offers the power of C++ without the complexity. And I plan to learn F# as well one of these days, though isn't that more of a math language for calculation programs and such like that? But thanks to Roslyn, I can learn easier with C# interactive. And I don't use VB for moral reasons. No offense to those on this list who love it, but isn't it kind of the malware author's language? From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of David Richards Sent: Wednesday, February 13, 2013 7:50 PM To: ozDotNet Subject: Re: does anyone know a good technique to keep track of your braces in C#? I'd also add that braces, parentheses, or anything that comes in pairs, should be inserted at the same time. ie, immediately type your opening and closing braces and then move your insertion point in between them. If you're putting existing code in new braces, you still try to do this as a single operation. either be careful to put them in the correct place at that time, checking to make sure they are, or have them inserted for you. eg, select the code, CTRL + K + X, select Visual C#, then select what you want, such as if. I do all of this and the only time I've ever had mismatched braces is by accidentally deleting one. David If we can hit that bullseye, the rest of the dominoes will fall like a house of cards... checkmate! -Zapp Brannigan, Futurama
Re: IIS has no folders
It looks to me like IIS isn't installed. Check under control panel, programs, add windows features/components. Visual studio may be using IIS express or Cassini On Feb 14, 2013 10:01 AM, Grant Maw grant@gmail.com wrote: All Has anyone seen this behaviour before? We have no Application Pools folder or Sites folder in this IIS8 instance of IIS. We know IIS is running because we can run websites that are auto-created by Visual Studio when loading up a project. Removed/reinstalled all the components etc, to no avail. I am posting here so that in 30 seconds I will work it out myself, but failing that, any thoughts on what's going on would be appreciated :) Thanks Grant
RE: does anyone know a good technique to keep track of your braces in C#?
Do you mean to say that whoever said that (I think it was Ian Griffiths, is right? From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Heinrich Breedt Sent: Wednesday, February 13, 2013 9:38 PM To: ozDotNet Subject: Re: does anyone know a good technique to keep track of your braces in C#? On Thu, Feb 14, 2013 at 12:33 PM, Katherine Moss katherine.m...@gordon.edumailto:katherine.m...@gordon.edu wrote: And I plan to learn F# as well one of these days, though isn't that more of a math language for calculation programs and such like that? HAHA!! got to remember that next time I talk to the erlang and haskell guys lol -- Heinrich Breedt Do not wait to strike till the iron is hot; but make it hot by striking. - William B. Sprague
RE: does anyone know a good technique to keep track of your braces in C#?
Hi Katherine, C# does not have the power of C++. C# is a managed language: it has basically the same power as VB (.NET). What C# shares with C++ is it is a C style language: that is a lot of the styling and grammar are similar. And C in the old days was renowned for obfuscated code competitions. The issue of style in C languages, has caused many wasted hours: so much so there's even tools such as style cop that are designed to help address the development process/maintenance. So yes there is a lot of freedom with the braces; hence there are third party tools designed to reign in those freedoms. As to VB equating to malware: well I guess you don't know the history of app development. VB does have a rich history; today I still see programs written in VB6, including major commercial software in Australia (eg MYOB Retail Manager), lots of internal business applications etc. Macro language for Microsoft Office and Visual Studio has been VB (for Applications), and even Reporting services function have to be written in VB .NET : no C# (at least last time I looked). The only malware aspect might be the days of old when macros and client side scripts (.vbs) had to be in VBA or VBScript. Actually, come to think of it, Microsoft's AntiMalware product (defender?) actually came for ma third party company they bought, and it was originally all written in VB: It was re-written in C++, not C# Anyway, if you choose a C style language, then you choose those freedoms, and issues that come with it. Some people even go as far as to try to comment the braces so as what it is closing. At the end of the day if you need that, you really have to ask why choose that style of language ;) |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of Katherine Moss |Sent: Thursday, 14 February 2013 1:34 PM |To: ozDotNet |Subject: RE: does anyone know a good technique to keep track of your braces in |C#? | |Please correct me if I am wrong on this. You're telling me that braces are free for |the programmer to place them where they want in C#? I know that in most of |the demos I have from books, there are always braces in particular places every |time with no fail. Is this a C# convention, or is this a standard that Wily is using? |For instance: | |Namespace Demo | |{ | |Static void main(string [] args) | |} | |{ | |Console.WriteLine(this is a demo); | |Console.ReadKey(); | |} | |} | |} | |Or something like that. I'm not sure since I don't have the file open in front of |me, but are you saying that is just a chosen way of writing it and that people are |relatively free with braces? And about other languages. I chose C# because it |offers the power of C++ without the complexity. And I plan to learn F# as well |one of these days, though isn't that more of a math language for calculation |programs and such like that? But thanks to Roslyn, I can learn easier with C# |interactive. And I don't use VB for moral reasons. No offense to those on this list |who love it, but isn't it kind of the malware author's language? | |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of David Richards |Sent: Wednesday, February 13, 2013 7:50 PM |To: ozDotNet |Subject: Re: does anyone know a good technique to keep track of your braces in |C#? | | | |I'd also add that braces, parentheses, or anything that comes in pairs, should be |inserted at the same time. ie, immediately type your opening and closing braces |and then move your insertion point in between them. If you're putting existing |code in new braces, you still try to do this as a single operation. either be careful |to put them in the correct place at that time, checking to make sure they are, or |have them inserted for you. eg, select the code, CTRL + K + X, select Visual C#, |then select what you want, such as if. | | | |I do all of this and the only time I've ever had mismatched braces is by |accidentally deleting one. | | | | |David | |If we can hit that bullseye, the rest of the dominoes will fall like a house of |cards... checkmate! | -Zapp Brannigan, Futurama | | | |
RE: does anyone know a good technique to keep track of your braces in C#?
I selected C# over VB because in my opinion, C# is a lot more readable than VB is, and every application in .net that I am in any way associated with uses C#, I think. So it would be impractical for me to learn a language for a project if a project uses another language, right? From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Ian Thomas Sent: Wednesday, February 13, 2013 10:11 PM To: 'ozDotNet' Subject: RE: does anyone know a good technique to keep track of your braces in C#? My suggestion would extend on Bill's: write some example code in VB.NET, to get familiar with .NET assemblies etc - then use one of the code translators to see the equivalent in C#. That will give you a start in first laying out the obvious code structure (VB is much more explanatory / verbose in that regard), and comparing what C# requires for code structures (beyond the braces) is educational as well. Once your code becomes more complex, you won't want to use the write-in-VB-and-translate approach: mainly because you will either recognize the inherent superiority of VB.NET over C# :) and/or the free / demo VB to C# translators can't handle some more complex code. Ian Thomas Victoria Park, Western Australia -Original Message- From: ozdotnet-boun...@ozdotnet.commailto:ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Bill McCarthy Sent: Thursday, February 14, 2013 8:45 AM To: 'ozDotNet' Subject: RE: does anyone know a good technique to keep track of your braces in C#? If looking for a programing language that is more suited to a text reader, then I'd suggest VB, where blocks are more self descriptive, eg: If ... Then ... Else .. End If.
Re: does anyone know a good technique to keep track of your braces in C#?
I mean to say that while that is an obvious strength of F# (and other functional langauges) there is much more to them than that. http://tomasp.net/blog/fsharp-mvc-web.aspx On Thu, Feb 14, 2013 at 1:07 PM, Katherine Moss katherine.m...@gordon.eduwrote: Do you mean to say that whoever said that (I think it was Ian Griffiths, is right? ** ** *From:* ozdotnet-boun...@ozdotnet.com [mailto: ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Heinrich Breedt *Sent:* Wednesday, February 13, 2013 9:38 PM *To:* ozDotNet *Subject:* Re: does anyone know a good technique to keep track of your braces in C#? ** ** ** ** On Thu, Feb 14, 2013 at 12:33 PM, Katherine Moss katherine.m...@gordon.edu wrote: And I plan to learn F# as well one of these days, though isn’t that more of a math language for calculation programs and such like that? HAHA!! got to remember that next time I talk to the erlang and haskell guys lol ** ** -- Heinrich Breedt “Do not wait to strike till the iron is hot; but make it hot by striking.” - William B. Sprague -- Heinrich Breedt “Do not wait to strike till the iron is hot; but make it hot by striking.” - William B. Sprague
RE: IIS has no folders
I can't really offer much on this one, since I've never seen it before, but I'll have to agree with the consensus that IIS isn't installed. Or it is partially installed is more like it. From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Grant Maw Sent: Wednesday, February 13, 2013 10:57 PM To: ozDotNet Subject: Re: IIS has no folders Thanks for the responses - we thought the same, and double checked all that. Will look at it again. Will post here if we work it out. Cheers On 14 February 2013 12:40, Stephen Price step...@perthprojects.commailto:step...@perthprojects.com wrote: It looks to me like IIS isn't installed. Check under control panel, programs, add windows features/components. Visual studio may be using IIS express or Cassini On Feb 14, 2013 10:01 AM, Grant Maw grant@gmail.commailto:grant@gmail.com wrote: All Has anyone seen this behaviour before? We have no Application Pools folder or Sites folder in this IIS8 instance of IIS. We know IIS is running because we can run websites that are auto-created by Visual Studio when loading up a project. Removed/reinstalled all the components etc, to no avail. I am posting here so that in 30 seconds I will work it out myself, but failing that, any thoughts on what's going on would be appreciated :) Thanks Grant
RE: does anyone know a good technique to keep track of your braces in C#?
Okay, that's a different reason than what was previously given ;) If you are having trouble with brace matching, hard to see how that is more readable. But more to the point, you've really answered your own original question: if the projects you are involved in don't let you choose the language, it is unlikely they'd let you dictate the style. So what you should aim for is consistency, and in the projects you are working with, consistency with the style(s) used in the existing code. |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of Katherine Moss |Sent: Thursday, 14 February 2013 2:30 PM |To: ozDotNet |Subject: RE: does anyone know a good technique to keep track of your braces in |C#? | |I selected C# over VB because in my opinion, C# is a lot more readable than VB is, |and every application in .net that I am in any way associated with uses C#, I think. |So it would be impractical for me to learn a language for a project if a project |uses another language, right? | | | |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of Ian Thomas |Sent: Wednesday, February 13, 2013 10:11 PM |To: 'ozDotNet' |Subject: RE: does anyone know a good technique to keep track of your braces in |C#? | | | |My suggestion would extend on Bill's: write some example code in VB.NET, to get |familiar with .NET assemblies etc - then use one of the code translators to see |the equivalent in C#. That will give you a start in first laying out the obvious code |structure (VB is much more explanatory / verbose in that regard), and comparing |what C# requires for code structures (beyond the braces) is educational as well. | |Once your code becomes more complex, you won't want to use the write-in-VB- |and-translate approach: mainly because you will either recognize the inherent |superiority of VB.NET over C# J and/or the free / demo VB to C# translators can't |handle some more complex code. | | | |Ian Thomas | |Victoria Park, Western Australia | |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of Bill McCarthy |Sent: Thursday, February 14, 2013 8:45 AM |To: 'ozDotNet' |Subject: RE: does anyone know a good technique to keep track of your braces in |C#? | |If looking for a programing language that is more suited to a text reader, | |then I'd suggest VB, where blocks are more self descriptive, eg: If ... | |Then ... Else .. End If.
RE: does anyone know a good technique to keep track of your braces in C#?
Text Editor Options for indenting, new line rules etc. Brace completion is Productivity Power Tools options. |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of Katherine Moss |Sent: Thursday, 14 February 2013 3:20 PM |To: ozDotNet |Subject: RE: does anyone know a good technique to keep track of your braces in |C#? | |Oh okay. That makes sense. And just so I know. Tell me again how to allow |Visual Studio 2012 to auto-insert the closing braces and other things in pairs. It's |with the Power Tools Extension, right? I was looking at that, though I couldn't |seem to find that particular set of options, for that would certainly make my life |easier. | | | |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of David Richards |Sent: Wednesday, February 13, 2013 10:42 PM |To: ozDotNet |Subject: Re: does anyone know a good technique to keep track of your braces in |C#? | | | |They don't quite go anywhere you want. They can go in far more places than are |actually necessary but let not worry about that for now. You have a set for the |namespace. You have a set for each method or property in that namespace. You |have a set for any compound statements. You have a set for any array |initialisation. I've probably forgotten some cases at the moment but that's |probably 99% of cases there. You can also, for example, put them in case |statements within a switch (oh yeah, switch statements have them as well) but |the break statement makes them superfluous. Although it would probably make |them more consistent. | | | |Hmm, it's entirely possible I'm not understanding what you're saying. | | | | |David | |If we can hit that bullseye, the rest of the dominoes will fall like a house of |cards... checkmate! | -Zapp Brannigan, Futurama | | | |On 14 February 2013 13:33, Katherine Moss katherine.m...@gordon.edu |wrote: | |Please correct me if I am wrong on this. You're telling me that braces are free for |the programmer to place them where they want in C#? I know that in most of |the demos I have from books, there are always braces in particular places every |time with no fail. Is this a C# convention, or is this a standard that Wily is using? |For instance: | |Namespace Demo | |{ | |Static void main(string [] args) | |} | |{ | |Console.WriteLine(this is a demo); | |Console.ReadKey(); | |} | |} | |} | |Or something like that. I'm not sure since I don't have the file open in front of |me, but are you saying that is just a chosen way of writing it and that people are |relatively free with braces? And about other languages. I chose C# because it |offers the power of C++ without the complexity. And I plan to learn F# as well |one of these days, though isn't that more of a math language for calculation |programs and such like that? But thanks to Roslyn, I can learn easier with C# |interactive. And I don't use VB for moral reasons. No offense to those on this list |who love it, but isn't it kind of the malware author's language? | |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of David Richards |Sent: Wednesday, February 13, 2013 7:50 PM | |
Re: does anyone know a good technique to keep track of your braces in C#?
Someone else would have to answer that. We're still using VS 2008 where I'm working. In fact, we still have projects stuck in 2005 and 2003. I've had that behaviour in Eclipse and it takes some getting used to. Especially if you normally add the end brace yourself. David If we can hit that bullseye, the rest of the dominoes will fall like a house of cards... checkmate! -Zapp Brannigan, Futurama On 14 February 2013 15:19, Katherine Moss katherine.m...@gordon.edu wrote: Oh okay. That makes sense. And just so I know. Tell me again how to allow Visual Studio 2012 to auto-insert the closing braces and other things in pairs. It’s with the Power Tools Extension, right? I was looking at that, though I couldn’t seem to find that particular set of options, for that would certainly make my life easier. ** **