IPF-1501 Primer control
En el primer control debiera entrar definiciones de objetos y sentencias de control. El profe subió los apuntes y libros a su blog (http://clasesduocuc.blogspot.com) pero deberían ser los siguientes;
Primera clase
Presentación del ramo, como van a ser las calificaciones, asistencia mínima y un par de ideas acerca de las definiciones que pueden entrar en el primer control.
Segunda clase
Estructuras de control y ciclos, tipos de datos, ciclo desarrollo del software, tipos de programación, etc.
Tercera Clase
Ciclo de Vida del Software
Hasta aquí debiera entrar en el primer control.
----------------------------------------------
Adicionalmente quiero dejar un libro para el que quiera revisar la definición de objetos, está en inglés, dejo el extracto de la página 13 a continuación, con las definiciones.
A Programmer´s Introduction to C# APress
What Is an Object?
An object is merely a collection of related information and functionality. An object can be something that has a corresponding real-world manifestation (such as an employee object), something that has some virtual meaning (such as a window on the screen), or just some convenient abstraction within a program (a list of work to be done, for example).
An object is composed of the data that describes the object and the operations that can be performed on the object. Information stored in an employee object, for example, might be various identification information (name, address), work information (job title, salary), and so on. The operations performed
might include creating an employee paycheck or promoting an employee.
When creating an object-oriented design, the first step is to determine what the objects are. When dealing with real-life objects, this is often straightforward, but when dealing with the virtual world, the boundaries become less clear. That’s where the art of good design shows up, and it’s why good architects are in such demand.
Inheritance
Inheritance is a fundamental feature of an object-oriented system, and it is simply the ability to inherit data and functionality from a parent object. Rather than developing new objects from scratch, new code can be based on the work of other programmers[1], adding only the new features that are needed. The parent object that the new work is based upon is known as a base class, and the child object is known as a derived class.
Inheritance gets a lot of attention in explanations of object-oriented design, but the use of inheritance isn’t particularly widespread in most designs. There are several reasons for this.
First, inheritance is an example of what is known in object-oriented design as an “is-a” relationship. If a system has an animal object and a cat object, the cat object could inherit from the animal object, because a cat "is-a" animal. In inheritance, the base class is always more generalized than the derived class. The cat class would inherit the eat function from the animal class, and would have an enhanced sleep function. In real-world design, such relationships aren’t particularly common.
Second, to use inheritance, the base class needs to be designed with inheritance in mind. This is important for several reasons. If the objects don’t have the proper structure, inheritance can’t really work well. More importantly, a design that enables inheritance also makes it clear that the author of the base class is willing to support other classes inheriting from the class. If a new class is inherited from a class where this isn’t the case, the base class might at some point change, breaking the derived class.
Some less-experienced programmers mistakenly believe that inheritance is “supposed to be” used widely in object-oriented programming, and therefore use it far too often. Inheritance should only be used when the advantages that it brings are needed[2]. See the coming section on “Polymorphism and Virtual Functions.”
Containment
So, if inheritance isn’t the right choice, what is?
The answer is containment, also known as aggregation. Rather than saying that an object is an example of another object, an instance of that other object will be contained inside the object. So, instead of having a class look like a string, the class will contain a string (or array, or hash table).
The default design choice should be containment, and you should switch to inheritance only if needed (i.e., if there really is an “is-a” relationship).
No hay comentarios:
Publicar un comentario