Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does Clean Code Involve...

 
greg fuentes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does clean code involve "Programming to an interface" and keeping methods as Generic as possible?
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by greg fuentes:
Does clean code involve "Programming to an interface" and keeping methods as Generic as possible?


Yes and no.

It involves a whole lot more than programming to an interface. The book talks about coding so that your program tells its story well, how to name variables and functions and classes so that they are expressive, how not to name variables, functions, and classes. It talks about using whitespace to help visually clarify your code, about how not to use comments, about how long methods and classes should be, about writing clean tests.

Should a method be as generic as possible? Not necessarily.

In some cases, it should be as specific as possible - especially if you are only using it once.

It talks about writing dirty code and then cleaning it up, step by step, under the protection of automated tests.

Clean code is about writing code that is a pleasure to read, easy to understand, easy to extend and modify, easy to maintain, easy to pass on to another developer.

... and so much more.
 
Robert Martin
Author
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by greg fuentes:
Does clean code involve "Programming to an interface" and keeping methods as Generic as possible?


Sure. At lease that's good clean design. But clean code is a lot more than just programming to interfaces. It's clean names, small functions, well partitioned classes, minimal comments, and a whole host of other practices.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic