Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/feed-rss2-comments.php on line 8
Comments on: বুলিয়ানোলজি, বিড়ম্বনা ও শিক্ষা (Branching with if(condition) ; should have at lease one else statement) https://blog.ujjal.net/?p=372&utm_source=rss&utm_medium=rss&utm_campaign=%25e0%25a6%25ac%25e0%25a7%2581%25e0%25a6%25b2%25e0%25a6%25bf%25e0%25a7%259f%25e0%25a6%25be%25e0%25a6%25a8%25e0%25a7%2587%25e0%25a6%25be%25e0%25a6%25b2%25e0%25a6%259c%25e0%25a6%25bf-%25e0%25a6%25ac%25e0%25a6%25bf%25e0%25a7%259c%25e0%25a6%25ae%25e0%25a7%258d%25e0%25a6%25ac%25e0%25a6%25a8%25e0%25a6%25be-%25e0%25a6%2593 Software Development Lead, Very good listener, Tech enthusiastic, Movie & Series freak Sat, 14 Apr 2018 19:09:18 +0000 hourly 1 https://wordpress.org/?v=6.2.6 By: ujjal https://blog.ujjal.net/?p=372#comment-32 Sat, 03 Sep 2016 11:59:05 +0000 http://blog.ujjal.net/?p=372#comment-32 In reply to Md. Minhazul Haque.

I just found that I was not clear enough to describe the situation here. Let me explain again. I am going to take your code snippet as an example here:

[code=”pseoducode”]
function init(){
branch = “master”
}
function updateBranchName(string newName)
{
if not isempty(newName)
branch = newName
}

int main() {
init();
updateBranchName(“master/add-option-for-select-icons-in-pref”);
updateBranchName(“”); // updateBranchName will be called from different seprate thread.
return 0;
}
[/code]

As you have written, the initialization was in the same method. That is a good approach obviously. But my situation arrived when initialization was in separate method. Yes, what you have suggested is the best approach and we should always follow that one. So, both of following two approach are ok.

[code = “approach1”]
function updateBranchName(string newName)
{
branch = master
if not isempty(newName)
branch = newName
}
[code]

[code = “approach2”]
function updateBranchName(string newName)
{
branch = string.empty;
if not isempty(newName)
branch = newName
else
branch = master
}
[code]

]]>
By: Md. Minhazul Haque https://blog.ujjal.net/?p=372#comment-31 Sun, 21 Aug 2016 12:27:07 +0000 http://blog.ujjal.net/?p=372#comment-31 দুটা উদাহরণই মজার। বিশেষ করে ২য়টা। তবে অনেক ক্ষেত্রে আমি এইরকম কাজ করি।

branch = “master”
if not isempty(argv[1])
branch = argv[1]

অর্থাৎ কাস্টম প্যারামিটার দিলে branch এর ভ্যালু বদলাবে, নাতো master ই থাকবে। এটা মানছি যে else ব্লক দিলে রিডেবল বেশী হবে এবং এরর হবার চান্স কম। কিন্তু সেক্ষেত্রে branch এর ভ্যালু অযথা ২য়বার সেট হচ্ছেনা? অথবা এরকম করা যেতে পারে।

branch =

if not isempty(argv[1])
branch = argv[1]
else
branch = “master”

এখানে শুরুতে ভেরিয়েবল জাস্ট ডিক্লেয়ার হবে, পরে ভ্যালু সেট করলাম। আপনারা বাস্তবে প্রজেক্টের ক্ষেত্রে এইরকম সিচুয়েশনে কি স্টেপ ফলো করেন জানালে উপকৃত হব।

]]>