關於傳值(Pass by value),以及傳參(Pass by reference),其實,是常見於C++圈子的名詞,曾在Java圈嘈嚷過一段時間,而沉寂一陣之後,近來,我發現類似的爭議,在JavaScript圈復出了。
於是,此時又引出了一個更古老的名詞Call by sharing說選我正解,但這不是用明朝的劍斬清朝的官嗎?
同時也有3部Youtube影片,追蹤數超過12萬的網紅prasertcbs,也在其Youtube影片中提到,สาธิตการเขียนฟังก์ชันเพื่อแยกราคารวมของสินค้าออกเป็นราคาและภาษีมูลค่าเพิ่ม โดยแสดงให้เห็นถึงวิธีการเขียนฟังก์ชันโดยใช้ 1) pass by pointer 2) pass by r...
「java pass by reference」的推薦目錄:
- 關於java pass by reference 在 iThome Facebook 的最讚貼文
- 關於java pass by reference 在 โปรแกรมเมอร์ไทย Thai programmer Facebook 的最佳解答
- 關於java pass by reference 在 โปรแกรมเมอร์ไทย Thai programmer Facebook 的精選貼文
- 關於java pass by reference 在 prasertcbs Youtube 的精選貼文
- 關於java pass by reference 在 prasertcbs Youtube 的最讚貼文
- 關於java pass by reference 在 prasertcbs Youtube 的精選貼文
- 關於java pass by reference 在 Passing Arguments by Reference in Java - YouTube 的評價
- 關於java pass by reference 在 Understanding JavaScript Pass By Value 的評價
java pass by reference 在 โปรแกรมเมอร์ไทย Thai programmer Facebook 的最佳解答
+++ access token คืออะไรใน facebook ++++
😋 ปกติ facebook เปิดให้เว็บ (รวมทั้งแอพ) ที่เราเขียนขึ้น
สามารถใช้ระบบ login ของ facebook ได้
ทำให้เว็บนั้นได้สิทธิเข้าถึงข้อมูลส่วนตัวของ user นั้นๆ บน facebook
....
Continue Reading+++ What is access token on Facebook ++++
😋 Facebook is usually open for web (including apps) that we write up.
Facebook login system can be used
Make that web access to user's personal information on Facebook.
.
And in many sites, we must have seen.
Just have an account on Facebook, you can log in.
No need to waste time. Fill out a new subscription.
:
In this post will quote
Using Facebook Login
Behind that success, Facebook will give away access token
So that any web can manage user login
:
Before talking about access token, let me go back to the age of 2534
When "Timberners-Lee" delivered the world's first website.
It's a common thing that human beings use to be.
:
❣ but my weaknesses.... is in the heart
Hey, it's not the weaknesses of the website.
Well it uses HTTP potocol
Which is stateless. Don't remember any status.
The meaning is that Server is very short of memory. Alzheimer's disease.
When it gets request from browser
I don't remember where it came from???
Who sent it, I can't remember anymore!!!!!
:
🤔 to solve this cuddle nha technically
He will give you a server to send session id (or session token)
Which session id is something we can't read and long
It will be sent to browser. Keep this in the cookie.
.
.. Wrong is not that cookie.. but cookies are text
Server will send session id to browser
Keep the value in cookies (keep text on browser side)
:
Programming time on server side
Like PHP when using session _ start ();
Will tell browser to collect session id in text photos such as
PHPSESSID=tqb4s5q7k25234eabbvs11dp02
(session id is a random code)
:
But if it's another language, it may be seen in other words.
E.g. JSSIONID (JAVA EE), PHPSESSID (PHP), and ASPSESSIONID (Microsoft ASP).
.
😉 Even here session id... may think it's a ID code.
:
From now on when users click on what on the web page
Browser will be kind.
Secretly sending this session id to server automatically
Make the server recover from Alzheimer's.
... I remember where the request sent this... yay yay
.
So if the request sent in
It has the same session id
It's considered the same friends.
(Computer vocabulary says these request is in the same SESSION)
.
What if it's not the same session id
It's considered that request is not the same people.
:
👉 Benefits of session id
Will be used in conjunction with login / logout mechanism
1) When user name XXX comes in, there will be a session id.
2) When another user name YY does login, there will be a session id as a different ID.
3) When both users do logout, it will expire session id.
:
Question if we went to wash all the cookies in browser what would happen?
- answer for session id will be gone.
- So who secretly login is holding this web? What is that... huhu
- I have to logout automatically for new login... So sad. Haha.
(server doesn't remember us anymore
Because browser doesn't send session id)
:
Session id sounds like good
😨 but using user / password to login will have disadvantage such as
1) Easy to hacker to sneak in session
To wear sesion id (Cross-Site Request Forgery: CSRF)
... Technically, let's not talk about it. Read it on the
2) It is a burden for server to remember the session id. What rights you have and remember other information of user etc.
3) If you want to give the same user, login different devices such as
Web is fine. Mobile phone is good... It will be more difficult. (I have to copy session)
4) and other disadvantage not mentioned
:
😘 but he has a technique to solve the way.
.
Well, use what's called "acces token"
To get access token
I have to login with user / password to exchange it.
... We have to stand in the cat before we get access token.
Then we can use it instead of login
.
Keep us from feeding user / password often
And each user will get access token. Different look alike.
When it's time for user to do logout, access token will expire immediately.
:
😙 Here access token may compare like a key
Or maybe you can see it as a ticket or a pass... It's up to the imagination.
Difference from session id is
1) access token will not be kept in cookies
2) access token will collect information that can be revealed.
e.g. user _ id, rights, expiration date
(Not a burden for server to remember these information)
:
If you use access token with login mechanism, you will see the advantages like
1) Prevent hacker from using session by Cross-Site Request Forgery (CSRF)
2) Can login from mobile phone and just use the same user.
Just giving away access token... It's like Facebook.
(Not stored in browser cookies)
3) The server can leave a hassle login / logout duty... Throw it to authenticate service outside.
4) Server doesn't need to take care of user information.
:
😀 Cut back to see login mechanism with facebook user / password
The concept is as shown in the photo that I posted. (as an example of php)
Simple summary
- user time login
- It will sneak a switch to Facebook to do login instead.
- Then Facebook will throw back access token to our web
- Then user will use it as a pass. No need to login again.
:
There are many types of access token of Facebook such as
-User Access Token
- App Access Token
- Page Access Token
-Client Token
Each type has different rights. I can't ask for deep.
:
👉 session id and access token all this story
It's a sweet, fragrant hacker. I like it very much.
If they can steal, they can wear a login user.
Then hacker will get all rights like user... done here
.
Except we logout
To make session id or access token expire
Then the hacker will be out of bogs.
:
In the user corner. Just login.
Don't mind access token behind the scenes
But if it's a #programmer, you need to be extra mindful.
Because even four feet know that the philosopher knows.
The biggest giant. Big brother like Facebook.
Still missed it. Let access token out so that it's a big news.
.
👌 So, programming
Let's be mindful about access token. Don't fall off.
Be safe from hakcker to the best
Good luck to all of you.
:
:
Written by Thai programmer thai programmer
:
+++++++++++++
Reference
1) https://developers.facebook.com/docs/php/howto/example_facebook_login?locale=th_TH
2) https://developers.facebook.com/docs/facebook-login/access-tokens?locale=th_THTranslated
java pass by reference 在 โปรแกรมเมอร์ไทย Thai programmer Facebook 的精選貼文
จากวิชาสอนเขียนโปรแกรมของเด็กม.1 เรื่องการเปลี่ยนค่าตัวแปรในโปรแกรม มีประเด็นน่าสนใจดีนะครับ
ในหลายภาษาเขียนโปรแกรม การเปลี่ยนค่าตัวแปร รวมทั้งการส่งค่าอากิวเมนต์ไปให้พารามิเตอร์ของฟังก์ชั่น (เวลาเรียกฟังก์ชั่น) จะมี 2 คอนเซปต์ได้แก่
1) ก็อปปี้ค่า (value) จากตัวแปรหนึ่งไปให้อีกตัวแปรโดยตรง
2) ก็อปปี้ค่า reference (หรือ pointer) จากตัวแปรหนึ่ง ไปให้อีกตัวแปรโดยตรง ...ส่งผลทำให้ตัวแปรทั้งสองชี้ไปยังข้อมูลก้อนเดียวกัน (อ็อบเจ็กต์)
(ถ้าเป็นการส่งค่าอากิวเมนต์ไปให้พารามิเตอร์ของฟังก์ชั่น ก็จะเรียกว่า pass by value กับ pass by reference ตามลำดับนั่นเอง)
คราวนี้ถ้าไปดูในตำราม.1 บทที่ 3 สอน Python ภาษานี้จะมองทุกอย่างเป็นอ็อบเจ็กต์หมด เช่น ตัวเลข ก็มองเป็นอ็อบเจกต์ เมื่อตัวแปรเก็บค่าตัวเลข ตัวแปรนั้นก็จะชี้ไปยังอ็อบเจ็กต์ตัวเลข เป็นต้น
**** ใน Python จึงไม่มีการเปลี่ยนแปลงค่าตัวแปร โดยการก็อปปี้ value แต่จะเป็นก็อบปี้ object reference (เติมคำว่า object นำหน้า)
การเปลี่ยนแปลงค่าตัวแปรทุกๆ อย่างใน Python จะเป็นการก็อปปี้ค่า object reference ไปให้ รวมทั้งตอนส่งค่าอากิวเมนต์ไปให้พารามิเตอร์ของฟังก์ชั่น (เวลาเรียกฟังก์ชั่น) ก็จะเป็นการก็อปปี้ค่า object reference ไปให้เช่นกัน
ซึ่ง Python เขาจะเรียกการส่งค่าอากิวเมนต์ไปให้ฟังก์ชั่นว่าเป็น "Call by Object Reference" มากกว่า ไม่ว่าจะส่งข้อมูลเป็นชนิดอะไรก็ตาม ถือเป็นอ็อบเจ็กต์หมด (ไม่ได้มีคอนเซปต์ pass by value กับ pass by reference แบบภาษาอื่น)
เพื่อให้เห็นภาพลองดูบทเรียนของเด็กม .1 ในบทที่ 3 กันดีกว่า (ตามที่เห็นในรูป)
##################
>>> c = 16 # บรรทัด 1
>>> print(c) # บรรทัด 2
16
>>> d = c # บรรทัด 4
>>> print(d) # บรรทัด 5
16
>>> d= 15 # บรรทัด 7
>>> print(d) # บรรทัด 8
15
###################
😁 จะขออธิบายคำสั่งข้างบนกัน
👉 บรรทัด 1-2:
c=16 คำสั่งนี้จะสร้างตัวแปร c แล้วกำหนดให้ชี้ไปยังจำนวนเต็ม 16 จากนั้นแสดงผลด้วยคำสั่ง print(c) ได้ตัวเลข 16 ออกมา
👉 บรรทัด 4-5:
d=c คำสั่งนี้จะสร้างตัวแปร d แล้วชี้ไปที่ตัวแปร c จึงทำให้ตัวแปร d ชี้ไปยังจำนวนเต็ม 16 จากนั้นแสดงผลด้วยคำสั่ง print(d) ได้ตัวเลข 16 ออกมา
**** ถึงตอนนี้ ตัวแปร c กับ d ชี้ไปยังเลข 16 ก้อนเดียวกัน (ใครที่เคยศึกษาภาษาอื่นมา อาจแปลกใจนิดหนึ่ง)
👉 บรรทัด 7-8:
d=15 คำสั่งนี้จะกำหนดให้ตัวแปร d ชี้ไปยังจำนวนเต็ม 15 เมื่อแสดงด้วยคำสั่ง print(d) จะแสดง 15 ออกมา
ตอนนี้ตัวแปร c กับ d ชี้ไปยังข้อมูลคนละก้อนกันแล้ว
----
ถ้าดูภาพประกอบจากหนังสือเรียนม.1 อธิบายชัดเจนดี
แต่ทว่าในตำราไม่ได้พูดเรื่องก็อปปี้ค่าด้วย value หรือ reference อะไรพวกนี้หรอกนะครับ แต่น้องๆ ก็รู้ไว้ใช่ว่าใส่บ่าแบกหาม
เพราะถ้าน้องๆ ไปเขียนภาษาอื่น เช่น java , c, c++ จะมีคอนเซปต์ดังกล่าว จะแตกต่างจาก python ในตำราเรียนนะครับ
อย่างในตำราเรียนเขียนว่า
"ค่าที่เก็บในตัวแปร" อาจพูดว่า "ค่าที่ตัวแปรชี้อยู่" เช่น
>>> a = 100
100 คือค่าที่เก็บในตัวแปร หรือพูดอีกอย่างว่า 100 คือค่าที่ตัวแปรชี้อยู่
(ความหมายเดียวกัน)
+++ข้อมูล++++
หนังสือ "วิทยาการคำนวณ" ชั้น ม .1 บทที่ 3
java pass by reference 在 prasertcbs Youtube 的精選貼文
สาธิตการเขียนฟังก์ชันเพื่อแยกราคารวมของสินค้าออกเป็นราคาและภาษีมูลค่าเพิ่ม โดยแสดงให้เห็นถึงวิธีการเขียนฟังก์ชันโดยใช้
1) pass by pointer
2) pass by reference
3) สร้าง struct โดยมี price และ vat เป็น member แล้วเขียนฟังก์ชันเพื่อให้ส่งค่ากลับมาเป็น struct
ดาวน์โหลดไฟล์ตัวอย่างได้ที่ ► https://goo.gl/qSfHSn
เชิญสมัครเป็นสมาชิกของช่องนี้ได้ที่ ► https://www.youtube.com/subscription_center?add_user=prasertcbs
playlist สอนภาษา C++ ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEfZwqM2KyCBcPTVsc6cU_i
playlist สอนภาษา C เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GHHgz0S1tSyIl7vkG0y105z
playlist สอนภาษา C# ► https://www.youtube.com/playlist?list=PLoTScYm9O0GE4trr-XPozJRwaY7V9hx8K
playlist สอนภาษา Java ► https://www.youtube.com/playlist?list=PLoTScYm9O0GF26yW0zVc2rzjkygafsILN
playlist สอนภาษา Python ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH4YQs9t4tf2RIYolHt_YwW
playlist สอนภาษาไพธอน Python OOP ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEIZzlTKPUiOqkewkWmwadW
playlist สอน Python 3 GUI ► https://www.youtube.com/playlist?list=PLoTScYm9O0GFB1Y3cCmb9aPD5xRB1T11y
playlist สอนภาษา PHP เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH_6LARFxozL_viEsXV2wgO
playlist สอนภาษา R เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GF6qjrRuZFSHdnBXD2KVICp

