Skip to content

Commit d87dc2d

Browse files
committed
Translate a part of article
Line 41 needs more attention
1 parent 4de10f8 commit d87dc2d

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

  • 1-js/09-classes/04-private-protected-properties-methods

1-js/09-classes/04-private-protected-properties-methods/article.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,33 @@
3131

3232
اما برای مخفی‌سازی جزئیات درونی،ما از پوشش حفاظتی استفاده نمی‌کنیم، بلکه از سینتکس خاص زبان و قراردادها استفاده می‌کنیم.
3333

34-
## Internal and external interface
34+
## رابط درونی و بیرونی
3535

36-
In object-oriented programming, properties and methods are split into two groups:
36+
در برنامه‌نویسی شیءگرا، ویژگی‌ها و متدها به دو گروه تقسیم می‌شوند:
3737

38-
- *Internal interface* -- methods and properties, accessible from other methods of the class, but not from the outside.
39-
- *External interface* -- methods and properties, accessible also from outside the class.
38+
- *رابط درونی* -- متدها و ویژگی‌ها، قابل دسترس از متدهای دیگر کلاس، اما نه از بیرون.
39+
- *رابط بیرونی* -- متدها و ویژگی‌ها، قابل دسترس از بیرون از کلاس.
4040

41-
If we continue the analogy with the coffee machine -- what's hidden inside: a boiler tube, heating element, and so on -- is its internal interface.
41+
اگر ما مثال قهوه‌ساز را ادامه دهیم -- چیزی که درون آن است: یک مجرای بخار، المنت حرارت و غیره -- رابط درونی است.
4242

43-
An internal interface is used for the object to work, its details use each other. For instance, a boiler tube is attached to the heating element.
43+
یک رابط درونی برای اینکه شیء کار کند استفاده می‌شود، جزئیات آن از یکدیگر استفاده می‌کنند. برای مثال، یک مجرای بخار به المنت حرارت متصل شده است.
4444

45-
But from the outside a coffee machine is closed by the protective cover, so that no one can reach those. Details are hidden and inaccessible. We can use its features via the external interface.
45+
اما از بیرون یک قهوه‌ساز توسط پوشش محافظ بسته شده است پس کسی نمی‌تواند به آن‌ها دسترسی داشته باشد. جزئیات پنهان و غیر قابل دسترس شده‌اند. ما می‌توانیم از طریق رابط بیرونی از خصوصیات آن استفاده کنیم.
4646

47-
So, all we need to use an object is to know its external interface. We may be completely unaware how it works inside, and that's great.
47+
پس تمام چیزی که برای استفاده از یک شیء نیاز داریم این است که رابط بیرونی آن را بشناسیم. شاید کاملا از اینکه چگونه کار می‌کند و این عالی است.
4848

49-
That was a general introduction.
49+
این یک معرفی کلی بود.
5050

51-
In JavaScript, there are two types of object fields (properties and methods):
51+
در جاوااسکریپت، دو نوع فیلد شیء داریم (ویژگی‌ها و متدها):
5252

53-
- Public: accessible from anywhere. They comprise the external interface. Until now we were only using public properties and methods.
54-
- Private: accessible only from inside the class. These are for the internal interface.
53+
- عمومی (public): قابل دسترس از هر جا. آن‌ها شامل رابط بیرونی می‌شوند. تا اینجا ما فقط از ویژگی‌ها و متدهای عمومی استفاده می‌کردیم.
54+
- خصوصی (private): فقط درون کلاس قابل دسترس است. این‌ها برای رابط درونی هستند.
5555

56-
In many other languages there also exist "protected" fields: accessible only from inside the class and those extending it (like private, but plus access from inheriting classes). They are also useful for the internal interface. They are in a sense more widespread than private ones, because we usually want inheriting classes to gain access to them.
56+
در بسیاری از زبان‌های دیگر فیلدهای «محافظت‌شده» (protected) هم وجود دارد: فقط از درون کلاس و کلاس‌هایی که آن را تعمیم می‌دهند قابل دسترس است (مانند نوع خصوصی اما قابل دسترس از کلاس‌های ارث‌بر). آن‌ها هم برای رابط درونی مفید هستند. آن‌ها در کل نسبت به نوع خصوصی بیشتر رایج هستند چون ما معمولا می‌خواهیم کلاس‌های ارث‌بر به آن‌ها دسترسی داشته باشند.
5757

58-
Protected fields are not implemented in JavaScript on the language level, but in practice they are very convenient, so they are emulated.
58+
فیلدهای محافظت‌شده در جاوااسکریپت در سطح زبان پیاده‌سازی نشده‌اند اما در عمل بسیار مناسب هستند پس تقلید شده‌اند.
5959

60-
Now we'll make a coffee machine in JavaScript with all these types of properties. A coffee machine has a lot of details, we won't model them to stay simple (though we could).
60+
حالا در جاوااسکریپت یک قهوه‌ساز همراه با انواع ویژگی خواهیم ساخت. یک قهوه‌ساز جزئیات زیادی دارد، ما برای ساده بودن آن‌ها را مدل‌سازی نمی‌کنیم (اگرچه می‌توانستیم).
6161

6262
## Protecting "waterAmount"
6363

0 commit comments

Comments
 (0)