Virtual inheritance and Vágner Love: Difference between pages

(Difference between pages)
Content deleted Content added
Shawn wiki (talk | contribs)
m Inheritance Concepts: - Partitioned fundamental from detailed concepts
 
No edit summary
 
Line 1:
{{Football player infobox
{{dubious}}
| playername = Vágner Love
| fullname = Vágner Silva de Souza
| nickname = Vágner Love
| height = 171 cm / 5' 7" |
| weight = 72 kg
| dateofbirth = {{birth date and age|1984|6|11}}
| cityofbirth = [[Rio de Janeiro]]
| countryofbirth = [[Brazil]]
| currentclub = [[PFC CSKA Moscow|CSKA Moscow]]
| clubnumber = 9
| position = [[Striker]] |
| years = 2002-2004<br/>2004-present
| clubs = [[Sociedade Esportiva Palmeiras|Palmeiras]]<br/>[[PFC CSKA Moscow|CSKA Moscow]]
| caps(goals) = 20 (11)<br/>67 (30)
| nationalyears = 2003-present
| nationalteam = [[Brazilian national football team|Brazil]]
| nationalcaps(goals) = 6 (2)
| pcupdate = [[28 May]] [[2007]]
| ntupdate = [[28 March]] [[2007]]
}}
 
'''Vágner Love''', real name '''Vágner Silva de Souza''', (born [[June 11]], [[1984]] in [[Rio de Janeiro]]) is a [[Brazil]]ian [[football (soccer)]] [[striker]] who currently plays for [[PFC CSKA Moskva|CSKA Moscow]].
'''Virtual inheritance''' is a special form of [[inheritance]] in [[object-oriented]] [[programming languages]].
 
==GeneralClub Career==
 
Vágner started his career with [[Sociedade Esportiva Palmeiras|Palmeiras]], he was a great aid in the 2003 season to help them return to the [[Campeonato Brasileiro Série A|Brazilian Série A]], the national first division (premier league). He was bought by [[PFC CSKA Moskva|CSKA Moscow]] in the summer of 2004, prior to their [[UEFA Champions League|Champions League]] Campaign, for an estimated 8 million dollars.
Virtual Inheritance (VI) is a fundamental feature of most [[object-oriented]]
languages. Virtual Inheritance allows for code elements in a derived object (the child) to be
used by the base object (the parent).
 
For over a year after his arrival at CSKA, rumors kept appearing that he did not want to stay in Moscow, and a transfer to [[Sport Club Corinthians Paulista|Corinthians]] in particular was hinted at numerous times. However these rumors have now subsided and Vágner has mentioned a number of times that he is fully committed to his contract and is looking forward to completing its full tenure. As of April 17th, he has scored 29 goals in 73 games, 17 of them in 38 [[Russian Premier League|Russian Premiership]] games. He scored the final goal that sealed CSKA's 3-1 victory in the [[2005]] [[UEFA Cup]] final over [[Sporting Clube de Portugal|Sporting Lisbon]] on [[Estádio José Alvalade|Sporting's home ground]] in [[Lisbon]]. Additionally to this [[UEFA Cup]] final, he has gone on to win the [[Russian Premier League]] title and [[Russian Cup]] in 2005, and the [[Russian Super Cup]] in 2006.
Virtual inheritance is used by a parent to specify methods, variables and other
code elements that must exist (be implemented) in the child.
 