java pass by reference 在 prasertcbs Youtube 的最讚貼文
เนื้อหาแสดงถึงวิธีการประยุกต์ใช้ pass by reference โดยแสดงให้เห็นถึงการประยุกใช้ 3 กรณี อันได้แก่
1. การเขียนฟังก์ชัน swap(a, b) สำหรับสลับค่าของตัวแปร a และ b
2. การผ่าน string แบบ pass by reference เพื่อให้ฟังก์ชันทำการเปลี่ยนค่าสตริงที่ผ่านเข้าไป
3. การผ่าน vector ซึ่งเป็น container ที่เก็บค่าได้หลาย ๆ ค่าคล้าย ๆ กับอะเรย์ ไปให้พารามิเตอร์ของฟังก์ชัน เพื่อให้โค้ดภายในฟังก์ชันทำการเปลี่ยนแปลงค่าสมาชิกแต่ละตัวใน vector
ดาวน์โหลดไฟล์ตัวอย่างได้ที่ ► https://goo.gl/5cfCen
เชิญสมัครเป็นสมาชิกของช่องนี้ได้ที่ ► https://www.youtube.com/subscription_center?add_user=prasertcbs
playlist สอนภาษา C++ ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEfZwqM2KyCBcPTVsc6cU_i
playlist สอนภาษา C เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GHHgz0S1tSyIl7vkG0y105z
playlist สอนภาษา C# ► https://www.youtube.com/playlist?list=PLoTScYm9O0GE4trr-XPozJRwaY7V9hx8K
playlist สอนภาษา Java ► https://www.youtube.com/playlist?list=PLoTScYm9O0GF26yW0zVc2rzjkygafsILN
playlist สอนภาษา Python ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH4YQs9t4tf2RIYolHt_YwW
playlist สอนภาษาไพธอน Python OOP ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEIZzlTKPUiOqkewkWmwadW
playlist สอน Python 3 GUI ► https://www.youtube.com/playlist?list=PLoTScYm9O0GFB1Y3cCmb9aPD5xRB1T11y
playlist สอนภาษา PHP เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH_6LARFxozL_viEsXV2wgO
playlist สอนภาษา R เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GF6qjrRuZFSHdnBXD2KVICp

