U
U
User6282022-01-27 16:14:04
Work organization
User628, 2022-01-27 16:14:04

How do programmers store frequently used pieces of code so that they don't have to remember each time?

How do programmers store small heterogeneous pieces of code, examples of how instructions are used, patterns of a certain language / framework, concepts, frequently used code, boilerplate, so that each time you don’t remember how to do it when you need it again?
And so that you can conveniently copy / paste them, search for them, add, occasionally change.

Answer the question

In order to leave comments, you need to log in

12 answer(s)
D
dollar, 2022-01-27
@dollar

Programmers do not forget this to store it somewhere. You can forget the names of functions, of which there are 100500 in various APIs. But the syntax and language standards are like an alphabet. Do you often forget the alphabet? Can you reproduce it now: "a", "b", "c" ...? And if another language: "a", "b", "c"... ? Likewise, (real) programmers remember these things as the foundations of the foundations.
Frequently used code is arranged as functions, and there is no need for copying / rewriting. Many of these simple functions are included in the standard library, and the names of such functions do not change much from language to language. Therefore, even if the language does not have one of these functions, then it is created with a known name in advance, which programmers remember well. And if the function is specific to the project, then there are not many such functions, and they are also easy to remember (for the duration of the project).

R
Rag'n' Code Man, 2022-01-27
@iDmitriyWinX

Snippets

V
Vasily Bannikov, 2022-01-27
@vabka

Frequently used code, with a sufficiently deep study, is remembered at an intuitive level.
Boilerplate - mechanical memory, snippets, and templates.
Well, Google with stackoverflow :)
If within the framework of one project, then you can just copy-paste.
Well, you can also move the repeating code into a separate module and use it

D
Daria Motorina, 2022-01-27
@glaphire

In the backend, almost everything that is often used is added to some kind of module, a console command generator or a dump of helpers (such as the Utils class) in the project, so there is no need to store it separately. Occasionally, you can save some reference implementation of a large task in a github or gist

A
Alexandroppolus, 2022-01-27
@Alexandroppolus

a separate folder with files containing pieces of code. Permanently open in Atom, you can quickly take and copy-paste

N
nashivancom, 2022-01-27
@nashivancom

github gist

P
Pavel, 2022-01-27
@mrusklon

I asked this question a very, very long time ago, I was looking for a program so that snippets could be inserted into any IDE without being tied to the code editor itself, but alas, I did not find a suitable software, maybe after so many years someone found one.
So far, I've only got around with snippets in the IDE, and if the code needs a lot of explanation, I kept the code in obsidian (markdown markup)

G
Griboks, 2022-01-27
@Griboks

I store it in stack overflow, insert it into the code via google..

S
Sergey delphinpro, 2022-01-28
@delphinpro

I am using github gist and OneNote

G
Grigory Boev, 2022-01-28
@ProgrammerForever

When I was coding in VB6 at school, I saved significant pieces of code that can be reused in modules and stored them in folders that were more or less structured.
Now I store the snippets on my github. From the consideration that it lies in the cloud.

Y
Yerlan Ibraev, 2022-01-28
@mad_nazgul

If you often use something, then it makes sense to allocate it to the library.
Well, or write a code generator. For example in IDEA.

R
Rickkk, 2022-01-28
@Rickkk

I used to make an ordinary word file with a table inside. The left column contains an explanation of the purpose, the right - a piece of code. And now I paid for a paid Evernote account - I store pieces of code in different notes, I group notes into notebooks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question