gtag('config', 'G-0PFHD683JR');
Price Prediction

Good programmers are always majestic

“It is always a closure.”

Difficult sales talisman from Glengarry Glen Ross It has become an acronym for improving uncompromising. In the same spirit (but with less than right), a good engineer should Always be rebuilding. This is the reason.

To clean or not clean

It is generally agreed that the clean code is easier to understand, cheaper in preserving it, and more expandable. In essence, the current code cleansing the current code does not change its perceived functions.

The common protest of re -preparation is that there is no time to do this already. The difference sees it is luxury. The drive does not allow uncomfortable features of the new features simply to re -create, especially because re -activity does not change anything from an external point of view. This can be a difficult sale of your product owner.

But the clean symbol makes your life easier. The clean symbol pushes itself and slows the accumulation of technical debts.

Even infiltration in.

This is correct. I suggest a little trick. Little orientation even. Why not clean some things in every withdrawal request?

Be awake

The good engineer has a place where the base of honor should go. It may take some time to get there, but you know the chaotic parts, accumulation, road map, artistic religion, security holes, and documents gaps.

While developing the usual features, be alive from rejuvenation that can offer your larger business schedule. Like one of those TV programs with excessive services that wipe the crime scene, it is closely interesting for all the code in which you are stuck.

When you notice the smell of a symbol or something near your current focus, the alarm bells must explode: “Don’t let this opportunity pass!” Take a few minutes and fix it now, before the inspiration fades.

Don’t say it’s not your problem. Do not pretend that you can cancel it. Just run your sleeves and accomplish them.

A simple example

Reinstitting does not necessarily mean changing thousands of code. It can be just a small part of the code here and there. These small small factors add over time. In fact, the more it usually enters continuous cleaning, the more you need to make large formations in the future.

To clarify the accurate recovery, let’s take a look at the example of the Golang extract.

Suppose you are dealing with a feature that requires knowledge of the number of days it happened since the last time the user has logged. Note an existing method that determines whether the user is asleep using the same information:

func IsDormant(user User, asOf time.Time) bool {
  days := int(asOf.Sub(user.LastLogin).Hours() / 24)
  return days >= 8
}

You want to reuse the last login account instead of copying and paste it, so you take the internal variable, daysAnd extract it in a separate way, DaysSinceLastLogin:

func IsDormant(user User, asOf time.Time) bool {
  return DaysSinceLastLogin(user, asOf) >= 8
}

func DaysSinceLastLogin(user User, asOf time.Time) int {
  return int(asOf.Sub(user.LastLogin).Hours() / 24)
}

This allows to test the logic of the last login and reuse it. If you write the unit test, you will be raised in the case of an edge that must be treated (a state of potential panic if the user never registered).

It also makes future improvements easier. For example, it may be logical IsDormant and DaysSinceLastLogin Knock on User Brown instead of being independent. Likewise, consider replacing solid value 8 With something more descriptive like DormantDaysThreshold.

This is a simple example, only a few lines of code. But this is beauty. It indicates that a small re -creation can add value by detecting a possible error and indicating future improvements.

To learn more about the re -appeal craft and see all the small ways to improve your code, check on the online resources such as re -creation catalog from Martin Fowler’s book or Reintepan.

Rectement mentality

Get a vision of your code rule easy. Knowing how to get it there is more difficult. Discovering re -preparation opportunities takes practice. One way to start looking at the necessary re -expulsion categories to convert your code.

Here are some common topics to reconsider:

🧹 Remove duplication– The collapse of a copy and the paste of logic in one job.

🧰 Extracting the joint or library utilityTransfer the common logic from the applications of each service. Normalization of integration (for example, all services use the same authentication customer).

🧱 Add joint infrastructureEnter observation (registration, tracking, standards). Central treatment of errors or re -attempt.

⚙ Make the code more test– Tightly disintegrated logic. Extract facades so that it can be ridiculed from dependency or pieces.

🔄 Take advantage of the featureA complicated policewoman or an overlapping logic. Reorganizing files or categories to suit new responsibilities.

🏗 New structure support– disintegration. Entering the event -based patterns, dependency injection, or the treatment of ASYNC.

🚦 Reducing cognitive pregnancyDivide the files or giant groups into focused logical units.

🔐 Improving security or complianceCentral access control logic. Refactor styles (for example, SQL Concatering → Teacher Information).

🚀 Performance improvementReplace naive algorithms with those improved. Reducing memory or unnecessary account in hot tracks.

👥 Reducing the plane or delivery-Refactor symbol that it only understands “Pat” in something readable team. Provide documents/comments/test cover as part of structural cleaning.

20 %

Some may object that all factors can surely sneak. I will give you that. Let’s apply a base of 80-20 and state that 20 % of rejuvenation should take place on top and higher.

However, this must be an easier sale, because when you reach the point where you need to re -formulate completely and honestly to good, it will certainly be in the service of some of the greatest goals.

For example, before working on a performance improvement ticket, you first need to add tracking and standards so that you can develop an accurate image of the current performance and determine hot points.

Starting the reconstruction begins with the test

It is likely to be self -evident, but I must point out that rebuilding is much easier (and less volatile nerves) if your code database contains a group accompanying the tests that pass before and after the reconstruction. Tests are also valuable for a set of other reasons. If your project does not have a strong test, add some tests first to cancel future renovations.

Code review considerations

My advice in this article contradicts the standard guidance principle of not mixing the re -expulsion and developing regular features. The objection is that it makes it difficult for the team to make symbol reviews if non -relevant changes are included. This is a fair point. When repeating the model while making the feature, keep it small and (perfect) associated with the main payment of change.

There is a good base of the thumb for any withdrawal request is to reduce 500 lines of software change changes. The second rule of thumb is that additional reconstruction changes should not exceed 20 % of public relations.

When you have a dedicated to re -preparation PRS, keep it focus and around this size. Sometimes, public relations should be greater than 500 lines of software instructions, especially when working on the Ribo level. In these cases, well coordinates with your colleagues to prepare them for change and reduce conflicts merge.

Make all the number of commitment

Every time you touch the base of the blade, you have a choice: leave it a little better, or leave it a little worse. Reconstruction should not be a big event. Small improvements (extraction methods, renames of confusing variables, loosening long roads, etc.) Add up over time. It prevents technical debts from stacking and making future changes easier and safer.

If you see something, make something.

Always be rebuilding!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button