Khác biệt giữa bản sửa đổi của “Lập trình tổng quát”

Bách khoa toàn thư mở Wikipedia
Nội dung được xóa Nội dung được thêm vào
Dịch từ bài viết Anh
 
AlphamaEditor, Executed time: 00:00:07.0032243 using AWB
Dòng 2: Dòng 2:


'''Lập trình tổng quát''' (tiếng Anh: ''generic programming'') là một dạng [[lập trình máy tính]] mà trong đó [[thuật toán]] được viết theo cách [[kiểu dữ liệu|kiểu]] ''được-xác-định-sau'' và sau đó được ''khởi tạo'' (''instantiate'') nếu cần cho một kiểu cụ thể mà được cung cấp như [[Tham số (khoa học máy tính)|tham số]]. Cách tiếp cận này, được tiên phong bởi [[ML (ngôn ngữ lập trình)|ML]] vào năm 1973,<ref name="Lee2008">
'''Lập trình tổng quát''' (tiếng Anh: ''generic programming'') là một dạng [[lập trình máy tính]] mà trong đó [[thuật toán]] được viết theo cách [[kiểu dữ liệu|kiểu]] ''được-xác-định-sau'' và sau đó được ''khởi tạo'' (''instantiate'') nếu cần cho một kiểu cụ thể mà được cung cấp như [[Tham số (khoa học máy tính)|tham số]]. Cách tiếp cận này, được tiên phong bởi [[ML (ngôn ngữ lập trình)|ML]] vào năm 1973,<ref name="Lee2008">
{{chú thích sách
{{cite book
| last=Lee
| last=Lee
| first=Kent D.
| first=Kent D.
| title=Programming Languages: An Active Learning Approach
| title=Programming Languages: An Active Learning Approach
| url=https://books.google.com/books?id=OuW5dC2O99AC&pg=PA9
| url=https://books.google.com/books?id=OuW5dC2O99AC&pg=PA9
| date=15 December 2008
| date=ngày 15 tháng 12 năm 2008
| publisher=Springer Science & Business Media
| publisher=Springer Science & Business Media
| isbn=978-0-387-79422-8
| isbn=978-0-387-79422-8
| pages=9–10}}</ref><ref>{{cite conference | title=A Logic for Computable Functions with Reflexive and Polymorphic Types | accessdate=15 October 2016 |author1=Milner, R. |author2=Morris, L. |author3=Newey, M. | booktitle=Proceedings of the Conference on Proving and Improving Programs | year=1975}}</ref> cho phép viết các [[chương trình con|hàm]] hay [[kiểu dữ liệu|kiểu]] chung mà chỉ khác nhau ở tập các kiểu mà chúng dùng, do vậy giảm thiểu được [[trùng lặp mã|sự trùng lặp]]. Các thực thể phần mềm như vậy gọi là ''generic'' trong [[Ada (ngôn ngữ lập trình)|Ada]], [[C Sharp (ngôn ngữ lập trình)|C#]], [[Delphi (ngôn ngữ lập trình)|Delphi]], [[Eiffel (ngôn ngữ lập trình)|Eiffel]], [[F Sharp (ngôn ngữ lập trình)|F#]], [[Java (ngôn ngữ lập trình)|Java]], [[Objective-C]], [[Rust (ngôn ngữ lập trình)|Rust]], [[Swift (ngôn ngữ lập trình)|Swift]], và [[Visual Basic .NET]]. Chúng còn được gọi là ''[[đa hình tham số]]'' (''parametric polymorphism'') trong [[ML (ngôn ngữ lập trình)|ML]], [[Scala (ngôn ngữ lập trình)|Scala]], [[Haskell (ngôn ngữ lập trình)|Haskell]] (cộng đồng Haskell cũng sử dụng thuật ngữ "generic" cho khái niệm liên quan nhưng với ý nghĩa hơi khác biệt) và [[Julia (ngôn ngữ lập trình)|Julia]]; ''[[Template (C++)|template]]'' trong [[C++]] và [[D (ngôn ngữ lập trình)|D]]; và ''kiểu tham số'' (''parameterized type'') trong cuốn sách có nhiều ảnh hưởng năm 1994 ''[[Design Patterns (sách)|Design Patterns]]''.<ref name="GoF">
| pages=9–10}}</ref><ref>{{cite conference | title=A Logic for Computable Functions with Reflexive and Polymorphic Types | accessdate=ngày 15 tháng 10 năm 2016 |author1=Milner, R. |author2=Morris, L. |author3=Newey, M. | booktitle=Proceedings of the Conference on Proving and Improving Programs | year=1975}}</ref> cho phép viết các [[chương trình con|hàm]] hay [[kiểu dữ liệu|kiểu]] chung mà chỉ khác nhau ở tập các kiểu mà chúng dùng, do vậy giảm thiểu được [[trùng lặp mã|sự trùng lặp]]. Các thực thể phần mềm như vậy gọi là ''generic'' trong [[Ada (ngôn ngữ lập trình)|Ada]], [[C Sharp (ngôn ngữ lập trình)|C#]], [[Delphi (ngôn ngữ lập trình)|Delphi]], [[Eiffel (ngôn ngữ lập trình)|Eiffel]], [[F Sharp (ngôn ngữ lập trình)|F#]], [[Java (ngôn ngữ lập trình)|Java]], [[Objective-C]], [[Rust (ngôn ngữ lập trình)|Rust]], [[Swift (ngôn ngữ lập trình)|Swift]], và [[Visual Basic.NET]]. Chúng còn được gọi là ''[[đa hình tham số]]'' (''parametric polymorphism'') trong [[ML (ngôn ngữ lập trình)|ML]], [[Scala (ngôn ngữ lập trình)|Scala]], [[Haskell (ngôn ngữ lập trình)|Haskell]] (cộng đồng Haskell cũng sử dụng thuật ngữ "generic" cho khái niệm liên quan nhưng với ý nghĩa hơi khác biệt) và [[Julia (ngôn ngữ lập trình)|Julia]]; ''[[Template (C++)|template]]'' trong [[C++]] và [[D (ngôn ngữ lập trình)|D]]; và ''kiểu tham số'' (''parameterized type'') trong cuốn sách có nhiều ảnh hưởng năm 1994 ''[[Design Patterns (sách)|Design Patterns]]''.<ref name="GoF">
{{chú thích sách
{{cite book
| last1 = Gamma
| last1 = Gamma
| first1 = Erich
| first1 = Erich
Dòng 34: Dòng 34:


== Tham khảo ==
== Tham khảo ==
{{Reflist}}
{{tham khảo}}


== Trích dẫn ==
== Trích dẫn ==
{{refbegin}}
{{refbegin}}
* {{Cite book | last1 = Musser | first1 = D. R. | authorlink1 = David Musser | last2 = Stepanov | first2 = A. A. | authorlink2 = Alexander Stepanov| chapter = Generic programming | doi = 10.1007/3-540-51084-2_2 | title = Symbolic and Algebraic Computation: International symposium ISSAC 1988 | editor = P. Gianni | series = Lecture Notes in Computer Science | volume = 358 | pages = 13–25 | year = 1989 | isbn = 978-3-540-51084-0 | ref = harv }}
* {{chú thích sách | last1 = Musser | first1 = D. R. | authorlink1 = David Musser | last2 = Stepanov | first2 = A. A. | authorlink2 = Alexander Stepanov| chapter = Generic programming | doi = 10.1007/3-540-51084-2_2 | title = Symbolic and Algebraic Computation: International symposium ISSAC 1988 | editor = P. Gianni | series = Lecture Notes in Computer Science | volume = 358 | pages = 13–25 | year = 1989 | isbn = 978-3-540-51084-0 | ref = harv }}
* {{cite conference | url =http://www.research.att.com/~bs/hopl-almost-final.pdf |title=Evolving a language in and for the real world: C++ 1991-2006 |authorlink=Bjarne Stroustrup |last=Stroustrup |first=Bjarne |conference=ACM HOPL 2007 |year=2007}}
* {{cite conference | url =http://www.research.att.com/~bs/hopl-almost-final.pdf |title=Evolving a language in and for the real world: C++ 1991-2006 |authorlink=Bjarne Stroustrup |last=Stroustrup |first=Bjarne |conference=ACM HOPL 2007 |year=2007}}
* {{cite book |title=Design Patterns: Elements of Reusable Object-Oriented Software |first1=Erich |last1=Gamma |first2=Richard |last2=Helm|first3=Ralph |last3=Johnson |first4=John |last4=Vlissides |year=1994 |publisher=Addison-Wesley |isbn=0-201-63361-2 }}
* {{chú thích sách |title=Design Patterns: Elements of Reusable Object-Oriented Software |first1=Erich |last1=Gamma |first2=Richard |last2=Helm|first3=Ralph |last3=Johnson |first4=John |last4=Vlissides |year=1994 |publisher=Addison-Wesley |isbn=0-201-63361-2 }}
{{refend}}
{{refend}}


Dòng 50: Dòng 50:
| conference = Spring School on Datatype-Generic Programming 2006 | series = Lecture Notes in Computer Science | volume = 4719 | pages = 1–71
| conference = Spring School on Datatype-Generic Programming 2006 | series = Lecture Notes in Computer Science | volume = 4719 | pages = 1–71
| publisher = Springer | location = Heidelberg | year = 2007 }}
| publisher = Springer | location = Heidelberg | year = 2007 }}
* [[Bertrand Meyer]]. "[http://se.ethz.ch/~meyer/publications/acm/geninh.pdf Genericity vs Inheritance]." In ''OOPSLA (First ACM Conference on Object-Oriented Programming Systems, Languages and Applications),'' Portland (Oregon), 29 September–2 October 1986, pages 391–405.
* [[Bertrand Meyer]]. "[http://se.ethz.ch/~meyer/publications/acm/geninh.pdf Genericity vs Inheritance]." In ''OOPSLA (First ACM Conference on Object-Oriented Programming Systems, Languages and Applications),'' Portland (Oregon), 29 September–ngày 2 tháng 10 năm 1986, pages 391–405.


== Liên kết ngoài ==
== Liên kết ngoài ==
Dòng 71: Dòng 71:
* [[Free Pascal]]: [http://www.freepascal.org/docs-html/ref/refch8.html Free Pascal Reference guide Chapter 8: Generics], Michaël Van Canneyt, 2007
* [[Free Pascal]]: [http://www.freepascal.org/docs-html/ref/refch8.html Free Pascal Reference guide Chapter 8: Generics], Michaël Van Canneyt, 2007
* [[CodeGear Delphi|Delphi]] for Win32: [http://sjrd.developpez.com/delphi/tutoriel/generics/ Generics with Delphi 2009 Win32], Sébastien DOERAENE, 2008
* [[CodeGear Delphi|Delphi]] for Win32: [http://sjrd.developpez.com/delphi/tutoriel/generics/ Generics with Delphi 2009 Win32], Sébastien DOERAENE, 2008
* Delphi for .NET: [http://www.felix-colibri.com/papers/oop_components/delphi_generics_tutorial/delphi_generics_tutorial.html Delphi Generics], Felix COLIBRI, 2008
* Delphi for.NET: [http://www.felix-colibri.com/papers/oop_components/delphi_generics_tutorial/delphi_generics_tutorial.html Delphi Generics], Felix COLIBRI, 2008


;Eiffel
;Eiffel

Phiên bản lúc 12:00, ngày 15 tháng 6 năm 2017

Lập trình tổng quát (tiếng Anh: generic programming) là một dạng lập trình máy tính mà trong đó thuật toán được viết theo cách kiểu được-xác-định-sau và sau đó được khởi tạo (instantiate) nếu cần cho một kiểu cụ thể mà được cung cấp như tham số. Cách tiếp cận này, được tiên phong bởi ML vào năm 1973,[1][2] cho phép viết các hàm hay kiểu chung mà chỉ khác nhau ở tập các kiểu mà chúng dùng, do vậy giảm thiểu được sự trùng lặp. Các thực thể phần mềm như vậy gọi là generic trong Ada, C#, Delphi, Eiffel, F#, Java, Objective-C, Rust, Swift, và Visual Basic.NET. Chúng còn được gọi là đa hình tham số (parametric polymorphism) trong ML, Scala, Haskell (cộng đồng Haskell cũng sử dụng thuật ngữ "generic" cho khái niệm liên quan nhưng với ý nghĩa hơi khác biệt) và Julia; template trong C++D; và kiểu tham số (parameterized type) trong cuốn sách có nhiều ảnh hưởng năm 1994 Design Patterns.[3]

Xem thêm

Tham khảo

  1. ^ Lee, Kent D. (ngày 15 tháng 12 năm 2008). Programming Languages: An Active Learning Approach. Springer Science & Business Media. tr. 9–10. ISBN 978-0-387-79422-8.
  2. ^ Milner, R.; Morris, L.; Newey, M. (1975). A Logic for Computable Functions with Reflexive and Polymorphic Types. Đã bỏ qua tham số không rõ |booktitle= (trợ giúp); |ngày truy cập= cần |url= (trợ giúp)
  3. ^ Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1994). Design Patterns. Addison-Wesley. ISBN 0-201-63361-2.Quản lý CS1: ref=harv (liên kết)

Trích dẫn

Đọc thêm

  • Gabriel Dos Reis and Jaakko Järvi, What is Generic Programming?, LCSD 2005.
  • Gibbons, Jeremy (2007). Backhouse, R.; Gibbons, J.; Hinze, R.; Jeuring, J. (biên tập). Datatype-generic programming. Spring School on Datatype-Generic Programming 2006. Lecture Notes in Computer Science. 4719. Heidelberg: Springer. tr. 1–71. CiteSeerX 10.1.1.159.1228.
  • Bertrand Meyer. "Genericity vs Inheritance." In OOPSLA (First ACM Conference on Object-Oriented Programming Systems, Languages and Applications), Portland (Oregon), 29 September–ngày 2 tháng 10 năm 1986, pages 391–405.

Liên kết ngoài

C++/D
C#/.NET
Delphi/Object Pascal
Eiffel
Haskell
Java