By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,609 Members | 3,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,609 IT Pros & Developers. It's quick & easy.

Improving my code

P: n/a
Jo
Hi there:

I m wondering what can I do to improve my code, everytime I am coding
I feel like it could be done better. I started on c# a good months ago
and feel conformtable but sometimes I Need to look up stuff.
maybe someone can suggest a good book on good practices for c#?
Cheers
Jo

Jun 22 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"Jo" <jo*******@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
I m wondering what can I do to improve my code, everytime I am coding
I feel like it could be done better. I started on c# a good months ago
and feel conformtable but sometimes I Need to look up stuff.
maybe someone can suggest a good book on good practices for c#?
One way to improve your code is peer review. From time to time, spend a
few minutes with a colleague and have him look at a sample of your code,
pointing out things that he would do differently, and explaining why. Do
offer to pay back the favour and take a look at his code. While you are at
it, ask questions about why he did things the way that they are done
whenever you see something that you would have done in a different way.
Jun 22 '07 #2

P: n/a
Jo
On Jun 22, 9:23 am, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
"Jo" <jodiep...@gmail.comwrote in message

news:11**********************@k79g2000hse.googlegr oups.com...
I m wondering what can I do to improve my code, everytime I am coding
I feel like it could be done better. I started on c# a good months ago
and feel conformtable but sometimes I Need to look up stuff.
maybe someone can suggest a good book on good practices for c#?

One way to improve your code is peer review. From time to time, spend a
few minutes with a colleague and have him look at a sample of your code,
pointing out things that he would do differently, and explaining why. Do
offer to pay back the favour and take a look at his code. While you are at
it, ask questions about why he did things the way that they are done
whenever you see something that you would have done in a different way.
hola alberto:

That would be great, problem is.. I m on my own here thats why i was
thinking book

Jun 22 '07 #3

P: n/a
Code complete, second edition
http://www.amazon.com/gp/product/073...SIN=0735619670

This is a book recommended by many.
It is not C# specific.
Did not read it myself (yet :)).

Regards, Petar Repac

Jo wrote:
On Jun 22, 9:23 am, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
>"Jo" <jodiep...@gmail.comwrote in message

news:11**********************@k79g2000hse.googleg roups.com...
>>I m wondering what can I do to improve my code, everytime I am coding
I feel like it could be done better. I started on c# a good months ago
and feel conformtable but sometimes I Need to look up stuff.
maybe someone can suggest a good book on good practices for c#?
One way to improve your code is peer review. From time to time, spend a
few minutes with a colleague and have him look at a sample of your code,
pointing out things that he would do differently, and explaining why. Do
offer to pay back the favour and take a look at his code. While you are at
it, ask questions about why he did things the way that they are done
whenever you see something that you would have done in a different way.

hola alberto:

That would be great, problem is.. I m on my own here thats why i was
thinking book
Jun 22 '07 #4

P: n/a
On 22 Jun, 09:03, Jo <jodiep...@gmail.comwrote:
Hi there:

I m wondering what can I do to improve my code, everytime I am coding
I feel like it could be done better. I started on c# a good months ago
and feel conformtable but sometimes I Need to look up stuff.
maybe someone can suggest a good book on good practices for c#?
Cheers

