Forum start - Register
Name Password Forgot your password?

Forum start > pc > software > Clean Code
Author
Thread
JDOG
Member


 

Location: 
Registered: 8/7/2006    Warnings: 0
Clean Code
Hey guys, I have run into a guy at my work who has really changed my perspective on coding. He has written a couple of books etc and has really been pounding into me the idea of refactoring, clean coding etc. So, my question to you all is, what techniques/tools do you use to keep your code neat, readable, and efficient?

I have been doing my best to make my functions 10 lines or less and been doing my best to break everything down into readable functions with variables that have meaning. I have been using Coderush from DevExpress and ReSharper.

Any words of wisdom to share in this?
__________________
JDW
jdog44@gmail.com
12/19/2013 09:31 Link - Ip: Logged - Quote:
byerspc
Admin
avataren

 

Location: South Bend, IN
Registered: 4/14/2006      Warnings: 0
Have you read Uncle Bob's books Clean Code and Clean Coder?

If you are writing good unit tests following TDD your code will stay pretty clean because it is hard to write automated tests if your code isn't clean :-)

I am a big fan of resharper running visual studio code analysis to monitor code coverage and code complexity. If you have more than one branch in a method there is a good chance that the method may be doing too much etc.

Refactoring legacy code is another matter and requires care not to break existing code by wrapping old code in pinning tests while you refactor. It can be done but is a pain. I think Martin Fowler wrote a book on that.

Glad to hear you are trying to write clean code...My team is going to be learning how to do it soon. We are moving to agile/scrum on 1/1/2014! I am excited....have missed it since I left PG.
__________________
byerspc
byerspc@gmail.com
12/19/2013 13:34 Link - Ip: Logged - Quote:
JDOG
Member


 

Location: 
Registered: 8/7/2006      Warnings: 0
I have read the beginning of both of those books. However, I am guilty of not finishing either one of them. Testing is something that I never really understood the benefit of as much until I started trying to refactor some of the crappy code I have seen/made in the past. CodeRush has a line counter, a cyclomatic complexity, and a maintenance complexity tool along with a couple other things I have not used. Does ReSharper have something like that as well? I looked it up some and I only saw cyclomatic complexity, obviously the line counting can be easily solved lol. But the maintenance complexity I really enjoy. It really helps to make sure that the functions do not do to much.

One thing I have appreciated about here is that they at least try to code right most of the time. It's not a free for all for whatever works. True, I know there is huge room for improvement but it's nice to be around people that want to learn.
__________________
JDW
jdog44@gmail.com
12/20/2013 06:24 Link - Ip: Logged - Quote:
byerspc
Admin
avataren

 

Location: South Bend, IN
Registered: 4/14/2006      Warnings: 0
yeah VS has code complexity, code coverage and some other code maintenance metrics built in when you compile but you have to turn them on ...they are all off by default.
__________________
byerspc
byerspc@gmail.com
12/20/2013 08:14 Link - Ip: Logged - Quote:
Forum start > pc > software > Clean Code

Quick reply
You need to login before you can post.


Powered by ASPBB v0.5.2
© 2004-2006 ASPBB Developers team