Since in the background it is known that [[Roman Abramovich]]`s money brought him to Moscow, rumors are circulating claiming Vágner will sign for [[Chelsea F.C.|Chelsea]] in the near future.
A common use of Virtual Inheritance is when the parent specifies a method that must exist
However after CSKA's Championship title in 2005 they are qualified for the UEFA Champions League
in the child. In this case the child will 'do the work' (perform some function) when
and will probably stay at the [[Dynamo Stadium (Moscow)|Dynamo Stadium]], due to the fact that Manager [[Valery Gazzaev]] will have him in the starting squad alongside [[Jô]] or [[Ivica Olic]]. This because he is very fast and is considered as one of the most agile players in the world.
called upon by the parent.
 
==International Career==
====Specification Vs. Implementation====
 
Vágner was part of the [[Brazil National Football Team|Brazil]] squad that won the [[Copa America]] in [[Peru]] in 2004. but saw very little action for Brazil under coach [[Carlos Alberto Parreira]]. However, he was called up for the [[Seleção]] by the new manager [[Carlos Dunga]] together with his teammates [[Daniel Carvalho da Silva|Daniel Carvalho]] and [[Dudu Cearense]]. In his fourth game for the national team, against Wales, he scored his first goal. He has recently returned to [[Carlos Dunga]] [[Seleção]] after his impressive start to the season with [[PFC CSKA Moscow|CSKA Moscow]].
In Virtual Inheritance an inherited child method inherits ONLY the SPECIFICATION
of the method defined in the parent. As such the child is FORCED to IMPLEMENT
the functionality specified in the signature of the [[Method (programming)|abstract method]].
 
{{DEFAULTSORT:Vagner Love}}
Virtual Inheritance (VI) is contrasted with Implementation Inheritance (II)
[[Category:1984 births]]
where the child (the derived object) inherits an IMPLEMENTATION of a
[[Category:Afro-Brazilians]]
function defined by the parent (the base object).
[[Category:Living people]]
[[Category:Brazilian footballers]]
[[Category:CSKA Moscow footballers]]
[[Category:Sociedade Esportiva Palmeiras players]]
[[Category:Football (soccer) strikers]]
[[Category:Brazil international footballers]]
{{CSKA Moscow Squad}}
 
{{Brazil-footy-striker-stub}}
====Abstract Method====
 
[[de:Vagner Love]]
An [[Method (programming)|abstract method]] is one defined by the parent with no 'default
[[fr:Vagner Love]]
implementation'. Abstract methods are the definitive expression of
[[nl:Vágner Love]]
Virtual Inheritance as they embody the FORCED IMPLEMENTATION in the child by the
[[ja:ヴァグネル・ラヴ]]
specification in the parent (a primary requirement for delegation of function via inheritance).
[[pl:Vagner Love]]
 
[[pt:Vágner Silva Nascimento]]
Abstract methods are 'signature only' specifications which leave the
[[ru:Вагнер Лав]]
implementation to the child. The signature specification (of the abstract
method) is the mechanism that allows the parent to call the child without
knowing the details of the child's implementation of the parent's specification.
 
====Interfaces====
 
Virtual Inheritance is the core impetus for [[Interface (computer science)|Interfaces]].
With Interfaces a child inherits ONLY the specification
and NOT the implementation of a method. Thus Interfaces FORCE a child to
implement a method defined in the interface.
 
====Default Virtual Method Implementation====
 
In some languages a virtual method CAN OPTIONALLY provide a default
implementation (of the virtual method). Thus the distinction between a
[[Virtual function|virtual method]] (which can sometimes provide a default implementation)
and an [[Method (programming)|abstract method]] (which can never provide a default implementation).
This, however, does not detract from the semantic meaning of Virtual Inheritance
which is the ability of the parent to call a child implementation (method,
variable or other construct).
 
Note that in cases where a default implementation is provided by the parent the
current casting context will determine which implementation (child or parent
implementation) is used.
 
====Type Polymorphism====
 
In [[Polymorphism (computer science)|Type Polymorphism]] the
child MAY use both its implementation (defined in the child code body) and the
parent's implementation (of the virtual method) in implementing the child's
version of the target functionality.
 
The 'abstract method' and 'forced implementation' are what distinguish
Virtual Inheritance (VI) from the more general 'Type Polymorphism'.
 
Thus 'Type Polymorphism' (TP) is a conceptual superset of 'Virtual Inheritance'
(VI) in that TP functionality can be composed of child AND parent
implementations while VI functionality is (by definition) the child
implementation alone.
 
====Polymorphic Mechanism Vs. Control Mechanism====
 
Virtual Inheritance has both a polymorphic and control aspect to
its semantics.
 
The 'polymorphic' aspect is the ability of the child implementation to
'type' the functionality (of its virtual implementation) to the
child's specific needs (for that functionality).
Thus the 'polymorphic mechanism' is centric to the child.
 
The 'virtual control' aspect is the ability of a parent to call a 'virtual
implementation' that is ultimately implemented in the child.
Thus the 'control mechanism' is centric to the parent.
 
In articulating these two aspects the relationship of Virtual Inheritance to
[[Polymorphism (computer science)|Type Polymorphism ]] becomes clear. The
'virtual' control' functionality of 'Virtual Inheritance' is the primary benefit
to the parent class.
The polymorphic 'potential' of Virtual Inheritance is the primary benefit to the child class.
 
The semantic effect of 'virtual control' is that the parent can delegate
responsibility for the functionality to the child. This [[Delegation (programming)|delegation]],
in turn, leads to the polymorphic aspect of Virtual Inheritance via the actual
implementation in the child.
 
Note that the 'virtual implementation' (in the child) is 'virtual' from the
parent's point of view and 'actual' from the child's point of view.
 
Thus Virtual Inheritance is a control mechanism for parents that allows
functional delegation to the child. If a single line of inheritance exists
(between first ancestor and final descendent) with several layers of inheritance
then no polymorphism exists (its just pure delegation).
 
==Languages==
 
===C++===
[[C++]] has two uses virtual inheritance to solve both disambiguity problems caused by multiple inheritance and virtual [[method overriding (programming)|method overriding]].
 
====Method Overriding====
Normal method overriding is limited to the context of the object's current
casting.
 
For Example:
 
struct Human{
int Eyes(){ return 2; }
};
struct Mutant : public Human {
int Eyes(){ return 3; }
};
int main(){
Mutant * m = new Mutant();
Human * h = m;
}
 
 
Calling <code>m->Eyes()</code> would return 3, but calling <code>h->Eyes()</code> would return 2, even though they represent the same object. Simply changing the class definitions to:
 
struct Human{
virtual int Eyes(){ return 2; }
};
struct Mutant : public Human {
virtual int Eyes(){ return 3; }
};
 
results in both calls to <code>m->Eyes()</code> & <code>h->Eyes()</code> returning 3.
 
====Multiple inheritance====
'''Virtual inheritance''' in [[C++]] solves some of the problems caused by [[multiple inheritance]] by having clarifying disambiguity over which Ancestor Class members to use. It is used when the inheritance is representing restrictions of a set rather than composition of parts. You denote a member as virtual by the <code>virtual</code> [[keyword]].
 
For example:
 
class Animal {
public: // or protected:
virtual void Eat();
};
// Two classes virtually inheriting Animal:
class Mammal : public virtual Animal {
virtual const Color GetHairColor() const;
};
class WingedAnimal : public virtual Animal {
virtual void Flap();
};
// A bat is a winged mammal
class Bat : public Mammal, public WingedAnimal {};
 
In the above, if <code>Mammal</code> and <code>WingedAnimal</code> did not inherit virtually, a call to <code>Bat::Eat()</code> would be ambiguous and hence a compile error.
 
===C#===
[[C Sharp|C#]] uses virtual inheritance the same way C++ does for [[method overriding (programming)|method overriding]]. Differing from C++, C# requires the keyword <code>override</code> modifier to alleviate the [[fragile base class|fragile base class problem]].
 
Translating the C++ example to C#:
class Human {
public virtual int Eyes() { return 2; }
}
class Mutant : public Human {
public override int Eyes() { return 3; }
}
public static void main() {
Mutant m = new Mutant();
Human h = m
}
 
Calls to both <code>m.Eyes()</code> and <code>h.Eyes()</code> would return 3.
 
===Java===
In [[Java programming language|Java]], all class methods are virtual: no keyword is necessary. The Java translation of the C++ is:
public class Human{
public int Eyes(){ return 2; }
}
public class Mutant extends Human {
public int Eyes(){ return 3; }
}
public class Program {
public static void main(String [] args){
Mutant m = new Mutant();
Human h = m;
System.out.print(m.Eyes());
System.out.print(",");
System.out.println(h.Eyes());
}
}
The result of this program running is the output <code>3,3</code>.
 
[[Category:Class-based programming languages]]
[[Category:Programming languages]]
 
 
 
==See also==
 
Virtual Inheritance (VI) is best understood within the context of class inheritance
(all forms of inheritance). In the same way, Class Inheritance (CI) is best
understood in the context of other approaches to combine computing
functionality.
 
The 'Fundamental Inheritance Concepts' section contains links to other articles relevant to
the general concept of inheritance.
 
The 'Detailed Inheritance Concepts' section contains links to other articles explaining
the conceptual details of inheritance.
 
The 'Other Design Approaches' section contains links to other ways of combining
computing functionality (Aggregation/Composition). Links to these concepts are
listed to contrast inheritance from other approaches to functional
design in object-oriented languages.
 
These 'other' links help to distinguish the concepts of 'functional
dispersion/aggregation along lines of inheritance' (as in Virtual/Implementation
Inheritance) from 'object aggregation/composition' as embedded/referential
members in a class (embedded/referential containment)
 
Note the interesting semantic [[Object association|distinction]] between
AGGREGATION of 'self reliant' objects from COMPOSITION of 'object parts' (from
the English language - 'composition' semantics infers 'composed of parts').
Similar subtle but important distinctions (semantic aspects) exist between
virtual, implementation, and interface inheritance.
 
===Fundamental Inheritance Concepts===
 
*[[Class (object-oriented programming)]]
*[[Hierarchy (object-oriented programming)]]
*[[Inheritance (object-oriented programming)]]
*[[Polymorphism (computer science)|Type Polymorphism (computer science)]]
*[[Subclass (computer science)|Subclass (computer science)]]
*[[Superclass (computer science)|Superclass (computer science)]]
 
===Detailed Inheritance Concepts===
*[[Interface (computer science)]]
*[[Method (programming)]]
*[[method overriding (programming)|Method Overriding (programming)]]
*[[Multiple inheritance|Multiple Inheritance (computer science)]]
*[[Virtual function|Virtual Function (computer science)]]
*[[Virtual inheritance|Virtual Inheritance (object-oriented programming)]]
*[[Virtual method table|Virtual Method Table]]
 
===Other Design Approaches===
*[[Aggregation_(object-oriented programming)|Object Aggregation (via referential containment)]]
*[[Object composition|Object Composition(via embedded containment)]]
*[[Function composition (computer science)|Function composition (via sequential effects)]]
*[[Composition_(computer_science)|Composition (disambiguation page)]]
*[[Object association| Object Association (aggregation Vs. composition semantics page)]]
 
 
===Inheritance Issues and Problems===
*[[Diamond_problem|Diamond Problem (state space collision)]]
*[[fragile base class|Fragile Base Class Problem (unintended child side effects when changing base class)]]
*[[Yo-yo_problem|Yo-yo Problem (complex inheritance structure)]]
 
===Design Intentions in Inheritance===
 
*[[Code_reuse|Code Reuse (functional migration of replicated child code to parent class)]]
*[[Delegation (programming)|Delegation (historical semantic issues)]]
*[[Encapsulation|Encapsulation (disambiguation page)]]
*[[Information_hiding|Information Hiding (principal underlying encapsulation technique in object-oriented programming)]]
*[[Separation_of_concerns|Separation of Concerns (no functional overlap)]]
 
 
[[Category:Object-oriented programming]]