{"id":73,"date":"2025-02-25T16:43:44","date_gmt":"2025-02-25T13:13:44","guid":{"rendered":"https:\/\/techport.ir\/?p=73"},"modified":"2025-02-25T16:43:44","modified_gmt":"2025-02-25T13:13:44","slug":"%d9%85%d9%81%d9%87%d9%88%d9%85-tight-coupling","status":"publish","type":"post","link":"https:\/\/techport.ir\/?p=73","title":{"rendered":"\u0645\u0641\u0647\u0648\u0645 tight coupling"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u0645\u0646\u0628\u0639: chatgpt<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Tight coupling (\u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0634\u062f\u06cc\u062f)<\/strong> \u0628\u0647 \u0648\u0636\u0639\u06cc\u062a\u06cc \u062f\u0631 \u0637\u0631\u0627\u062d\u06cc \u0646\u0631\u0645\u200c\u0627\u0641\u0632\u0627\u0631 \u0627\u0634\u0627\u0631\u0647 \u062f\u0627\u0631\u062f \u06a9\u0647 \u062f\u0631 \u0622\u0646 \u06a9\u0644\u0627\u0633\u200c\u0647\u0627 \u06cc\u0627 \u0645\u0627\u0698\u0648\u0644\u200c\u0647\u0627 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0632\u06cc\u0627\u062f\u06cc \u0628\u0647 \u06cc\u06a9\u062f\u06cc\u06af\u0631 \u062f\u0627\u0631\u0646\u062f\u060c \u0628\u0647 \u0637\u0648\u0631\u06cc \u06a9\u0647 \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0631 \u06cc\u06a9\u06cc \u0627\u0632 \u0622\u0646\u200c\u0647\u0627 \u0628\u0647\u200c\u0633\u0627\u062f\u06af\u06cc \u0628\u0631 \u0628\u0642\u06cc\u0647 \u062a\u0623\u062b\u06cc\u0631 \u0645\u06cc\u200c\u06af\u0630\u0627\u0631\u062f. \u062f\u0631 \u0627\u06cc\u0646 \u062d\u0627\u0644\u062a\u060c \u06a9\u0644\u0627\u0633\u200c\u0647\u0627 \u0628\u0631\u0627\u06cc \u0627\u0646\u062c\u0627\u0645 \u06a9\u0627\u0631\u0647\u0627\u06cc\u0634\u0627\u0646 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u062f\u0627\u0646\u0633\u062a\u0646 \u062c\u0632\u0626\u06cc\u0627\u062a \u0648 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc\u200c\u0647\u0627\u06cc \u062f\u0627\u062e\u0644\u06cc \u06cc\u06a9\u062f\u06cc\u06af\u0631 \u062f\u0627\u0631\u0646\u062f \u0648 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u06cc \u0633\u06cc\u0633\u062a\u0645 \u06a9\u0627\u0647\u0634 \u0645\u06cc\u200c\u06cc\u0627\u0628\u062f.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u0648\u06cc\u0698\u06af\u06cc\u200c\u0647\u0627\u06cc tight coupling:<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0632\u06cc\u0627\u062f \u0628\u06cc\u0646 \u06a9\u0644\u0627\u0633\u200c\u0647\u0627 \u06cc\u0627 \u0645\u0627\u0698\u0648\u0644\u200c\u0647\u0627<\/strong>: \u0627\u06af\u0631 \u06a9\u0644\u0627\u0633 A \u062a\u063a\u06cc\u06cc\u0631 \u06a9\u0646\u062f\u060c \u0627\u062d\u062a\u0645\u0627\u0644\u0627\u064b \u0628\u0627\u06cc\u062f \u06a9\u0644\u0627\u0633 B \u0646\u06cc\u0632 \u062a\u063a\u06cc\u06cc\u0631 \u06a9\u0646\u062f\u060c \u0632\u06cc\u0631\u0627 A \u0648 B \u0628\u0647 \u0634\u062f\u062a \u0628\u0647 \u0647\u0645 \u0648\u0627\u0628\u0633\u062a\u0647 \u0647\u0633\u062a\u0646\u062f.<\/li>\n\n\n\n<li><strong>\u062a\u062f\u0627\u062e\u0644 \u0632\u06cc\u0627\u062f \u0628\u06cc\u0646 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc\u200c\u0647\u0627<\/strong>: \u06a9\u0644\u0627\u0633\u200c\u0647\u0627 \u06cc\u0627 \u0645\u0627\u0698\u0648\u0644\u200c\u0647\u0627 \u0627\u0637\u0644\u0627\u0639\u0627\u062a\u06cc \u0627\u0632 \u0633\u0627\u062e\u062a\u0627\u0631 \u062f\u0627\u062e\u0644\u06cc \u06cc\u06a9\u062f\u06cc\u06af\u0631 \u062f\u0627\u0631\u0646\u062f \u0648 \u0628\u0647 \u062c\u0632\u0626\u06cc\u0627\u062a \u062e\u0627\u0635\u06cc \u0645\u062a\u06a9\u06cc \u0647\u0633\u062a\u0646\u062f\u060c \u0645\u062b\u0644\u0627\u064b \u06a9\u0644\u0627\u0633 A \u0645\u0645\u06a9\u0646 \u0627\u0633\u062a \u0646\u06cc\u0627\u0632 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f \u06a9\u0647 \u062c\u0632\u0626\u06cc\u0627\u062a \u062e\u0627\u0635\u06cc \u0627\u0632 \u06a9\u0644\u0627\u0633 B \u0631\u0627 \u0628\u062f\u0627\u0646\u062f \u062a\u0627 \u06a9\u0627\u0631 \u06a9\u0646\u062f.<\/li>\n\n\n\n<li><strong>\u06a9\u0627\u0647\u0634 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u06cc \u0648 \u0642\u0627\u0628\u0644\u06cc\u062a \u0646\u06af\u0647\u062f\u0627\u0631\u06cc<\/strong>: \u0628\u0647 \u062f\u0644\u06cc\u0644 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0628\u0627\u0644\u0627\u060c \u062a\u063a\u06cc\u06cc\u0631\u0627\u062a \u062f\u0631 \u06a9\u062f \u067e\u06cc\u0686\u06cc\u062f\u0647\u200c\u062a\u0631 \u0648 \u0627\u062d\u062a\u0645\u0627\u0644 \u0628\u0631\u0648\u0632 \u062e\u0637\u0627 \u0628\u06cc\u0634\u062a\u0631 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0628\u0647 \u0647\u0645\u06cc\u0646 \u062f\u0644\u06cc\u0644\u060c \u06af\u0633\u062a\u0631\u0634 \u0648 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0631\u062f\u0646 \u0648\u06cc\u0698\u06af\u06cc\u200c\u0647\u0627\u06cc \u062c\u062f\u06cc\u062f \u0633\u062e\u062a \u0645\u06cc\u200c\u0634\u0648\u062f.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u0645\u062b\u0627\u0644 \u0627\u0632 tight coupling:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0641\u0631\u0636 \u06a9\u0646\u06cc\u062f \u0634\u0645\u0627 \u06cc\u06a9 \u0628\u0631\u0646\u0627\u0645\u0647 \u0633\u0627\u062f\u0647 \u0628\u0631\u0627\u06cc \u067e\u0631\u062f\u0627\u0632\u0634 \u0633\u0641\u0627\u0631\u0634\u0627\u062a \u062f\u0627\u0631\u06cc\u062f. \u06cc\u06a9 \u06a9\u0644\u0627\u0633 <code>OrderProcessor<\/code> \u062f\u0627\u0631\u06cc\u062f \u06a9\u0647 \u0628\u0647 \u0637\u0648\u0631 \u0645\u0633\u062a\u0642\u06cc\u0645 \u0627\u0632 \u06cc\u06a9 \u06a9\u0644\u0627\u0633 <code>PaymentService<\/code> \u0628\u0631\u0627\u06cc \u067e\u0631\u062f\u0627\u0632\u0634 \u067e\u0631\u062f\u0627\u062e\u062a \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"class PaymentService {\n    public function processPayment($amount) {\n        \/\/ \u06a9\u062f \u067e\u0631\u062f\u0627\u0632\u0634 \u067e\u0631\u062f\u0627\u062e\u062a\n        echo &quot;Payment of $amount processed.&quot;;\n    }\n}\n\nclass OrderProcessor {\n    private $paymentService;\n\n    public function __construct() {\n        $this-&gt;paymentService = new PaymentService();\n    }\n\n    public function processOrder($amount) {\n        \/\/ \u067e\u0631\u062f\u0627\u0632\u0634 \u0633\u0641\u0627\u0631\u0634\n        $this-&gt;paymentService-&gt;processPayment($amount); \/\/ \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0645\u0633\u062a\u0642\u06cc\u0645 \u0628\u0647 PaymentService\n    }\n}\n\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FF79C6\">class<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">PaymentService<\/span><span style=\"color: #F8F8F2\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">public<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">processPayment<\/span><span style=\"color: #F8F8F2\">($amount) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #6272A4\">\/\/ \u06a9\u062f \u067e\u0631\u062f\u0627\u0632\u0634 \u067e\u0631\u062f\u0627\u062e\u062a<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #8BE9FD\">echo<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #E9F284\">&quot;<\/span><span style=\"color: #F1FA8C\">Payment of <\/span><span style=\"color: #F8F8F2\">$amount<\/span><span style=\"color: #F1FA8C\"> processed.<\/span><span style=\"color: #E9F284\">&quot;<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FF79C6\">class<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">OrderProcessor<\/span><span style=\"color: #F8F8F2\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">private<\/span><span style=\"color: #F8F8F2\"> $paymentService;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">public<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">__construct<\/span><span style=\"color: #F8F8F2\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #BD93F9; font-style: italic\">$this<\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #F8F8F2\">paymentService <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">new<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD; font-style: italic\">PaymentService<\/span><span style=\"color: #F8F8F2\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">public<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">processOrder<\/span><span style=\"color: #F8F8F2\">($amount) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #6272A4\">\/\/ \u067e\u0631\u062f\u0627\u0632\u0634 \u0633\u0641\u0627\u0631\u0634<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #BD93F9; font-style: italic\">$this<\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #F8F8F2\">paymentService<\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #50FA7B\">processPayment<\/span><span style=\"color: #F8F8F2\">($amount); <\/span><span style=\"color: #6272A4\">\/\/ \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0645\u0633\u062a\u0642\u06cc\u0645 \u0628\u0647 PaymentService<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u062f\u0631 \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644\u060c \u06a9\u0644\u0627\u0633 <code>OrderProcessor<\/code> \u0628\u0647 \u0634\u062f\u062a \u0628\u0647 <code>PaymentService<\/code> \u0648\u0627\u0628\u0633\u062a\u0647 \u0627\u0633\u062a:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0627\u06af\u0631 \u062a\u063a\u06cc\u06cc\u0631 \u06a9\u0648\u0686\u06a9\u06cc \u062f\u0631 <code>PaymentService<\/code> \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f\u060c \u0628\u0627\u06cc\u062f <code>OrderProcessor<\/code> \u0647\u0645 \u062a\u063a\u06cc\u06cc\u0631 \u06a9\u0646\u062f.<\/li>\n\n\n\n<li>\u0627\u06cc\u0646 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0634\u062f\u06cc\u062f \u0645\u0627\u0646\u0639 \u0627\u0632 \u0627\u06cc\u0646 \u0645\u06cc\u200c\u0634\u0648\u062f \u06a9\u0647 \u0628\u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0647\u200c\u0631\u0627\u062d\u062a\u06cc \u0633\u0631\u0648\u06cc\u0633\u200c\u0647\u0627\u06cc \u067e\u0631\u062f\u0627\u062e\u062a \u062f\u06cc\u06af\u0631 \u0631\u0627 \u0627\u0636\u0627\u0641\u0647 \u06cc\u0627 \u062c\u0627\u06cc\u06af\u0632\u06cc\u0646 \u06a9\u0646\u06cc\u062f.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u0645\u0639\u0627\u06cc\u0628 tight coupling:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u06a9\u0627\u0647\u0634 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u06cc<\/strong>: \u0628\u0627 tight coupling\u060c \u0627\u06af\u0631 \u0628\u062e\u0648\u0627\u0647\u06cc\u062f \u06cc\u06a9 \u0642\u0633\u0645\u062a \u0627\u0632 \u06a9\u062f \u0631\u0627 \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0647\u06cc\u062f\u060c \u0627\u062d\u062a\u0645\u0627\u0644\u0627\u064b \u0628\u0627\u06cc\u062f \u0628\u062e\u0634\u200c\u0647\u0627\u06cc \u0632\u06cc\u0627\u062f\u06cc \u0627\u0632 \u0633\u06cc\u0633\u062a\u0645 \u0631\u0627 \u0647\u0645 \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0647\u06cc\u062f.<\/li>\n\n\n\n<li><strong>\u0633\u062e\u062a\u200c\u062a\u0631 \u0634\u062f\u0646 \u062a\u0633\u062a \u0648 \u0627\u0634\u06a9\u0627\u0644\u200c\u0632\u062f\u0627\u06cc\u06cc<\/strong>: \u0628\u0647 \u062f\u0644\u06cc\u0644 \u0627\u06cc\u0646 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0634\u062f\u06cc\u062f\u060c \u062a\u0633\u062a \u0645\u0633\u062a\u0642\u0644 \u0647\u0631 \u062c\u0632\u0621 \u0633\u062e\u062a\u200c\u062a\u0631 \u0645\u06cc\u200c\u0634\u0648\u062f\u060c \u0686\u0648\u0646 \u0628\u062e\u0634\u200c\u0647\u0627\u06cc \u062f\u06cc\u06af\u0631 \u0633\u06cc\u0633\u062a\u0645 \u0647\u0645 \u0628\u0627\u06cc\u062f \u0628\u0627 \u0622\u0646 \u0647\u0645\u0627\u0647\u0646\u06af \u0628\u0627\u0634\u0646\u062f.<\/li>\n\n\n\n<li><strong>\u0642\u0627\u0628\u0644\u06cc\u062a \u0646\u06af\u0647\u062f\u0627\u0631\u06cc \u067e\u0627\u06cc\u06cc\u0646<\/strong>: \u0627\u0641\u0632\u0627\u06cc\u0634 \u067e\u06cc\u0686\u06cc\u062f\u06af\u06cc \u062f\u0631 \u0646\u06af\u0647\u062f\u0627\u0631\u06cc \u0648 \u0627\u0631\u062a\u0642\u0627 \u0646\u0631\u0645\u200c\u0627\u0641\u0632\u0627\u0631 \u0628\u0647 \u062f\u0644\u06cc\u0644 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc\u200c\u0647\u0627\u06cc \u0632\u06cc\u0627\u062f \u0648 \u06af\u0633\u062a\u0631\u062f\u0647.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u062c\u0644\u0648\u06af\u06cc\u0631\u06cc \u0627\u0632 tight coupling:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u06cc\u06a9\u06cc \u0627\u0632 \u0628\u0647\u062a\u0631\u06cc\u0646 \u0631\u0648\u0634\u200c\u0647\u0627 \u0628\u0631\u0627\u06cc \u062c\u0644\u0648\u06af\u06cc\u0631\u06cc \u0627\u0632 tight coupling \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 <strong>Dependency Injection<\/strong> \u0648 <strong>Interface Segregation<\/strong> \u0627\u0633\u062a. \u0628\u0627 \u0627\u06cc\u0646 \u06a9\u0627\u0631\u060c \u06a9\u0644\u0627\u0633\u200c\u0647\u0627 \u0628\u0647 \u062c\u0627\u06cc \u0627\u06cc\u0646\u200c\u06a9\u0647 \u0645\u0633\u062a\u0642\u06cc\u0645\u0627\u064b \u0628\u0647 \u0647\u0645 \u0648\u0627\u0628\u0633\u062a\u0647 \u0628\u0627\u0634\u0646\u062f\u060c \u0628\u0647 \u06cc\u06a9 \u0631\u0627\u0628\u0637 (interface) \u06cc\u0627 \u0633\u0631\u0648\u06cc\u0633 \u0627\u0646\u062a\u0632\u0627\u0639\u06cc \u0648\u0627\u0628\u0633\u062a\u0647 \u0645\u06cc\u200c\u0634\u0648\u0646\u062f.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u0645\u062b\u0627\u0644 \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 Dependency Injection:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u062f\u0631 \u0645\u062b\u0627\u0644 \u0642\u0628\u0644\u06cc\u060c \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u0645 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0628\u0647 <code>PaymentService<\/code> \u0631\u0627 \u0627\u0632 \u0637\u0631\u06cc\u0642 \u062a\u0632\u0631\u06cc\u0642 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc (Dependency Injection) \u0645\u062f\u06cc\u0631\u06cc\u062a \u06a9\u0646\u06cc\u0645 \u0648 \u0627\u0632 \u06cc\u06a9 interface \u0628\u0631\u0627\u06cc \u06a9\u0627\u0647\u0634 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u0645:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"interface PaymentInterface {\n    public function processPayment($amount);\n}\n\nclass PaymentService implements PaymentInterface {\n    public function processPayment($amount) {\n        echo &quot;Payment of $amount processed.&quot;;\n    }\n}\n\nclass OrderProcessor {\n    private $paymentService;\n\n    public function __construct(PaymentInterface $paymentService) {\n        $this-&gt;paymentService = $paymentService;\n    }\n\n    public function processOrder($amount) {\n        $this-&gt;paymentService-&gt;processPayment($amount);\n    }\n}\n\n\/\/ \u062f\u0631 \u0628\u0631\u0646\u0627\u0645\u0647 \u0627\u0635\u0644\u06cc \u06cc\u0627 \u062a\u0633\u062a\n$paymentService = new PaymentService();\n$orderProcessor = new OrderProcessor($paymentService);\n$orderProcessor-&gt;processOrder(100);\n\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FF79C6\">interface<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD; font-style: italic\">PaymentInterface<\/span><span style=\"color: #F8F8F2\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">public<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">processPayment<\/span><span style=\"color: #F8F8F2\">($amount);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FF79C6\">class<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">PaymentService<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">implements<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD; font-style: italic\">PaymentInterface<\/span><span style=\"color: #F8F8F2\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">public<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">processPayment<\/span><span style=\"color: #F8F8F2\">($amount) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #8BE9FD\">echo<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #E9F284\">&quot;<\/span><span style=\"color: #F1FA8C\">Payment of <\/span><span style=\"color: #F8F8F2\">$amount<\/span><span style=\"color: #F1FA8C\"> processed.<\/span><span style=\"color: #E9F284\">&quot;<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FF79C6\">class<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">OrderProcessor<\/span><span style=\"color: #F8F8F2\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">private<\/span><span style=\"color: #F8F8F2\"> $paymentService;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">public<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">__construct<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #8BE9FD; font-style: italic\">PaymentInterface<\/span><span style=\"color: #F8F8F2\"> $paymentService) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #BD93F9; font-style: italic\">$this<\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #F8F8F2\">paymentService <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> $paymentService;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">public<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">processOrder<\/span><span style=\"color: #F8F8F2\">($amount) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #BD93F9; font-style: italic\">$this<\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #F8F8F2\">paymentService<\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #50FA7B\">processPayment<\/span><span style=\"color: #F8F8F2\">($amount);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6272A4\">\/\/ \u062f\u0631 \u0628\u0631\u0646\u0627\u0645\u0647 \u0627\u0635\u0644\u06cc \u06cc\u0627 \u062a\u0633\u062a<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">$paymentService <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">new<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD; font-style: italic\">PaymentService<\/span><span style=\"color: #F8F8F2\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">$orderProcessor <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6\">new<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD; font-style: italic\">OrderProcessor<\/span><span style=\"color: #F8F8F2\">($paymentService);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">$orderProcessor<\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #50FA7B\">processOrder<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #BD93F9\">100<\/span><span style=\"color: #F8F8F2\">);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u062f\u0631 \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u06a9\u0644\u0627\u0633 <code>OrderProcessor<\/code> \u062f\u06cc\u06af\u0631 \u0628\u0647 <code>PaymentService<\/code> \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0645\u0633\u062a\u0642\u06cc\u0645 \u0646\u062f\u0627\u0631\u062f \u0648 \u0628\u0647 \u062c\u0627\u06cc \u0622\u0646 \u0627\u0632 <code>PaymentInterface<\/code> \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/li>\n\n\n\n<li>\u0627\u06cc\u0646 \u0628\u0627\u0639\u062b \u0645\u06cc\u200c\u0634\u0648\u062f \u06a9\u0647 \u0628\u062a\u0648\u0627\u0646\u06cc\u062f \u0647\u0631 \u0633\u0631\u0648\u06cc\u0633 \u067e\u0631\u062f\u0627\u062e\u062a \u062f\u06cc\u06af\u0631\u06cc \u06a9\u0647 \u0627\u0632 <code>PaymentInterface<\/code> \u067e\u06cc\u0631\u0648\u06cc \u0645\u06cc\u200c\u06a9\u0646\u062f \u0631\u0627 \u0628\u062f\u0648\u0646 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0631 <code>OrderProcessor<\/code> \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u0646\u062a\u06cc\u062c\u0647\u200c\u06af\u06cc\u0631\u06cc:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Tight coupling<\/strong> \u0628\u0627\u0639\u062b \u06a9\u0627\u0647\u0634 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u06cc \u0648 \u0633\u062e\u062a\u200c\u062a\u0631 \u0634\u062f\u0646 \u0646\u06af\u0647\u062f\u0627\u0631\u06cc \u06a9\u062f \u0645\u06cc\u200c\u0634\u0648\u062f. \u0628\u0631\u0627\u06cc \u0628\u0647\u0628\u0648\u062f \u0627\u06cc\u0646 \u0648\u0636\u0639\u06cc\u062a\u060c \u0628\u0627\u06cc\u062f \u0627\u0632 \u062a\u06a9\u0646\u06cc\u06a9\u200c\u0647\u0627\u06cc\u06cc \u0645\u0627\u0646\u0646\u062f <strong>Dependency Injection<\/strong> \u0648 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 <strong>Interfaces<\/strong> \u0628\u0647\u0631\u0647 \u0628\u0628\u0631\u06cc\u062f \u062a\u0627 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0628\u06cc\u0646 \u0627\u062c\u0632\u0627\u06cc \u0633\u06cc\u0633\u062a\u0645 \u06a9\u0627\u0647\u0634 \u06cc\u0627\u0628\u062f \u0648 \u06a9\u062f \u0645\u0646\u0639\u0637\u0641\u200c\u062a\u0631 \u0648 \u0642\u0627\u0628\u0644 \u0646\u06af\u0647\u062f\u0627\u0631\u06cc\u200c\u062a\u0631 \u0634\u0648\u062f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0645\u0646\u0628\u0639: chatgpt Tight coupling (\u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0634\u062f\u06cc\u062f) \u0628\u0647 \u0648\u0636\u0639\u06cc\u062a\u06cc \u062f\u0631 \u0637\u0631\u0627\u062d\u06cc \u0646\u0631\u0645\u200c\u0627\u0641\u0632\u0627\u0631 \u0627\u0634\u0627\u0631\u0647 \u062f\u0627\u0631\u062f \u06a9\u0647 \u062f\u0631 \u0622\u0646 \u06a9\u0644\u0627\u0633\u200c\u0647\u0627 \u06cc\u0627 \u0645\u0627\u0698\u0648\u0644\u200c\u0647\u0627 \u0648\u0627\u0628\u0633\u062a\u06af\u06cc \u0632\u06cc\u0627\u062f\u06cc \u0628\u0647 \u06cc\u06a9\u062f\u06cc\u06af\u0631 \u062f\u0627\u0631\u0646\u062f\u060c \u0628\u0647 \u0637\u0648\u0631\u06cc \u06a9\u0647 \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0631 \u06cc\u06a9\u06cc \u0627\u0632 \u0622\u0646\u200c\u0647\u0627 \u0628\u0647\u200c\u0633\u0627\u062f\u06af\u06cc \u0628\u0631 \u0628\u0642\u06cc\u0647 \u062a\u0623\u062b\u06cc\u0631 \u0645\u06cc\u200c\u06af\u0630\u0627\u0631\u062f. \u062f\u0631 \u0627\u06cc\u0646 \u062d\u0627\u0644\u062a\u060c \u06a9\u0644\u0627\u0633\u200c\u0647\u0627 \u0628\u0631\u0627\u06cc \u0627\u0646\u062c\u0627\u0645 \u06a9\u0627\u0631\u0647\u0627\u06cc\u0634\u0627\u0646 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u062f\u0627\u0646\u0633\u062a\u0646 \u062c\u0632\u0626\u06cc\u0627\u062a \u0648 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc\u200c\u0647\u0627\u06cc \u062f\u0627\u062e\u0644\u06cc \u06cc\u06a9\u062f\u06cc\u06af\u0631 \u062f\u0627\u0631\u0646\u062f \u0648 \u0627\u0646\u0639\u0637\u0627\u0641\u200c\u067e\u0630\u06cc\u0631\u06cc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[5],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-php","tag-source_chatgpt"],"_links":{"self":[{"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techport.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=73"}],"version-history":[{"count":1,"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/techport.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techport.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techport.ir\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}