soru |
cevap |
W tym podręczniku będziemy mówić o pisaniu „czystego” kodu. öğrenmeye başla
|
|
In this handbook we're going to talk about writing "clean" code.
|
|
|
Jest to temat, który trochę mnie dezorientował, gdy zaczynałem pracę jako programista i odkryłem, że ma on wiele niuansów i możliwych interpretacji. öğrenmeye başla
|
|
It's a topic that used to confuse me a bit when I was starting out as a programmer, and I find that it has many nuances and possible interpretations.
|
|
|
Zatem w tym artykule porozmawiamy o tym, co oznacza termin „czysty kod”, dlaczego jest on ważny i jak możemy ocenić, czy baza kodu jest czysta, czy nie. öğrenmeye başla
|
|
So in this article we'll talk about what the term "clean code" means, why it's important, how can we assess whether a codebase is clean or not.
|
|
|
Poznasz także najlepsze praktyki i konwencje, których możesz przestrzegać, aby Twój kod był czystszy. öğrenmeye başla
|
|
You'll also learn some best practices and conventions you can follow to make your code cleaner.
|
|
|
Czysty kod to termin używany do opisania kodu komputerowego, który jest łatwy do odczytania, zrozumienia i konserwacji. öğrenmeye başla
|
|
Clean code is a term used to describe computer code that is easy to read, understand, and maintain.
|
|
|
Czysty kod jest napisany w sposób prosty, zwięzły i wyrazisty. öğrenmeye başla
|
|
Clean code is written in a way that makes it simple, concise, and expressive.
|
|
|
Jest zgodny z zestawem konwencji, standardów i praktyk, które ułatwiają czytanie i przestrzeganie. öğrenmeye başla
|
|
It follows a set of conventions, standards, and practices that make it easy to read and follow.
|
|
|
Czysty kod jest wolny od złożoności, nadmiarowości i innych zapachów kodu oraz antywzorców, które mogą utrudniać konserwację, debugowanie i modyfikowanie. öğrenmeye başla
|
|
Clean code is free from complexity, redundancy, and other code smells and anti-patterns that can make it difficult to maintain, debug, and modify.
|
|
|
Nie mogę przecenić znaczenia czystego kodu. öğrenmeye başla
|
|
I can't overstate the importance of clean code.
|
|
|
Nie mogę przecenić znaczenia czystego kodu. öğrenmeye başla
|
|
I can't overstate the importance of clean code.
|
|
|
Gdy kod jest łatwy do odczytania i zrozumienia, ułatwia programistom pracę nad bazą kodu. öğrenmeye başla
|
|
When code is easy to read and understand, it makes it easier for developers to work on the codebase.
|
|
|
Może to prowadzić do zwiększenia produktywności i zmniejszenia liczby błędów. öğrenmeye başla
|
|
This can lead to increased productivity and reduced errors.
|
|
|
öğrenmeye başla
|
|
|
|
|
Półkula północna to połowa Ziemi położona na północ od równika. öğrenmeye başla
|
|
The Northern Hemisphere is the half of Earth that is north of the Equator.
|
|
|
öğrenmeye başla
|
|
|
|
|
öğrenmeye başla
|
|
|
|
|
nadal mnie przewyższał we wszystkich meczach öğrenmeye başla
|
|
he continued to surpass me at all games
|
|
|
öğrenmeye başla
|
|
|
|
|
obawa - oznacza martwienie się o coś öğrenmeye başla
|
|
concern - means worried about something
|
|
|
wspomnieć - odnieść się do (czegoś) krótko i bez wchodzenia w szczegóły. öğrenmeye başla
|
|
mention - refer to (something) briefly and without going into detail.
|
|
|
Nie wspomniałam jeszcze o tym Williamowi öğrenmeye başla
|
|
I haven't mentioned it to William yet
|
|
|
Ekstremalne zjawiska pogodowe nie pokazały, że rządy odpowiednio poradziły sobie z wyzwaniami. öğrenmeye başla
|
|
Extreme weather events didn't show that governments have dealt adequately with the challenges.
|
|
|
öğrenmeye başla
|
|
|
|
|
spakuj swoje marzenia - gotowy i chętny do realizacji swoich aspiracji. öğrenmeye başla
|
|
pack your dreams - ready and willing to pursue your aspirations.
|
|
|
serce kompasu - ktoś, kto ma silną chęć podróżowania öğrenmeye başla
|
|
compass heart - someone who has a strong desire to travel
|
|
|
bilet do odkrycia - możliwość uczenia się i odkrywania nowych rzeczy öğrenmeye başla
|
|
ticket to discovery - opportunity to learn and explore new things
|
|
|
zaplanuj wspomnienia - aby stworzyć niezapomniane wrażenia öğrenmeye başla
|
|
map out memories - to create memorable experiences
|
|
|
skrzydła wolności - poczucie wyzwolenia i przygody öğrenmeye başla
|
|
wings of freedom - feeling of liberation and adventure
|
|
|
paszport do przygody - możliwość wyruszenia w ekscytujące podróże öğrenmeye başla
|
|
passport to adventure - opportunity to embark on exciting travels
|
|
|
öğrenmeye başla
|
|
|
|
|
öğrenmeye başla
|
|
we will send you an itinerary
|
|
|
öğrenmeye başla
|
|
|
|
|
öğrenmeye başla
|
|
|
|
|
öğrenmeye başla
|
|
|
|
|
rozproszone przesyłanie strumieniowe öğrenmeye başla
|
|
|
|
|
öğrenmeye başla
|
|
|
|
|
öğrenmeye başla
|
|
|
|
|
öğrenmeye başla
|
|
|
|
|
Jestem pewien, że większość czytelników spotkała się z sytuacją, w której odwiedzasz swój kod zaledwie kilka miesięcy później i trudno ci zrozumieć, co zrobiłeś wcześniej. öğrenmeye başla
|
|
And I am sure most readers have faced the situation where you visit your code only a few months later and have a hard time understanding what you did before.
|
|
|
Jak tworzyć znaczące nazwy öğrenmeye başla
|
|
How to Create Meaningful Names
|
|
|
Nie używaj komentarzy do wyjaśnienia, dlaczego użyto zmiennej. Jeśli nazwa wymaga komentarza, zamiast pisać komentarz, poświęć trochę czasu na zmianę nazwy tej zmiennej. öğrenmeye başla
|
|
Do not use comments to explain why a variable is used. If a name requires a comment, then you should take your time to rename that variable instead of writing a comment.
|
|
|
Jeśli nazwa wymaga komentarza, to nie zdradza swojego zamysłu. öğrenmeye başla
|
|
If a name requires a comment, then the name does not reveal its intent.
|
|
|
öğrenmeye başla
|
|
|
|
|
öğrenmeye başla
|
|
|
|
|
Są zbędne i należy je usunąć. öğrenmeye başla
|
|
They are redundant and should be removed.
|
|
|
öğrenmeye başla
|
|
|
|
|
Jeśli nie potrafisz wymówić jakiegoś imienia, nie możesz o nim rozmawiać tak, żeby nie zabrzmiało głupio. öğrenmeye başla
|
|
If you can't pronounce a name, you can't discuss it without sounding silly.
|
|
|
Upewnij się, że robią tylko jedną rzecz öğrenmeye başla
|
|
Make Sure They Just Do One Thing
|
|
|
Tylko oni powinni to zrobić. öğrenmeye başla
|
|
|
|
|
Dobrym sposobem sprawdzenia jest próba wyodrębnienia innej funkcji o innej nazwie. öğrenmeye başla
|
|
One good way to check is to try to extract another function with a different name.
|
|
|
i przyzwyczajenie się do tego zajmie trochę czasu. öğrenmeye başla
|
|
and it will take some time to get used to.
|
|
|
Ale gdy już to opanujesz, Twój kod będzie wyglądał na znacznie dojrzalszy i na pewno będzie łatwiej go refaktoryzować, zrozumieć i przetestować. öğrenmeye başla
|
|
But once you get the hang of it, your code will look much more mature, and it will be more easily refactorable, understandable, and testable for sure.
|
|
|
Hermetyzuj warunki warunkowe w funkcjach öğrenmeye başla
|
|
Encapsulate Conditionals in Functions
|
|
|
Oto fragment kodu z mojego projektu szkolnego. öğrenmeye başla
|
|
Here is a piece of code from a school project of mine.
|
|
|
Obrzydliwe, prawda? Zgadzam się. öğrenmeye başla
|
|
|
|
|
Funkcje powinny mieć dwa lub mniej argumentów, im mniej, tym lepiej. öğrenmeye başla
|
|
Functions should have two or fewer arguments, the fewer the better.
|
|
|
Argumenty flagowe w naturalny sposób zaprzeczają zasadzie pojedynczej odpowiedzialności. öğrenmeye başla
|
|
Flag arguments naturally contradict the principle of single responsibility.
|
|
|
Skutki uboczne to niezamierzone konsekwencje Twojego kodu. öğrenmeye başla
|
|
Side effects are unintended consequences of your code.
|
|
|
Mogą powodować nieprzyjemne błędy. öğrenmeye başla
|
|
They can result in some nasty bugs.
|
|
|
Powtarzanie kodu może być źródłem wszelkiego zła w oprogramowaniu. öğrenmeye başla
|
|
Code repetition may be the root of all evil in software.
|
|
|
Zduplikowany kod oznacza, że w przypadku zmiany logiki musisz zmienić elementy w wielu miejscach i jest to bardzo podatne na błędy. öğrenmeye başla
|
|
Duplicate code means you need to change things in multiple places when there is a change in logic and it is very error prone.
|
|
|
Wtedy, gdy zmienią się nazwy zmiennych lub nazw metod, staje się to nieistotne, ale nadal nikt ich nie usuwa. öğrenmeye başla
|
|
Then when variable names or method names change, it gets irrelevant but still nobody deletes it.
|
|
|
Czyste kodowanie nie jest umiejętnością, którą można nabyć z dnia na dzień. öğrenmeye başla
|
|
Clean coding is not a skill that can be acquired overnight.
|
|
|