|
|
|
Ask HN: Is it possible to semantically analyze code for design patterns?
|
|
6 points
by ashastry
5248 days ago
|
|
I have been recently introduced to the importance of writing clean, maintainable code. Even though I have studied Design Patterns and have read books on how to go about it, I find it difficult to recognize patterns in code. I have been told that this skill improves over time of reading and writing more code. The question is can code be semantically analyzed on the fly to 1) Detect duplicate code 2) Detect design patterns 3) or taking it one step further: Suggest how to go about refactoring Are there any tools which already do this? |
|
http://en.wikipedia.org/wiki/List_of_tools_for_static_code_a...
From my very limited understanding, the powerful ones are seemingly only in reach for large enterprises [1].
With regard to number 3, In C# and Java, resharper/IntelliJ has partially automated refactoring tools. I'm sure similar tools exist for other languages.
However, I think going down this route is substantially more work unless you are inheriting a code base. I would aim to learn some of the design patterns basics[2], perhaps read "The Algorithm Design Manual" [3], and aim to have a clear idea of how to design your latest algorithm from the offset.
[1] - http://semmle.com/solutions/what-we-do/index.html
[2] - http://en.wikipedia.org/wiki/Design_Patterns
[3] - http://www.amazon.co.uk/Algorithm-Design-Manual-Steven-Skien...