Заглавная страница Избранные статьи Случайная статья Познавательные статьи Новые добавления Обратная связь FAQ Написать работу КАТЕГОРИИ: АрхеологияБиология Генетика География Информатика История Логика Маркетинг Математика Менеджмент Механика Педагогика Религия Социология Технологии Физика Философия Финансы Химия Экология ТОП 10 на сайте Приготовление дезинфицирующих растворов различной концентрацииТехника нижней прямой подачи мяча. Франко-прусская война (причины и последствия) Организация работы процедурного кабинета Смысловое и механическое запоминание, их место и роль в усвоении знаний Коммуникативные барьеры и пути их преодоления Обработка изделий медицинского назначения многократного применения Образцы текста публицистического стиля Четыре типа изменения баланса Задачи с ответами для Всероссийской олимпиады по праву Мы поможем в написании ваших работ! ЗНАЕТЕ ЛИ ВЫ?
Влияние общества на человека
Приготовление дезинфицирующих растворов различной концентрации Практические работы по географии для 6 класса Организация работы процедурного кабинета Изменения в неживой природе осенью Уборка процедурного кабинета Сольфеджио. Все правила по сольфеджио Балочные системы. Определение реакций опор и моментов защемления |
Text 10. Object-oriented Programming↑ ⇐ ПредыдущаяСтр 3 из 3 Содержание книги
Поиск на нашем сайте
Words and phrases to the text: 1. encapsulation (n) a key feature of object-oriented programming that bundles data and program instructions into modules called objects 2. polymorphism (n) a key feature of OOP programming by which different objects can receive the same instructions but deal with them in different ways
One of the principal motivations for using OOP is to handle multimedia applications in which such diverse data types as sound and video can be packaged together into executable modules. Another is writing program code that's more intuitive and reusable; in other words, code that shortens program-development time. Perhaps the key feature of OOP is encapsulation - bundling data and program instructions into modules called 'objects'. Here's an example of how objects work. An icon on a display screen might be called 'Triangles'. When the user selects the Triangles icon - which is an object composed of the properties of triangles and other data and instructions - a menu might appear on the screen offering several choices. The choices may be (1) create a new triangle and (2) fetch a triangle already in storage. The menu, too, is an object, as are the choices on it. Each time a user selects an object, instructions inside the object are executed with whatever properties or data the object holds, to get to the next step. For instance, when the user wants to create a triangle, the application might execute a set of instructions that displays several types of triangles - right, equilateral, isosceles, and so on. Many industry observers feel that the encapsulation feature of OOP is the natural tool for complex applications in which speech and moving images are integrated with text and graphics. With moving images and voice built into the objects themselves, program developers avoid the sticky problem of deciding how each separate type of data is to be integrated and synchronized into a working whole. A second key feature of OOP is inheritance. This allows OOP developers to define one class of objects, say 'Rectangles', and a specific instance of this class, say 'Squares' (a rectangle with equal sides). Thus, all properties of rectangles - 'Has 4 sides' and 'Contains 4 right angles' are the two shown here - are automatically inherited by Squares. Inheritance is a useful property in rapidly processing business data. For instance, consider a business that has a class called 'Employees at the Dearborn Plant' and a specific instance of this class, 'Welders'. If employees at the Dearborn plant are eligible for a specific benefits package, welders automatically qualify for the package. If a welder named John Smith is later relocated from Dearborn to Birmingham, Alabama, where a different benefits package is available, revision is simple. An icon representing John Smith - such as John Smith’s face-can be selected on the screen and dragged with a mouse to an icon representing the Birmingham plant. He then automatically 'inherits' the Birmingham benefit package. A third principle behind OOP is polymorphism. This means that different objects can receive the same instructions but deal with them in different ways. For instance, consider again the triangles example. If the user right clicks the mouse on 'Right triangle', a voice clip might explain the properties of right triangles. However, if the mouse is right clicked on 'Equilateral triangle' the voice instead explains properties of equilateral triangles. The combination of encapsulation, inheritance and polymorphism leads to code reusability. 'Reusable code' means that new programs can easily be copied and pasted together from old programs. All one has to do is access a library of objects and stitch them into a working whole. This eliminates the need to write code from scratch and then debug it. Code reusability makes both program development and program maintenance faster. Comprehension check
|
||||
Последнее изменение этой страницы: 2016-12-17; просмотров: 948; Нарушение авторского права страницы; Мы поможем в написании вашей работы! infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 3.144.105.101 (0.008 с.) |