Design patterns overuse, or a “smelling code”

Home Forums Programming Software engineering Patterns design Design patterns overuse, or a “smelling code”

Tagged: 

This topic contains 0 replies, has 1 voice, and was last updated by  Васильев Владимир Сергеевич 3 months, 2 weeks ago.

  • Author
    Posts
  • #4073

    Here comes the topic I deifnitely want to discuss on my blog, because from my own experience I can say – it’s rather easy to get so much into design patterns, and in some cases it is good, but in other …

    Basically, those who are familiar with design patterns can be divided into two categories:

    First – those who know them and apply them in some cases, mainly relying on their own vision of what the structure of their code should be.

    And the second group – those who once heard about patterns, start reading avidly about them and try to apply them in an inadequate amount where it is necessary and where it is not necessary. In general, to the second group this article is dedicated…

    Strange thing, but design patterns are very often seen as a panacea. Of course, their use may be a sign of a good code structure, but not using them in code does not always mean a bad code design. Just the task of extensibility and reuse of code is not always aimed. Then there is no point in wasting precious time working on a project to design a flexible system.

    But more often we have the opposite situation. And then it is worth to do your best to work on flexible architecture. Competent but not abstruse. Design patterns overuse can lead to very muddled structure, huge and absolutely ungrounded number of classes, interfaces, and also to sophisticated relationships between data types. The author of this masterpiece will not share your doubts about his genius, since in his eyes, the success of the project is directly proportional to the number of design patterns, which he applied. And basically it does not matter even if they are used appropriately or not.

    Please do not think that now is not fashionable to just write a normal working code with the architecture and code design adequate to the task. Modern software developers’ slogan is not “use patterns”, but “be a professional”.

    Just think, such a rich tool turned into anti-tool in the hands of amateurs, non-professionals and just lazy for learning developers. It’s called – anti-patterns.

    How can it be expressed?

    For example, in an attempt to apply a specific pattern or a small number of patterns in all situations. And the reason for this may be an unwillingness to spend the time to self-improve, because it is easier to learn a bit and appeal to this knowledge constantly than to study something new and get to the heart of things.

    Or in a paranoid willing to make code “flexible” and “potentially capable of any improvements” and “ready for any changes we can ever decide to make” … This usually leads to a complicated code, a large number of small classes, each of which is planned as an adapter to objects of another type, and eventually we lose all logical connection between classes, lining up a chain.

    We can have many examples, and each of these cases even has its own name, but this is not the topic of this article, so more on that topic we shall talk some other time.

    Here it just sounds as a caution – use development tools wisely.

You must be logged in to reply to this topic.