You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-23Lines changed: 10 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2078,26 +2078,13 @@ class Manager
2078
2078
2079
2079
Try to observe the [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) principle.
2080
2080
2081
-
Do your absolute best to avoid duplicate code. Duplicate code is bad because
2082
-
it means that there's more than one place to alter something if you need to
2083
-
change some logic.
2084
-
2085
-
Imagine if you run a restaurant and you keep track of your inventory: all your
2086
-
tomatoes, onions, garlic, spices, etc. If you have multiple lists that
2087
-
you keep this on, then all have to be updated when you serve a dish with
2088
-
tomatoes in them. If you only have one list, there's only one place to update!
2089
-
2090
-
Often you have duplicate code because you have two or more slightly
2091
-
different things, that share a lot in common, but their differences force you
2092
-
to have two or more separate functions that do much of the same things. Removing
2093
-
duplicate code means creating an abstraction that can handle this set of different
2094
-
things with just one function/module/class.
2095
-
2096
-
Getting the abstraction right is critical, that's why you should follow the
2097
-
SOLID principles laid out in the [Classes](#classes) section. Bad abstractions can be
2098
-
worse than duplicate code, so be careful! Having said this, if you can make
2099
-
a good abstraction, do it! Don't repeat yourself, otherwise you'll find yourself
2100
-
updating multiple places any time you want to change one thing.
2081
+
ডুপ্লিকেট কোড এড়ানোর জন্য সব সময় ই চেষ্টা করা উচিত। ডুপ্লিকেট কোড খারাপ কারণ হল যে আপনার যদি কোন কিছু পরিবর্তন করতে হয় তাহলে যত জায়গায় ডুপ্লিকেট কোড লিখেছেন সব জাইগায় ই পরিবর্তন করতে হবে।
2082
+
2083
+
মনে করেন আপনি একটা রেস্টুরেন্ট চালাচ্ছেন এবং আপনার সব ইনভেন্টরি এর হিসাব রাখতে হয়: টমাটো, পেয়াজ, রসুন, মরিচ ইত্যাদি। এখন যদি এই ইনভেন্টরি এর জন্য আলাদা আলাদা লিস্ট করেন তাহলে প্রতি বার ই আপনার সবগুলো লিস্ট আপডেট করতে হবে যদি কোন লিস্ট আপডেট করতে ভুলে যান তাহলে আপনার হিসাব ও ভুল হয়ে যাবে। কিন্তু যদি শুধু একটা লিস্ট থাকত তাহলে কত সহজেই কাজ হয়ে যেত শুদু মাত্র একটা জায়গায় তেই পরিবর্তন এর মাধ্যমে।
2084
+
2085
+
যদি এমন হয় যে আপনার ডুপ্লিকেট কোড করার কারণ হল আপনার কাছে ২ টা আলাদা জিনিষ আছে কিন্তু সেখানে কিছু জিনিস একই রকম যেটা আপনাকে ফোর্স করতেছে আলাদা ভাবে কোড করার জন্য। তাহলে আপনি ওই আলদা জিনিসগুলো আলাদা ভাবে abstraction করে জিনিসটা হান্ডেল করতে পারেন আর এর জন্য ওই আলাদা জিনিষ গুলো একটা function/module/class এ নিয়ে কাজ করতে পারেন তাহলে এই function/module/class আপনি অন্য কোথায় লাগলে সেখানে ব্যাবহার করতে পারবেন।
2086
+
2087
+
abstraction করা আসলে একটুখানি কঠিন এর জন্য আপনার উচিত হবে SOLID principles এর [Classes](#classes) section তা ফলো করা। কারণ খারাপ abstraction ডুপ্লিকেট কোড এর থেকেও বেশি খারাপ, তাই আপনাকে এই বিষয়ে অবশ্যই সাবধান হতে হবে।
2101
2088
2102
2089
**খারাপ:**
2103
2090
@@ -2145,7 +2132,7 @@ function showList(array $employees): void
2145
2132
2146
2133
**Very good:**
2147
2134
2148
-
It is better to use a compact version of the code.
2135
+
কোড এর কম্প্যাক্ট ভার্সন ব্যাবহার করা সবসময় ভাল।
2149
2136
2150
2137
```php
2151
2138
function showList(array $employees): void
@@ -2160,9 +2147,9 @@ function showList(array $employees): void
0 commit comments