java pass by reference 在 prasertcbs Youtube 的精選貼文
เข้าใจความแตกต่างระหว่างการผ่านตัวแปรไปยังพารามิเตอร์ของฟังก์ชันแบบ pass by value และ pass by reference
pass by value จะเป็นการผ่านค่าไปยังพารามิเตอร์โดยที่ค่านั้นจะถูก copy ไปให้กับตัวแปรอีกตัวหนึ่งในฟังก์ชัน ซึ่งจะถูกเก็บในหน่วยความจำคนละที่กัน ซึ่งการผ่านแบบนี้จะเหมาะสำหรับการผ่านพารามิเตอร์ที่ไม่จำเป็นต้องมีการเปลี่ยนแปลงค่าภายในฟังก์ชัน เช่น ในฟังก์ชันหารากที่สองของตัวเลข เราจะทำการผ่านค่าตัวเลขที่ต้องการหารากที่สองไปให้กับฟังก์ชัน แล้วตัวฟังก์ชันจะนำค่านั้นไปหารากที่สองแล้วส่งค่ากลับมาทางฟังก์ชัน เป็นต้น
ส่วน pass by reference จะเป็นการผ่านค่าให้แก่พารามิเตอร์ของฟังก์ชัน โดย ตัวพารามิเตอร์ในฟังก์ชันจะอิงกับค่าในหน่วยความจำที่เก็บค่าข้อมูลตำแหน่งเดียวกับตัวแปรที่ส่งไปยังฟังก์ชัน ดังนั้นหากภายในฟังก์ชันมีการเปลี่ยนแปลงค่าของพารามิเตอร์ ก็จะส่งผลให้ค่าที่อยู่ในหน่วยความจำนั้นเปลี่ยนแปลงค่าไปด้วยเมื่อสิ้นสุดการใช้งานฟังก์ชัน ตัวอย่างของการ pass by reference ได้แก่ การสลับค่าตัวแปรสองตัว (swap values) เป็นต้น
ดาวน์โหลดไฟล์ตัวอย่างได้ที่ ► https://goo.gl/5LskJ4
เชิญสมัครเป็นสมาชิกของช่องนี้ได้ที่ ► https://www.youtube.com/subscription_center?add_user=prasertcbs
playlist สอนภาษา C++ ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEfZwqM2KyCBcPTVsc6cU_i
playlist สอนภาษา C เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GHHgz0S1tSyIl7vkG0y105z
playlist สอนภาษา C# ► https://www.youtube.com/playlist?list=PLoTScYm9O0GE4trr-XPozJRwaY7V9hx8K
playlist สอนภาษา Java ► https://www.youtube.com/playlist?list=PLoTScYm9O0GF26yW0zVc2rzjkygafsILN
playlist สอนภาษา Python ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH4YQs9t4tf2RIYolHt_YwW
playlist สอนภาษาไพธอน Python OOP ► https://www.youtube.com/playlist?list=PLoTScYm9O0GEIZzlTKPUiOqkewkWmwadW
playlist สอน Python 3 GUI ► https://www.youtube.com/playlist?list=PLoTScYm9O0GFB1Y3cCmb9aPD5xRB1T11y
playlist สอนภาษา PHP เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GH_6LARFxozL_viEsXV2wgO
playlist สอนภาษา R เบื้องต้น ► https://www.youtube.com/playlist?list=PLoTScYm9O0GF6qjrRuZFSHdnBXD2KVICp

java pass by reference 在 Understanding JavaScript Pass By Value 的美食出口停車場
This tutorial explains how JavaScript pass by value works and gives you some examples of passing primitive and reference variables to a function. ... <看更多>
java pass by reference 在 Passing Arguments by Reference in Java - YouTube 的美食出口停車場
Java Programming: Passing Arguments by Reference in Java ProgrammingTopics Discussed:1. Point ... ... <看更多>