Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Orientación a Objetos eXtrema en Visual FoxPro
Message
De
04/02/2005 14:28:55
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Orientación a Objetos eXtrema en Visual FoxPro
Divers
Thread ID:
00983983
Message ID:
00983983
Vues:
43
Hola
Acabo de leer el artículo de Martín Salías al que hago referencia en el título, correspondiente a la reciente edición de UTMag de febrero 2005.
Pese a que el título del artículo aclara que se trata de Visual FoxPro, me hubiera gustado que apareciera algo de código acompañando los conceptos y los diagramas UML, porque habemos todavía desarrolladores que, aunque aparentemente creemos haber entendido perfectamente los conceptos y haber interpretado correctamente los diagramas, a la hora de la verdad no sabemos como volcarlo al código.
Suponiendo que tal vez Martín tuvo la idea de dejarnos una tarea para el hogar, cuya resolución aparecerá en el próximo número [;-D], pongo a consideración de ustedes lo que creo es el código que correspondería a los diagramas.
Creo que el concepto de "herencia", a esta altura, lo tengo bastante claro. Tengo mis dudas con respecto a la "composición", no tanto en cuanto al concepto en sí, sino más bien en el código que lo representa.
*!*///////////////////////////////////////////////////////
*!*   Class.........: Person
DEFINE CLASS Person AS Session 
Name  = ""
Sex   = "F"
Birth = Date()
*--------------------------
FUNCTION Age( BirthDate AS Date ) AS Number 
Local lnAge as Number
*-----*
Return lnAge
EndFunc 
*--------------------------
EndDefine
*!* 
*!*END DEFINE
*!*   Class.........: Person
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: Professional
DEFINE CLASS Professional AS Person 
Title           = ""
Available       = .T.
VocationClass   = ""
VocationLibrary = ""
oVocation       = null 
*--------------------------
PROCEDURE Init
This.oVocation = NewObject( This.VocationClass, This.VocationLibrary )
ENDPROC
*--------------------------
Function Hire() as Boolean 
Local lIsHire as Boolean 
*-----*
Return lIsHire  
EndFunc 
*--------------------------
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: Professional
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: Student
DEFINE CLASS Student AS Person 
University      = ""
Career          = ""
VocationClass   = ""
VocationLibrary = ""
oVocation       = null 
*--------------------------
PROCEDURE Init
This.oVocation = NewObject( This.VocationClass, This.VocationLibrary )
ENDPROC
*--------------------------
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: Student
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: Vocation
DEFINE CLASS Vocation AS Session 
Name = ""
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: Vocation
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: Medicine
DEFINE CLASS Medicine as Vocation 
*--------------------------
PROCEDURE Operate( oPerson AS Person ) AS Void
*----*
ENDPROC
*--------------------------
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: Medicine
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: Law
DEFINE CLASS Law as Vocation 
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: Law
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: LawStudent
DEFINE CLASS LawStudent AS Student 
VocationClass   = "Law"
VocationLibrary = "MyClassLibrary"
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: LawStudent
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: Lawyer
DEFINE CLASS Lawyer AS Professional
VocationClass   = "Law"
VocationLibrary = "MyClassLibrary"
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: Lawyer
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: MedicineStudent
DEFINE CLASS MedicineStudent AS Student 
VocationClass   = "Medicine"
VocationLibrary = "MyClassLibrary"
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: MedicineStudent
*!* 
*!*///////////////////////////////////////////////////////

*!*///////////////////////////////////////////////////////
*!*   Class.........: Doctor
DEFINE CLASS Lawyer AS Professional
VocationClass   = "Medicine"
VocationLibrary = "MyClassLibrary"
ENDDEFINE
*!* 
*!*END DEFINE
*!*   Class.........: Doctor
*!* 
*!*///////////////////////////////////////////////////////
Ricardo Aidelman
Software Developer
Praxis Computación
Buenos Aires, Argentina
Répondre
Fil
Voir

Click here to load this message in the networking platform