How GitHub Copilot can WET your code (especially as a beginner)
Tags: beginners, productivity, githubcopilot, programming
Published: 2022-05-22 11:58:06

[GitHub Copilot](https://copilot.github.com/), (the controversial AI, that writes code instead of you) has been the subject of the discussion: "Will it deprive programmers of their job?". We cannot predict the future yet, but so far, it seems unlikely. In it's current state, it has the tendency to introduce bad coding habits.

Though, one thing is for sure: **Copilot does an excellent job on lessening the time spent on Stackoverflow or looking up documentation**. **It is enabling us to write code _faster_**. Not only we have access to code snippets from the web inside our IDE, but it can also find the "puzzle pieces" that are needed to be changed in the suggested code pieces, so we can apply the solution in our codebase.

Copilot reads our code as well as scraping the web and it will give personalised suggestions accordingly. For instance, if one has written their DAO's "create" method for a class in their specific way, Copilot will guess the create method for all the other classes based on their already existing implementation, but interchanging the right "puzzle pieces".
 
**However GitHub Copilot is not (yet?) capable of suggesting method extraction, introducing interfaces or generalization.**

This could lead to one overusing the automatic code generation instead of spending time with constructing a better, cleaner solution. This, however will often result in repeating code pieces. Why?

As said before, **it _writes the same code_, but _changes_ certain parts. This statement screams WET code.**

Using these suggestions not only could make someone forget about considering writing cleaner code, but it also could appear much more convenient and sensible. Why? 

For someone not using Copilot, WET code would have (amongst many) two huge disadvantages:
- More typing, or lengthy adjustment of copied code (short term)
- Chaos to maintain (long term)

Copilot makes it a breeze to write similar or worse, the same code N amount of times. This essentially eradicates the short term disadvantage of writing WET code. No retyping, no copy pasting and then changing parts of it, none of the similar hassle. It is all done via pressing tab once.

One could argue that experienced developers (hopefully) would not blindly rely on Copilot, hence there is no danger in using it with care. This statement is absolutely right. **Beginner or careless coders**, however **might fall victim to agreeing with everything that Copilot suggests**. Why wouldn't they? It's in the reach of pressing tab once and it (almost) always works. Thus, **Copilot could give them the false perception of fast progress**.

In the case of students, this is even strengthened by the fact that school projects often have tight deadlines, thus in many cases making clean code has to have a lot lower priority than working code. 

Additionally, school projects have a limited length, where troubles with code maintenance may only appear near the hand-in date. At that point, students would say: "Okay, let's make this chaos work somehow, hand it in, forget about it."
Then, they would repeat the process... **Each of their projects would progress exceptionally fast in the beginning, then as soon as code needs to be modified or extended, the rate of progress would drop drastically**.

In conclusion, any coder who relies too much on Copilot could find themselves not exercising their knowledge of how to write not only working, but clean code. 



> It almost feels like the copilot promoted crappy WET over handwritten DRY. The point of DRY is to avoid repetitive code, not to write or generate it by AI.

...writes [Pavel Movara](https://dev.to/hanpari), in the comments of [Tapajyoti Bose](https://dev.to/ruppysuppy)'s [article](https://dev.to/ruppysuppy/github-copilot-my-experience-after-one-week-usage-eie).

_Disclaimer: This is an article from a 2nd semester CS student and it is based on personal experience and limited research, take it merely as an advice._