Jo
Check out FxCop (http://www.gotdotnet.com/Team/FxCop/)

Making sure your code passes all tests is a quick way to make sure you
are following conventions & best practices and can help identify
possible problems.

Blurb from the site:
FxCop is a code analysis tool that checks .NET managed code assemblies
for conformance to the Microsoft .NET Framework Design Guidelines. It
uses reflection, MSIL parsing, and callgraph analysis to inspect
assemblies for more than 200 defects in the following areas:

Library design
Localization
Naming conventions
Performance
Security
FxCop includes both GUI and command line versions of the tool.

Jun 22 '07 #5

P: n/a
Jo
On Jun 22, 10:50 am, Matt Lacey <m.la...@fdsltd.co.ukwrote:
On 22 Jun, 09:03, Jo <jodiep...@gmail.comwrote:
Hi there:
I m wondering what can I do to improve my code, everytime I am coding
I feel like it could be done better. I started on c# a good months ago
and feel conformtable but sometimes I Need to look up stuff.
maybe someone can suggest a good book on good practices for c#?
Cheers
Jo

Check out FxCop (http://www.gotdotnet.com/Team/FxCop/)

Making sure your code passes all tests is a quick way to make sure you
are following conventions & best practices and can help identify
possible problems.

Blurb from the site:
FxCop is a code analysis tool that checks .NET managed code assemblies
for conformance to the Microsoft .NET Framework Design Guidelines. It
uses reflection, MSIL parsing, and callgraph analysis to inspect
assemblies for more than 200 defects in the following areas:

Library design
Localization
Naming conventions
Performance
Security
FxCop includes both GUI and command line versions of the tool.
great thanks for those tips

Jun 22 '07 #6

P: n/a
On Fri, 22 Jun 2007 08:03:34 -0000, Jo wrote:
I started on c# a good months ago and feel conformtable but sometimes I
Need to look up stuff. maybe someone can suggest a good book on good
practices for c#?
CLR via C#, Second Edition
http://wintellect.com/BookInformatio...SIN=0735621632
after reading You can reasonably and consciously use FxCop to apply even
custom rules but I suggest first understanding how CLR really works.

Regards
Jun 22 '07 #7

P: n/a
Making sure your code passes all of FxCop's tests is an exercise in
futility, in my opinion. It's not always necessary or desirable to
internationalize your code, for example. FxCop is simply a tool.

In answer to the original question, the best way to improve your code at
your stage is to write code. You will gradually identify standards of your
own (such as "duplication is bad"). After you've been programming for a
while, you will indeed benefit from others' advice.

///ark
Jun 22 '07 #8

P: n/a
"Jo" <jo*******@gmail.comwrote:
I m wondering what can I do to improve my code [...]
I agree with just about all of the responses so far:

1 - Peer Review is probably the single best way to improve.

I've gotten more out of this than anything else. Having people I work with
kick code back at me saying "Fix this" (and being right about it!) has been
very beneficial. Likewise, when I review someone else's code, I often learn
something new and end up being better for it.

2 - Code Complete is a great book.

I have read it, and quite liked it. In fact almost all of this books are
great. Rapid Developent is a good PM book, and his current book on
Estimation is excellent.

3 - FxCop is a great tool

I have a love/hate relationship with FxCop. I do recommend it to people, but
some of it's rules are a little over-the-top.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins
Jun 22 '07 #9

P: n/a
Hi Jo,

Like you, I have no technical peers at my workplace. I can suggest some
things that have worked well for me:

1) Read a lot of books, even if you don't understand everything in them or
even 25% of what's in them. Read the best books every few months and you'll
pick up more each time. Standouts:
_Code Complete_ as others have mentioned may be the best book on development
that's ever been wriiten.
_Design Patterns Explained_, Shalloway and Trott. The totality of DPs may be
a bit beyond your skills (and mine) right now, but you will learn a lot
about good design from this book.
_Beginning C# Objects: From Concept to Code_. A standout book on OO and
maybe the best first book for beginners.
_C# Class Design Handbook_. Concise. Excellent sections on abstract methods
and use of interfaces. Still getting a handle on all this myself.
MSDN magazine

2) The best advice I've ever gotten is to try to pick up a new language
every year. Learning Actionscript made it easier for me to pick up C# --
they're syntactic cousins. It also gave me a rich appreciation for all of
the ways that C# is a better language than Actionscript.

3) Go to Tech Ed 2008 even if you have to sell the cat to do it. Some of the
code you'll see is very good, and it's opportunity for humility as you'll
meet thousands of people with outsized skills.

4) If you're regularly working with data access of any sort, use an ORM
framework like EntitySpaces, or learn LINQ when it comes out. Life is too
short to be screwing around with data access code.

5) Learn everything you can about the VS.NET debugger. It will teach you a
lot.

It is too bad there isn't an online newsgroup or website where you could get
code reviews from other folks. I'm sure there are folks out there willing to
give and take.

-KF
"Jo" <jo*******@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Hi there:

I m wondering what can I do to improve my code, everytime I am coding
I feel like it could be done better. I started on c# a good months ago
and feel conformtable but sometimes I Need to look up stuff.
maybe someone can suggest a good book on good practices for c#?
Cheers
Jo

Jun 23 '07 #10

P: n/a
On Fri, 22 Jun 2007 08:43:03 -0000, Jo <jo*******@gmail.comwrote:
>On Jun 22, 9:23 am, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
>"Jo" <jodiep...@gmail.comwrote in message

news:11**********************@k79g2000hse.googleg roups.com...
I m wondering what can I do to improve my code, everytime I am coding
I feel like it could be done better. I started on c# a good months ago
and feel conformtable but sometimes I Need to look up stuff.
maybe someone can suggest a good book on good practices for c#?

One way to improve your code is peer review. From time to time, spend a
few minutes with a colleague and have him look at a sample of your code,
pointing out things that he would do differently, and explaining why. Do
offer to pay back the favour and take a look at his code. While you are at
it, ask questions about why he did things the way that they are done
whenever you see something that you would have done in a different way.

hola alberto:

That would be great, problem is.. I m on my own here thats why i was
thinking book
I have the same the problem as you. I work alone. Surely you have
friends and acquaintances who also code in C#? If so, then why not do a
swap? You do a code review for them and get them to do a code review for
you in return.

Have a look at some of these books:

"Framework Design Guidelines: Conventions, Idioms, and Patterns for
Reusable .NET Libraries", by Krzysztof Cwalina and Brad Abrams.
<http://www.amazon.com/Framework-Design-Guidelines-Conventions-Development/dp/0321246756/ref=sr_11_1/104-8843439-7455909?ie=UTF8&qid=1182671037&sr=11-1>

ASP.NET 2.0 Website Programming: Problem - Design - Solution, by Marco
Bellinaso
<http://www.amazon.com/ASP-NET-2-0-Website-Programming-Programmer/dp/0764584642/ref=sr_11_1/104-8843439-7455909?ie=UTF8&qid=1182671290&sr=11-1>

Design Patterns, by Christopher G. Lasater
<http://www.amazon.com/Design-Patterns-Wordware-Applications-Library/dp/1598220314/ref=sr_11_1/104-8843439-7455909?ie=UTF8&qid=1182671139&sr=11-1>

"Refactoring: Improving the Design of Existing Code", by Martin Fowler
<http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672/ref=pd_bbs_sr_2/104-8843439-7455909?ie=UTF8&s=books&qid=1182670855&sr=1-2>
Jun 24 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.