1

There is a bunch of books that state principles about good code (SOLID, DRY, Design patterns etc.) Those principles are solutions to some problems. An application of those principles could go like that:

Approach 1: I know the principles ⇒ I will write code that respect those principles.

The problem with this approach is that principles are context-related. We need to make sure that we have the problem (the context) for which we apply the solution. A preferable approach is:

Approach 2: I write simple code ⇒ Using some tools, methods I can discover that I have some problem ⇒ Apply the principle related to that problem.

So, is there some tools, methods etc. to use to figure out the problems. An example would be, using git, I notice that there is a class that depends on a less stable class. I then decide to introduce an interface and do a dependency inversion. I would appreciate any ressources that can help (books, videos, courses, papers etc.).

2
  • 2
    You're right, but (for the foreseeable future) this is more of an art. People use different methods, design approaches, and heuristics, and which ones are the most useful vary across people - probably depending on the way they think, or their background, experience, etc. You can use git in some creative ways - e.g. you can extract data to see which files are the most worked on and focus your design efforts mostly there. But there's no silver bullet type of tooling. Commented Aug 14, 2021 at 13:00
  • 2
    You could perhaps look into books like Working Effectively with Legacy Code by Michael Feathers (talks about how to make existing code better, design, and also describes some of the ways to make use of various tools), and Domain-Driven Design by Eric Evans (describes a way to do domain analysis & modeling, and also has a list of references that point you to other sources of information). Commented Aug 14, 2021 at 13:00

2 Answers 2

5

Unfortunately, there are no tools clever enough to detect your intents or identify when separation of concerns is not corresponding to the problem domain.

Would there be such a tool, it would be an AI system based on machine learning. It would have learned from a lot of examples: considering the many misunderstandings around principles such as SRP there would be a high probability that it would give you the wrong advices.

The golden principle of software development is: You’re the developper: it’s up to you to decide; and the solution is at the tip of your fingers (or other appropriate input devices) . The more you’ll develop, the more you’ll learn from false good ideas and the better your design will end up to be. Meanwhile, in case of doubt, talk to a senior developper, and if none is available, come back here on SE :-)

1

Tools like git are designed to help you manage and track changes to your code and share the code and changes between multiple developers. It has no features to help you design your code.

Some tools like integrated developer environments (IDE) have some features that help with design, but they won't do the design for you or make huge structural changes to the code. At best, they might assist with that, and handle diagramming or dependency tracking, or generate code templates from a GUI layout you design. If there was a tool that could design the code, we wouldn't need programmers.

1
  • 1
    Very relevant. We could also name some static analysis tools that calculate usual OOP metrics. But I think OP meant a tool that would use and scan the source repository, using git only mainly identifying the changes.
    – Christophe
    Commented Aug 14, 2021 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.