• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clean Code: Best way, per Class, big companies

 
G�za Czimeth
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Is there more way to write clean code? Is there a best way?

2. Your method to clean code only applicable per class, or is the cleaning procedure changes if I look at/consider classes which uses the class what I want to clear? Do you define any order about which class or class group should be clean first? e.g.: first DAO's than jsp than Control classes (talking about MVC).

2.1 In general if I have a porject with many classes and I wan't to clean the code where/how should I start at all?

3. What do you think, does big companies ever start to clean there legacy code? I work for a multi and it is not even mentioned here to clean 'our' legacy code, and the fact is the code is very hard to read and maintain. I think small companies are more flexible to do 'these' kind of things. What do you think?
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to Java Ranch.
The first step I would do is to clean up all warnings I see in my editor. And then you may try using one of the tools like Findbugs, PMD, Checkstyle, Cobertura. Which will give you a huge list of problems in your application. Clean them up. I use findbugs which has a plugin available for eclipse.

Hope this helps your needs.

Regards
Ananth Chellathurai
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2.1) Clean the code that you have to touch anyway. That is, if you have to change some code, for example to fix a bug or to implement an enhancement, make sure that after you have touched it, it is *more* clean than before.

3) Companies don't clean code. Responsible software developers do. And not as a separate action from implementing code, but as an integrated part of every minute of their work. You don't even need to get permission to do it. Just start doing it. Now. Seriously.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ananth Chellathurai:

The first step I would do is to clean up all warnings I see in my editor. And then you may try using one of the tools like Findbugs, PMD, Checkstyle, Cobertura. Which will give you a huge list of problems in your application. Clean them up. I use findbugs which has a plugin available for eclipse.


While those tools have some nicety to it, they can't tackle some of the worst problems with unclean code: badly named methods and identifiers, for example.
 
arulk pillai
Author
Ranch Hand
Posts: 3388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before you start cleaning write a test case if one does not exist.
 
Vijay Venkat
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi G�za Czimeth

1. You can read couple of books/sites to identify what is bad code.
2. This book "Clean Code" should serve that purpose +
3. Don't forget to read Refactoring: Improving the Design of Existing Code (http://www.refactoring.com/catalog/index.html) +
4. Other book is Code Complete 2 by Steve McConnell
5. Write tests before you make code clean. Not always possible at all situations. But getting to do that is the first step.
6. The most important is the courage to get started with it.

Thanks,
Vijay Venkataraman
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic