Khác biệt giữa bản sửa đổi của “Lập trình tổng quát”
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 |
| 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 |
| 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 == |
||
{{ |
{{tham khảo}} |
||
== Trích dẫn == |
== Trích dẫn == |
||
{{refbegin}} |
{{refbegin}} |
||
* {{ |
* {{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}} |
||
* {{ |
* {{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 |
* [[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 |
* 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
Mẫu hình lập trình |
---|
|
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++ và 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
- en:Concept (generic programming)
- en:Partial evaluation
- en:Template metaprogramming
- Đa hình (khoa học máy tính)
Tham khảo
- ^ 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.
- ^ 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) - ^ 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
- Musser, D. R.; Stepanov, A. A. (1989). “Generic programming”. Trong P. Gianni (biên tập). Symbolic and Algebraic Computation: International symposium ISSAC 1988. Lecture Notes in Computer Science. 358. tr. 13–25. doi:10.1007/3-540-51084-2_2. ISBN 978-3-540-51084-0.Quản lý CS1: ref=harv (liên kết)
- Stroustrup, Bjarne (2007). Evolving a language in and for the real world: C++ 1991-2006 (PDF). ACM HOPL 2007.
- Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1994). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley. ISBN 0-201-63361-2.
Đọ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
- generic-programming.org
- Alexander A. Stepanov, Collected Papers of Alexander A. Stepanov (creator of the STL)
- C++/D
- Walter Bright, Templates Revisited.
- David Vandevoorde, Nicolai M Josuttis, C++ Templates: The Complete Guide, 2003 Addison-Wesley. ISBN 0-201-73484-2
- C#/.NET
- Jason Clark, "Introducing Generics in the Microsoft CLR," September 2003, MSDN Magazine, Microsoft.
- Jason Clark, "More on Generics in the Microsoft CLR," October 2003, MSDN Magazine, Microsoft.
- M. Aamir Maniar, Generics.Net. An open source generics library for C#.
- Delphi/Object Pascal
- Nick Hodges, "Delphi 2009 Reviewers Guide," October 2008, CodeGear Developer Network, CodeGear.
- Craig Stuntz, "Delphi 2009 Generics and Type Constraints," October 2008
- Dr. Bob, "Delphi 2009 Generics"
- Free Pascal: Free Pascal Reference guide Chapter 8: Generics, Michaël Van Canneyt, 2007
- Delphi for Win32: Generics with Delphi 2009 Win32, Sébastien DOERAENE, 2008
- Delphi for.NET: Delphi Generics, Felix COLIBRI, 2008
- Eiffel
- Haskell
- Johan Jeuring, Sean Leather, José Pedro Magalhães, and Alexey Rodriguez Yakushev. Libraries for Generic Programming in Haskell. Utrecht University.
- Dæv Clarke, Johan Jeuring and Andres Löh, The Generic Haskell user's guide
- Ralf Hinze, "Generics for the Masses," In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP), 2004.
- Simon Peyton Jones, editor, The Haskell 98 Language Report, Revised 2002.
- Ralf Lämmel and Simon Peyton Jones, "Scrap Your Boilerplate: A Practical Design Pattern for Generic Programming," In Proceedings of the ACM SIGPLAN International Workshop on Types in Language Design and Implementation (TLDI'03), 2003. (Also see the website devoted to this research)
- Andres Löh, Exploring Generic Haskell, Ph.D. thesis, 2004 Utrecht University. ISBN 90-393-3765-9
- Generic Haskell: a language for generic programming
- Java
- Gilad Bracha, Generics in the Java Programming Language, 2004.
- Maurice Naftalin and Philip Wadler, Java Generics and Collections, 2006, O'Reilly Media, Inc. ISBN 0-596-52775-6
- Peter Sestoft, Java Precisely, Second Edition, 2005 MIT Press. ISBN 0-262-69325-9
- Bản mẫu:Javadoc:SE-guide, 2004 Sun Microsystems, Inc.
- Angelika Langer, Java Generics FAQs