Programming with Objects and Classes/fr

From Free Pascal wiki
Jump to navigationJump to search

English (en) français (fr) русский (ru)

vue d'ensemble

FPC inclut plusieurs extensions de la langage à sa syntaxe Pascal "standard" pour supporter la programmation orientée objet.

Ces extensions sont décrites dans les chapitres indiqués du guide de référence du langage FPC: http://www.freepascal.org/docs.var. Des liens vers les pages de tutoriel pour chaque concept sont de même inclus ci-dessus. Le Guide de référence du langage comprend des diagrammes sur la syntaxe et d'autres détails ne figurant pas dans ce tutoriel d'introduction. Parmi les quatres caractéristiques du langage mentionnées ci-dessus, Objects et Classes forme la base de la programmation orientée objet (OOP) dans FPC et Lazarus. Pour les nouveaux avec l'OOP, le paragraphe Objects comprend plus d'introduction sur les concepts et le paragraphe Classes minimiser la répétition en mettant l'accent sur les similitudes et les différences avec la syntaxe Objects. En général, l'implémentation Classes semble être plus largement utilisée, y compris par les développeurs Delphi et Lazarus. Often the word "objects" is used to refer to what is actually a "class" in the Classes dialect of OOP in FPC. These documents will be worded to minimize any terminology confusion, but outside of this document, the term "object" oftentimes refers to objects created from a Class. In fact, the FPC run time library (RTL) includes a class library with a base class called TObject.

Users familiar with the older Turbo Pascal OOP implementation may initially want to skip the section on Classes since the Objects implementation is based on the older Turbo Pascal dialect. The section on Classes should be familiar to Delphi users since it is based on Delphi syntax. Be aware that some of the writeup in the Classes section may refer to concepts from the Objects section. For Macintosh developers familiar with the various Apple, THINK and MPW Object Pascal dialects, neither the FPC Objects or Classes dialects provide a direct migration path. As of March 2009, there are discussions on the Mac Pascal Mailing list about potentially providing some compiler support (new syntax) for accessing Apple's Objective C / Cocoa framework.

General Concepts

OOP provides different ways to manage and encapsulate data and to manage program flow compared with other available programming language features and constructs. OOP often lends itself to modeling certain applications such as Graphic User Interfaces (GUI's) and physical systems in a more natural feeling manner. However OOP is not appropriate for all applications. Program control is not as explicit as the more basic Pascal procedural constructs. To obtain the most benefit from OOP, understanding of large class libraries is often required which can entail a steep learning curve. Maintaining large OOP application code has its advantages and disadvantages compared to maintaining strictly procedural code. There are many sources for learning OO analysis, design and programming techniques which are beyond the scope of this guide.

There are numerous programming languages which incorporate OOP features as extensions or the basis of their language. As such, there are many different terms for describing OO concepts. Even within FPC, some of the terminology overlaps. In general, OOP usually consists of the concept of a programming object (or information unit) which explicitly combines and encapsulates a related set of data and procedures which act on the data. This data is usually persistent during program execution but with mechanisms to reduce some of the problems inherent in declaring global variables. In addition, OOP languages enable objects to be incrementally modified and/or extended based on previously defined objects. This feature is usually referred to by the terms inheritance and polymorphism. Many OOP languages use the terms method or message referring to procedures which belong to an object. Much of the power of OOP is realized by late (run time) dynamic binding of methods rather than compile binding. This dynamic binding of methods is similar to using procedural variables and procedural parameters but with greater syntactic cohesion, encapsulation with the data it is related to and also inheritance of behavior of previously defined methods. The following wiki pages provide a starting point for discovering more about analysis, design and programming in an object orient manner.

http://en.wikipedia.org/wiki/Object-oriented_programming

http://en.wikipedia.org/wiki/OOAD

http://en.wikipedia.org/wiki/Object_oriented_design