ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

What is DRY in programming and why it matters?

Автор: Smok Code

Загружено: 2020-10-28

Просмотров: 5288

Описание: Avoiding knowledge duplication is daily bread and butter of every programmer. In this #QuickAnswer I'll shed some light on the subject.

#programming #tech #softwaredevelopment #developer #sde

Clean Code (R. Martin) - US: https://amzn.to/3jVUEDU | UK: https://amzn.to/2Iij4Jz
Best Practices for Programmers - US: https://amzn.to/2SPRSEg | UK: https://amzn.to/2Fr2h6e

What is DRY in programming and why it matters?

DRY stands for Do Not Repeat yourself. And it is one of the primary principles of good, clean code used by every professional programmer daily. If you don’t respect it - you won’t get very far.
Very naive explanation of this rule says that you shouldn’t just copy and paste the code around, and that is true, but it’s about much more than that. Keeping your code DRY is about duplication of knowledge and intent.
When we write our programs we codify the rules that govern the business side of the program, and this process is very costly. Time of programmers is expensive, and throughout the lifetime of a product - a single change gets the attention of very many people. There is an author, a reviewer, another programmer who finds a bug in the code, and fixes it, and then there is someone who builds on top of the code and extends it.
Therefore it is very imperative to avoid writing a code that when change is needed - has to be modified in many places in order to support new requirements. Today we acknowledge change as an inherent part of building a product, so much that we formed entire methodologies around supporting constant change like agile.
So whenever you need to check if your code is really dry, ask yourself: if the product has new requirements: how many places and formats do you need to change? Few bits of the code? Documentation? Database? Network layer? APIs? Answering yes too many times and your product isn’t DRY.
Of course there is a tradeoff related to writing the code in DRY manner: you spend more time on initial stages, designing, cleaning and distilling interfaces, partitioning the code and refactoring things that no longer fit the new purpose. It may seem like it takes forever to produce such clean code, but because of that - the cost of maintaining this code in the future will be orders of magnitude less. Perhaps this is the cost you will be paying very soon.
One thing that we need to be vary is overly extensive strictness when it comes to code duplication. Example given in The Pragmatic Programmer book is perfect to illustrate that: two validation functions that check for different things, but actually share the same body.
Should we merge this under one function and just call it “validate_something”? Of course no, this isn’t the duplication of knowledge, it’s a coincidence. As soon as one of these things will need to be changed - we’ll have to break the function into two. Another issue is finding generic validators in the repository that we can’t immediately assign to validated value.
Knowledge duplication really can be the source of all evil. Sooner or later the both versions will start to diverge, and keeping them in line always seems like wishful thinking. It doesn’t matter if these are two bits of code, comments or intent expressed in the database. It will break, believe me.
Avoiding duplication will be your bread and butter, the further you go into the land of software development, and like everything in it - it’s another point to debate and pick from a myriad of solutions. Don’t worry - the expertise to solve these issues will come with practice.
Subscribe, and I’ll see you in the next one, cheers!

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
What is DRY in programming and why it matters?

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Избегайте наследования при разработке ООП-программного обеспечения?

Избегайте наследования при разработке ООП-программного обеспечения?

"Clean Code" is bad. What makes code "maintainable"? part 1 of n

DRY principle is why your codebase sucks?

DRY principle is why your codebase sucks?

"Clean" Code, Horrible Performance

3 Tips To Write Clean Code (from an ex-Google software engineer)

3 Tips To Write Clean Code (from an ex-Google software engineer)

5 Easy Principles for ALWAYS Writing Clean Code

5 Easy Principles for ALWAYS Writing Clean Code

Все о принципах SOLID

Все о принципах SOLID

Что такое API? Простыми Словами Для Начинающих

Что такое API? Простыми Словами Для Начинающих

Programming Terms: DRY (Don't Repeat Yourself)

Programming Terms: DRY (Don't Repeat Yourself)

Programming Principles Crash Course: KISS, YAGNI, Law of Demeter, DRY and etc.

Programming Principles Crash Course: KISS, YAGNI, Law of Demeter, DRY and etc.

Принципы SOLID: действительно ли вы их понимаете?

Принципы SOLID: действительно ли вы их понимаете?

My 10 “Clean” Code Principles (Start These Now)

My 10 “Clean” Code Principles (Start These Now)

У меня ушло 10+ лет, чтобы понять то, что я расскажу за 11 минут

У меня ушло 10+ лет, чтобы понять то, что я расскажу за 11 минут

Не пишите комментарии

Не пишите комментарии

CI/CD — Простым языком на понятном примере

CI/CD — Простым языком на понятном примере

Is YAGNI (You aren’t gonna need it) Still Relevant in Backend Engineering System Design?

Is YAGNI (You aren’t gonna need it) Still Relevant in Backend Engineering System Design?

DRY Software Principle makes you CRY

DRY Software Principle makes you CRY

The One BIG Reason to Learn Google's Go Language

The One BIG Reason to Learn Google's Go Language

How Senior Programmers ACTUALLY Write Code

How Senior Programmers ACTUALLY Write Code

What is Clean Code?

What is Clean Code?

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]