Oop

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Oop as PDF for free.

More details

  • Words: 7,862
  • Pages: 28
May 2002

‫ﻠﻜﻤﺒﻴﻮﺗﺮ واﻻﻧﺘﺮﻧ ﺖ‬ ‫ اﻟﻤﻮﺳﻮﻋ ﺔ اﻟﻌﺮﺑﻴ ﺔﻟ‬- ٢٠٠٠-٢٠٠٢ © ‫ﻔﻮ ﻇ ﺔ‬ ‫ﺟﻤﻴ ﻊ اﻟﺤﻘﻮ ق ﻣﺤ‬ http://www.c4arab.com/

PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com

‫ﻟﻜﺎﺌﻨﺎ ﺕ‬ ‫ﻟ ﻰﺍ‬ ‫ﻤﺩﺨ ل ﺇ‬ ‫‪١‬‬

‫ﻟﻜﺎﺌ ﻥ‪:‬‬ ‫ﻤﻔ ﻬ ﻭ ﻡﺍ‬

‫ﺍﺒ ﻁﺔ ﺘ ﻀﻡ ﺒﻴﺎﻨﺎ ﺕ ﻭﻜﻭﺩ ﻴﻌﻤل ﻓﻲ ﻫﺫﻩﺍﻟﺒﻴﺎﻨﺎ ﺕ‪.‬ﺃﻤﺎ‬ ‫ﺍﺀ ﻤﺘﺭ‬ ‫ﺍﻟﻜﺎﺌ ﻥ ‪ Object‬ﻫﻭﺃﺠ ﺯ‬ ‫‪ ،‬ﻨﻌﺘﺒﺭ‬ ‫‪ ،‬ﻋﻠﻰ ﻜل‬ ‫ﺍﻟ ﺼﻨ ﻑ ‪ Class‬ﻓﻴﻤﻜ ﻥﺍﻋﺘﺒﺎﺭﻩ ﻜﻘﺎﻟ ﺏ ﺤﻴﺙ ﻤ ﻥ ﺨﻼﻟﻪ ﻴﻤﻜ ﻥ ﺨﻠﻕ ﻜﺎﺌﻨﺎ ﺕ‬ ‫‪ ،‬ﻭ ﻫﺫﻩﺍﻷﺨﻴﺭﺓ ﻫﻲ ﻤﺜﻴﻼ ﺕ ‪ Instances‬ﻋ ﻥ‬ ‫ﺍﺌﻤﺎ ﺒﺄ ﻥﺍﻷ ﺼﻨﺎ ﻑ ﻫﻲﺃﻭ ﺼﺎ ﻑﻟﻠﻜﺎﺌﻨﺎ ﺕ‬ ‫ﺩ‬ ‫ﺃ ﺼﻨﺎﻓﻬﺎ‪.‬‬ ‫‪،‬ﺍﻟﺒﻴﺎﻨﺎ ﺕﺍﻟﺘﻲ‬ ‫ﺍﺨﻠﻲﻟﻠﻜﺎﺌ ﻥ‬ ‫ﺍﺍﻟﺘﻌﻘﻴﺩ؟ ﻴﻤﻜ ﻥﺍﻟﻘﻭلﺃ ﻥﺍﻟ ﺼﻨ ﻑ ﻴ ﺼ ﻑﺍﻟﻬﻴﻜلﺍﻟﺩ‬ ‫ﺍ ﻫﺫ‬ ‫ﻟﻤﺎﺫ‬ ‫‪،‬ﺍﻷﻨﺸ ﻁﺔﺍﻟﺘﻲ ﻴﻘﺩﺭ ﺘ ﺤﻘﻴﻘﻬﺎ ﻋﻠﻰ ﻫﺫﻩﺍﻟﺒﻴﺎﻨﺎ ﺕ‪.‬ﺍﻟﻜﺎﺌ ﻥ ﻫﻭ ﺤﺎﻟﺔﻟ ﺼﻨﻔﻪ‪.‬‬ ‫ﻴ ﺤﻭﻴﻬﺎ‬ ‫ﺍﺍﻟﺘ ﺼﻤﻴﻡ‪.‬‬ ‫‪ ،‬ﻜﻤﺎ ﻴﻤﺜﻠﻬﺎ ﻫﺫ‬ ‫ﻟﻨﻌﺘﺒﺭ ﻤﺜﻼ ﻨﻤﻭﺫﺝ ﻤ ﺭﻜﺒﺔ‬ ‫‪name of the class‬‬

‫‪Vehicle‬‬ ‫‪#NumberOfVehicles: integer‬‬

‫‪description of attributes‬‬ ‫‪or member data‬‬

‫= ‪description of methods‬‬ ‫‪associate code to data‬‬

‫اﺳﻢ اﻟ ﺼﻨ ﻒ‬

‫‪#mark : string‬‬ ‫‪#speed maximal : integer‬‬ ‫‪#speed courante : integer‬‬ ‫)( ‪+ CreateVehicle‬‬ ‫)( ‪+ DestroyVehicle‬‬ ‫)( ‪+ Start‬‬ ‫)‪+ Accelerate(rate : integer‬‬ ‫)( ‪+ Advance‬‬ ‫)( ‪+ MoveBack‬‬ ‫ﻤ ﺭﻜﺒﺔ‬ ‫ﺍﻜ ﺏ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪ #‬ﻋﺩﺩﺍﻟﻤﺭ‬

‫و ﺻ ﻒ اﻟﺨ ﺼﺎﺋ ﺺ‬ ‫أو اﻟﺒﻴﺎﻧﺎ ت اﻷﻋ ﻀﺎء‬

‫و ﺻ ﻒ اﻟﻤﻨﺎﻫﺞ =‬ ‫ﻠﺒﻴﺎﻧﺎ ت‬ ‫ﺗﺨ ﺼﻴ ﺺﻛﻮدﻟ‬

‫‪#‬ﺍﻟﻨﻭﻉ‪ :‬ﺤ ﺯﻤﺔ ﺭﻤﻭ ﺯ‬ ‫‪#‬ﺍﻟﺴﺭﻋﺔﺍﻟﻘ ﺼﻭﻯ ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪#‬ﺍﻟﺴﺭﻋﺔﺍﻟﺩﻨﻴﺎ ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪‬ﺩ ﻤﺭﻜﺒﺔ )(‬ ‫‪ +‬ﺸﻴ‬ ‫‪‬ﻡ ﻤﺭﻜﺒﺔ )(‬ ‫‪ +‬ﻫﺩ‬ ‫‪+‬ﺃﻗﻠﻊ )(‬ ‫ﺍﻟﻨﺴﺒﺔ ‪ :‬ﺼ ﺤﻴﺢ(‬ ‫‪ +‬ﺴﺎﺭﻉ )‬ ‫‪ +‬ﺘﻘﺩﻡ )(‬ ‫ﺍﺠﻊ )(‬ ‫‪ +‬ﺘﺭ‬

‫‪ ،‬ﻭﻗﻴﻤﺘﻴ ﻥ ﺼ ﺤﻴ ﺤﺘﻴ ﻥ‪:‬‬ ‫ﺍﻟﻨﻭﻉ(‬ ‫‪‬ﻤ ﺕ ﻋﻠﻰ ﺸﻜل ﺤ ﺯﻤﺔ ﺭﻤﻭ ﺯ )‬ ‫‪ ،‬ﻤ ﺭﻜﺒﺔ ﻗ ﺩ‬ ‫ﺍﺍﻟﻤﺜﺎل‬ ‫ﻓﻲ ﻫﺫ‬ ‫‪ ،‬ﻜل‬ ‫‪ ،‬ﺒﻤﻌﻨﻰ ﺁﺨﺭ‬ ‫ﺍﻟﺴﺭﻋﺔﺍﻟﺩﻨﻴﺎ‪ .‬ﻜل ﻫﺫﻩﺍﻟﺒﻴﺎﻨﺎ ﺕ ﺘﺨ ﺹ ﻤﺭﻜﺒﺔﺃﻴﺎ ﻜﺎﻨ ﺕ‬ ‫‪،‬ﻭ‬ ‫ﺍﻟﺴﺭﻋﺔﺍﻟﻘ ﺼﻭﻯ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﻜﺎﺌ ﻥ ﻤ ﻥ ﻨﻭﻉ ﻤ ﺭﻜﺒﺔ ﺴﻴﻜﻭ ﻥ ﻟﻪ ﻨﺴﺨﺘﻪﺍﻟﺨﺎ ﺼﺔ ﻤ ﻥ ﻫﺫﻩﺍﻟﺒﻴﺎﻨﺎ ﺕ‪ :‬ﻨﺘﻜﻠﻡ ﺇﺫ ﻥ ﻋ ﻥ ﺨ ﺼﺎﺌ ﺹ‬ ‫ﺍﻟﻤﺜﻴل )‪.(instance attributes‬‬ ‫‪،‬ﺍﻟﺘﻲ ﺘﺴﻤﺢ ﺒﺨﻠﻕ ﻜﺎﺌ ﻥﺍﻨ ﻁﻼﻗﺎ ﻤ ﻥ ﺼﻨ ﻑ ﺘﻨ ﺹ‬ ‫ﻋﻤﻠﻴﺔ ﺨﻠﻕﺍﻟﻤﺜﻴل )‪(instanciation‬‬ ‫ﻋﻠﻰ ﻤﻨﺢ ﻗﻴﻡ ﻤﻤﻴﺯﺓﻟﻜل ﺨ ﺼﺎﺌ ﺹﺍﻟﻤﺜﻴل‪.‬‬ ‫‪،‬‬ ‫ﺍﻟﺘ ﺼﻤﻴﻡﺍﻟﺴﺎﺒﻕ ﻴﺴﻤﺢﻟﻨﺎ ﺒﺘﻘﺩﻴﻡﺍﻟ ـ‪(Unified Modeling Language) UML‬‬ ‫ﺍﻭﻟﺔ ﻓﻲ ﻫﺫﻩﺍﻷﻴﺎﻡ‪.‬‬ ‫ﺍﻟﻤﺘﺩ‬ ‫‪،‬ﻭ‬ ‫ﻭ ﻫﻲ ﻟﻐﺔ ﺘﺴﻤﺢ ﺒﺘﻘﺩﻴﻡﺃﻨ ﻅﻤﺔﺍﻟﻜﺎﺌ ﻥﺍﻟﻌﺎﻟﻤﻴﺔ ﺘﻘﺭﻴﺒﺎ‬ ‫ﺍﻟﻤﺩﺨلﺍﻟ ﺤﺎﻟﻲ ﻻ ﻴﺴﻤﺢ ﺇﻻ ﺒﺎﻹ ﻁﻼﻉ ﻋﻠﻰ ﺠ ﺯﺀ ﺒﺴﻴ ﻁ ﻤ ﻥ ﻫﺫﻩﺍﻟﻠﻐﺔ ﻤ ﻥ ﺨﻼل‬ ‫ﺍﻓﻘﺔ ﻋﻼﻗﺎﺘﻬﺎ‬ ‫‪ ،‬ﺒﻤﺭ‬ ‫ﺍﺨﻠﺔ ﻓﻲﺍﻟﻨﻤﻭﺫﺝ‬ ‫ﺍﻟﻤﺘﻌﻠﻕ ﺒﺘﻘﺩﻴﻡ ﻤﺨﺘﻠ ﻑﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﺘﺩ‬ ‫ﺘ ﺼﻤﻴﻤﻬﺎﺍﻟﺜﺎﺒ ﺕ ﻭ‬ ‫ﺍﻷﺴﺎﺴﻴﺔ‪ .‬ﻨﻼ ﺤ ﻅ ﺇﺫ ﻥﺃ ﻥﺍﻟ ﺼﻨ ﻑ ﻴﺘﻡ ﺘﻤﺜﻴﻠﻪﺃﻭ ﺘﻘﺩﻴﻤﻪ ﺒﻤﺴﺘ ﻁﻴل ﻴﺘﺄﻟ ﻑ ﻤ ﻥ ﺜﻼﺙﺃﻗﺴﺎﻡ‪:‬‬ ‫‪ v‬ﺍﻟﻘﺴﻡﺍﻟﻌﻠﻭ ﻱ ﻴﺸﻴﺭ ﺇﻟﻰ ﺇﺴﻡﺍﻟ ﺼﻨ ﻑ‬ ‫ﺍﻋﻬﺎ ﻋﻠﻰ ﺸﻜل‪:‬‬ ‫‪ v‬ﺍﻟﻘﺴﻡﺍﻷﻭﺴ ﻁ ﻴ ﺤﺩﺩﺍﻟﺨ ﺼﺎﺌ ﺹ ﻭﺃﻨﻭ‬ ‫‪: IdentifierType IdentifierAttribut‬‬ ‫ﺍﻉﺍﻟﻘﻴﻡ‬ ‫ﺍﺃﻨﻭ‬ ‫‪ ،‬ﻭﻜﺫ‬ ‫ﺍﺘﻬﺎ ) ﺤﺠﺠﻬﺎ(‬ ‫ﺍﻤﺘﺭ‬ ‫‪ v‬ﺍﻟﻘﺴﻡﺍﻟﺴﻔﻠﻲ ﻴﻘﺩﻡﺍﻟﻤﻨﺎ ﻫﺞ ﻤﺭﻓﻘﺔ ﺒﺒﺎﺭ‬ ‫ﺍﻟﻤﻌﺎﺩﺓ‪.‬‬ ‫ﺍ ﺀ ﺘﻌﻠﻕﺍﻷﻤﺭ ﺒﺎﻟﺨ ﺼﺎﺌ ﺹ‬ ‫‪ ،‬ﺴﻭ‬ ‫ﺍﻟﺘﺴ ﻁﻴﺭ ﻴﺸﻴﺭ ﺇﻟﻰﺃ ﻥﺍﻟﻌﻨ ﺼﺭ ﻫﻭ ﻋ ﻀﻭﻟﻠ ﺼﻨ ﻑ‬ ‫ﺃﻭﺍﻟﻤﻨﺎ ﻫﺞ‪.‬‬ ‫‪،‬ﺍﻟﻤﺴﺘ ﻁﻴﻼ ﺕﺍﻟﻤﻌﻠﹼﻤﺔ ﺒﺭﻜ ﻥ ﻤ ﻁﻭ ﻱ ﺘﺨ ﺼ ﺹﻟﻠﺘﻌﻠﻴﻘﺎ ﺕﺃﻭﺍﻟﻤﻼ ﺤ ﻅﺎ ﺕ‪.‬‬ ‫ﻓﻲﺍﻷﺨﻴﺭ‬ ‫ﺍﻜ ﺏ )‪(NumberOfVehicles‬ﺍﻟﻤﺴﺅﻭﻟﺔ‬ ‫‪،‬ﻨﻼ ﺤ ﻅﺃ ﻥﺍﻟﺨﺎ ﺼﻴﺔ ﻋﺩﺩﺍﻟﻤﺭ‬ ‫ﺒﺎﻟﻤﻘﺎﺒل‬ ‫ﺍ ﻫﺎ ﺒﻔ ﻀل‬ ‫ﻋ ﻥ ﺘ ﺤﺩﻴﺩ ﻋﺩﺩﺍﻟﻤﺭﻜﺒﺎ ﺕ ﻓﻲﺃ ﻱ ﻭﻗ ﺕ ﻓﻲﺍﻟ ﺼﻨ ﻑ‪ .‬ﺇ ﻥ ﻫﺫﻩﺍﻟﺨﺎ ﺼﻴﺔ ﻴﺘﻡ ﺯﻴﺎﺩﺓ ﻤ ﺤﺘﻭ‬ ‫‪‬ﻡ ﻤ ﺭﻜﺒﺔ )‬ ‫ﺍ ﻫﺎ ﻤ ﻥ ﺨﻼلﺍﻟﻌﻤﻠﻴﺔ ﻫﺩ‬ ‫‪ ،‬ﻭﻴﺘﻡ ﺇﻨﻘﺎ ﺹ ﻤ ﺤﺘﻭ‬ ‫‪‬ﺩ ﻤ ﺭﻜﺒﺔ )‪(CreateVehicle‬‬ ‫ﺍﻟﻌﻤﻠﻴﺔ ﺸﻴ‬ ‫ﺍ ﺹﻟﻤﺠﻤﻭﻋﺔ ﻜﺎﺌﻨﺎ ﺕ ﺘﻨﺘﻤﻲﻟﻨﻔ ﺱ‬ ‫ﺍ ﻤﺜﺎل ﻨﻤﻭﺫﺠﻲﻟﺘﻘﺎﺴﻡﺍﻟﺨﻭ‬ ‫‪ .(DestroyVehicle‬ﻫﺫ‬ ‫‪ ،‬ﺒل ﻭﻴﻌﺘﺒﺭ‬ ‫ﺍ ﻴﻌﺘﺒﺭ ﻏﻴﺭ ﻤﺠﺩ ﻱﺍﻤﺘﻼ ﻙ ﻜل ﻜﺎﺌ ﻥﻟﻨﺴﺨﺔ ﻤﻨﻔﺭﺩﺓ ﻤ ﻥ ﻫﺫﻩﺍﻟﺨﺎ ﺼﻴﺔ‬ ‫ﺍﻟ ﺼﻨ ﻑ‪.‬ﻟﻬﺫ‬ ‫‪ ،‬ﺇﺫ ﻥ ﻤ ﻥﺍﻟﻤﺴﺘ ﺤﺴ ﻥﺃ ﻥ ﺘﺘﻘﺎﺴﻡﺍﻟﻜﺎﺌﻨﺎ ﺕ ﻨﺴﺨﺔ ﻭ ﺤﻴﺩﺓ‬ ‫ﺍﺩ(‬ ‫ﺍ )ﺘﺨﻴل ﻋﻤﻠﻴﺎ ﺕﺍﻹﻋﺩ‬ ‫ﻋﻤﻼ ﺨ ﻁﻴﺭ‬ ‫ﺘﻨﺘﻤﻲﻟﻠ ﺼﻨ ﻑ‪ .‬ﻨﺘﻜﻠﻡ ﺇﺫ ﻥ ﻋ ﻥ ﺨﺎ ﺼﻴﺔﺍﻟ ﺼﻨ ﻑ )‪.(Class Attribut‬‬ ‫ﺍﻟﻤﺜﺎلﺍﻵﺘﻲ ﻴﻭ ﻀﺢ ﻋﻤﻠﻴﺔ ﺨﻠﻕ ﻤﺜﻴﻠﻴ ﻥﻟﻜﺎﺌﻨﻴ ﻥ ﻤﺨﺘﻠﻔﻴ ﻥ ﻤ ﻥ ﻨﻔ ﺱﺍﻟ ﺼﻨ ﻑ‪:‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫‪Instances‬‬

‫‪Class‬‬

‫‪Vehicle‬‬ ‫"‪Mark = "Peugeot‬‬ ‫‪MaximalSpeed=200‬‬ ‫‪CouranteSpeed=165‬‬

‫‪#NumberOfVehicles: integer‬‬

‫‪Instanciation‬‬

‫‪# Mark : string‬‬ ‫‪# MaximalSpeed: integer‬‬ ‫‪# CouranteSpeed: integer‬‬ ‫)( ‪+ CreateVehicle‬‬ ‫)( ‪+ DestroyVehicle‬‬ ‫)( ‪+ Start‬‬ ‫)‪+ Accelerate(rate : integer‬‬ ‫)( ‪+ Advance‬‬ ‫)( ‪+ MoveBack‬‬

‫"‪Mark = "Renault‬‬ ‫‪MaximalSpeed=230‬‬ ‫‪CouranteSpeed=140‬‬

‫‪Class‬‬

‫‪Instances‬‬

‫ﻤ ﺭﻜﺒﺔ‬

‫"‪Mark = "Peugeot‬‬ ‫‪MaximalSpeed=200‬‬ ‫‪CouranteSpeed=165‬‬

‫ﺍﻜ ﺏ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪ #‬ﻋﺩﺩﺍﻟﻤﺭ‬

‫‪Instanciation‬‬

‫"‪Mark = "Renault‬‬ ‫‪MaximalSpeed=230‬‬ ‫‪CouranteSpeed=140‬‬

‫‪#‬ﺍﻟﻨﻭﻉ‪ :‬ﺤ ﺯﻤﺔ ﺭﻤﻭ ﺯ‬ ‫‪#‬ﺍﻟﺴﺭﻋﺔﺍﻟﻘ ﺼﻭﻯ ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪#‬ﺍﻟﺴﺭﻋﺔﺍﻟﺩﻨﻴﺎ ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪‬ﺩ ﻤﺭﻜﺒﺔ )(‬ ‫‪ +‬ﺸﻴ‬ ‫‪‬ﻡ ﻤﺭﻜﺒﺔ )(‬ ‫‪ +‬ﻫﺩ‬ ‫‪+‬ﺃﻗﻠﻊ )(‬ ‫ﺍﻟﻨﺴﺒﺔ ‪ :‬ﺼ ﺤﻴﺢ(‬ ‫‪ +‬ﺴﺎﺭﻉ )‬ ‫‪ +‬ﺘﻘﺩﻡ )(‬ ‫ﺍﺠﻊ )(‬ ‫‪ +‬ﺘﺭ‬

‫ﻋﻤﻠﻴﺔ ﺨﻠﻕ ﻤﺜﻴﻠﻴﻥﻟ ﺼﻨ ﻑ ﻭﺍﺤﺩ‬ ‫‪ ،‬ﺒﻤﺎﺃﻨﻨﺎ ﻤﻴ ﺯﻨﺎ ﺒﻴ ﻥ ﺨ ﺼﺎﺌ ﺹ‬ ‫ﻨﻔ ﺱﺍﻟﻤﻌﺎﻴﻴﺭ ﺘﻨ ﻁﺒﻕ ﻤﺒﺎﺸﺭﺓ ﻋﻠﻰﺍﻟﻤﻨﺎ ﻫﺞ‪ .‬ﻜﺫﻟ ﻙ‬ ‫‪ ،‬ﻓﺴﻨﻤﻴ ﺯﺃﻴ ﻀﺎ ﺒﻴ ﻥ ﻤﻨﺎ ﻫﺞﺍﻟ ﺼﻨ ﻑ ﻭﻤﻨﺎ ﻫﺞﺍﻟﻤﺜﻴل‪.‬‬ ‫‪ ،‬ﻭﺨ ﺼﺎﺌ ﺹﺍﻟﻤﺜﻴل‬ ‫ﺍﻟ ﺼﻨ ﻑ‬ ‫ﺍﺍﻟﻤﻨﻬﺎﺝ ﻴ ﻁﺒﻕ ﻋﻠﻰ ﻜل‬ ‫‪ ،‬ﻴ ﻅﻬﺭ ﺒﻭ ﻀﻭ ﺡﺃ ﻥ ﻫﺫ‬ ‫ﻟﻨﺄﺨﺫ ﻤﺜﻼﺍﻟﻤﻨﻬﺎﺝﺃﻗﻠﻊ )(‪Start‬‬ ‫ﺍﻟﺘﻲ‬ ‫‪،‬ﻭ‬ ‫ﺍﻟﻜﺎﺌ ﻥﺍﻟﺠﺩﻴﺩ(‬ ‫ﺍﺍﻟﻤﻨﻬﺎﺝ ﺴﻴﺴﺘﻌﻤل ﺨ ﺼﺎﺌ ﺹﺍﻟﻤﺜﻴل )‬ ‫‪ ،‬ﻫﺫ‬ ‫ﺍﺩﻴﺔ‪ .‬ﺒﺎﻟﻤﻘﺎﺒل‬ ‫ﻋﺭﺒﺔ ﺒ ﺼﻔﺔﺍﻨﻔﺭ‬ ‫‪ ،‬ﺇﺫ ﻥ ﻨ ﺤ ﻥ ﻨﺘﻜﻠﻡ ﻋ ﻥ ﻤﻨﻬﺎﺝﺍﻟﻤﺜﻴل )ﻤﻨﻬﺎﺝ ﻴﺠ ﺏﻟﻜل ﻤﺜﻴلﺃ ﻥ ﻴﺘﻭﻓﺭ ﻋﻠﻰ‬ ‫ﻴﺠﺭ ﻱ ﻋﻠﻴﻬﺎ ﺘ ﻁﺒﻴﻘﺎﺘﻪ‬ ‫ﻨﺴﺨﺔ ﻤﻨﻪ(‪.‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﻭﻟﻨﻌﺘﺒﺭ ﻤﺜﻼﺍﻟﻤﻨﻬﺎﺝ ﺸﻴﺩ ﻋ ﺭﺒﺔ )(‪CreateVehicle‬‬ ‫‪،‬‬ ‫‪ ،‬ﻫﺩﻓﻪ ﻫﻭ ﺨﻠﻕ ﻋﺭﺒ ﺔ ﺠﺩﻴﺩﺓ‬ ‫ﺍﺍﻋﺘﺒﺭﻨﺎ ﺒﺎﻟﺘﺩﻗﻴﻕ‬ ‫ﺍﺌﻴﺔﻟﻜل ﺨ ﺼﺎﺌ ﺹﺍﻟﻤﺜﻴل‪ .‬ﺇﺫ‬ ‫‪ ،‬ﻤ ﻥ ﺘ ﺤﺩﻴﺩ ﻗﻴﻡ ﺒﺩ‬ ‫ﺍﻟﺫ ﻱ ﻴﻤﻜﻨﻪ ﻓﻲ ﻭﻗ ﺕ ﺜﺎ ﻥ‬ ‫ﻭ‬ ‫ﺍﻜﺭ ﻱ ﻟﻠﻜﺎﺌ ﻥﺍﻟﺠﺩﻴﺩ‪ .‬ﻭﻟﻜ ﻥ‬ ‫‪،‬ﻨﻼ ﺤ ﻅﺃ ﻥﺍﻟﻤﺭ ﺤﻠﺔﺍﻷﻭﻟﻰ ﺘﺘﻌﻠﻕ ﺒ ﺤﺠ ﺯ ﻤﻜﺎ ﻥ ﺫ‬ ‫ﻋﻤﻠﻴﺔ ﺨﻠﻕ ﻜﺎﺌ ﻥ‬ ‫‪ ،‬ﻓﻘ ﻁﺍﻟ ﺼﻨ ﻑ ﻫﻭﺍﻟﺫ ﻱ ﻴﻤﻠ ﻙﺍﻟﻤﻌﻠﻭﻤﺎ ﺕﺍﻟﻼ ﺯﻤﺔ‬ ‫ﺍﺘﻪ‬ ‫ﻫﺫﻩﺍﻟﻤﺭ ﺤﻠﺔ ﻻ ﻋﻼﻗﺔﻟﻬﺎ ﺒﺎﻟﻜﺎﺌ ﻥ ﻓﻲ ﺤﺩ ﺫ‬ ‫ﻟﻌﻤﻠﻴﺔﺍﻟ ﺤﺠ ﺯ‪ :‬ﺇﺫ ﻥ ﺨﻠﻕ ﻜﺎﺌ ﻥ ﻫﻭ ﻤﻨﻬﺎﺝ ﻤ ﻥ ﻤﻨﺎ ﻫﺞﺍﻟ ﺼﻨ ﻑ‪.‬ﻨﺸﻴﺭ ﻜﺫﻟ ﻙ ﺇﻟﻰﺃﻨﻪ ﻓﻲ ﻫﺫﻩ‬ ‫ﺍ‬ ‫‪ ،‬ﻤﺜﻼ‪ :‬ﻤﻌﻠﻭﻤﺎ ﺕ ﺘﺸﻴﺭ ﺇﻟﻰﺃ ﻱ ﺼﻨ ﻑ ﻴﻨﺘﻤﻲ ﻫﺫ‬ ‫ﺍ ﺕ ﺇ ﻀﺎﻓﻴﺔ‬ ‫‪ ،‬ﻴﺴﺘﻘﺒلﺍﻟﻜﺎﺌ ﻥ ﺇﺸﺎﺭ‬ ‫ﺍﻟﻤﺭ ﺤﻠﺔ‬ ‫ﺍﻟﺫ ﻱ‬ ‫ﺍ‪ :‬ﻭ‬ ‫‪ ،‬ﺘ ﻁﺒﻕ ﻓﻘ ﻁ ﻓﻲ ﻜﺎﺌ ﻥ ﻤ ﺤﺩﺩ ﺠﻴﺩ‬ ‫‪ ،‬ﻓﻴﻡ ﻴﺨ ﺹ ﻋﻤﻠﻴﺔ ﺘﻬﻴﺌﺔﺍﻟﺨ ﺼﺎﺌ ﺹ‬ ‫ﺍﻟﻜﺎﺌ ﻥ‪ .‬ﺒﺎﻟﻤﻘﺎﺒل‬ ‫ﻫﻭ ﻗﻴﺩﺍﻟﺘﺸﻴﻴﺩ‪ .‬ﺘﻬﻴﺌﺔﺍﻟﺨ ﺼﺎﺌ ﺹ ﺇﺫ ﻥ ﻫﻲ ﻤﻨﻬﺎﺝ ﻤ ﻥ ﻤﻨﺎ ﻫﺞﺍﻟﻤﺜﻴل ﻭﻟﻴ ﺱﺍﻟ ﺼﻨ ﻑ‪.‬‬ ‫ﻨﺴﺘﺨﻠ ﺹ ﻓﻲﺍﻟﻨﻬﺎﻴﺔﺍﻟﻌﻼﻗﺔﺍﻵﺘﻴﺔ‪ :‬ﻋﻤﻠﻴﺔ ﺨﻠﻕ ﻜﺎﺌ ﻥ ﺘﻤﺭ ﻋﻠﻰ ﻤﺭ ﺤﻠﺘﻴ ﻥ‪:‬‬ ‫‪ ،‬ﻭﺘﻭﻓﻴﺭﺃﺩﻨﻰ‬ ‫ﺍﻜﺭ ﻱ ﻤ ﻥ ﻗﺒلﺍﻟ ﺼﻨ ﻑ ﻟﻠﻜﺎﺌ ﻥﺍﻟﺠﺩﻴﺩ‬ ‫‪ ،‬ﻭ ﻫﻲ ﺤﺠ ﺯ ﻤﻜﺎ ﻥ ﺫ‬ ‫ﻤﺭ ﺤﻠﺔﺃﻭﻟﻰ‬ ‫ﺍﻟﻤﻌﻠﻭﻤﺎ ﺕﻟﺠﻌلﺍﻟﻜﺎﺌ ﻥ ﻴﻨﻔﺫ‪.‬‬ ‫‪ ،‬ﻭﺘﺘﻌﻠﻕ ﺒﺘﻬﻴﺌ ﺔ ﺨ ﺼﺎﺌ ﺹﺍﻟﻤﺜﻴل‪.‬‬ ‫ﻤﺭ ﺤﻠﺔ ﺜﺎﻨﻴﺔ ﺘﺨ ﺹﺍﻟﻜﺎﺌ ﻥ‬

‫‪٢‬‬

‫ﻟﻜﺒ ﺴﻠﺔ‪encapsulation :‬‬ ‫ﻤﻔ ﻬ ﻭ ﻡﺍ‬

‫‪،‬ﻟﻘﺩ ﺨ ﻁﻭ ﺕ ﺨ ﻁﻭﺘ ﻙﺍﻷﻭﻟﻰ ﻨ ﺤﻭﺃ ﺤﺩ ﻋﻨﺎ ﺼﺭﺍﻟﻜﺒﺴﻠﺔﺍﻟﺜﻼﺜﺔ‪.‬ﺍﻟﻜﺒﺴﻠﺔ‬ ‫ﺒﺩﻭ ﻥ ﻤﻌﺭﻓﺔ‬ ‫ﺘﺭﺘﻜ ﺯ ﻋﻠﻰ ﺜﻼﺜﺔ ﻤﻔﺎ ﻫﻴﻡ‪:‬‬ ‫ﺍﻟﻜﻭﺩﺍﻟﻘﺎﺩﺭ ﻋﻠﻰ ﻤﻌﺎﻟﺠﺘﻬﺎ‬ ‫‪،‬ﻭ‬ ‫‪ v‬ﺍﻟﻜﺎﺌ ﻥ ﻴﺠﻤﻊ ﻓﻲ ﻤ ﻀﻤﻭﻨﻪﺒﻴﺎﻨﺎﺘﻪ )ﺨ ﺼﺎﺌ ﺼﻪ(‬ ‫ﺍﻟﻤﻨﺎ ﻫﺞ(‪.‬‬ ‫)‬ ‫‪ ،‬ﺸﻜﻠﻪ ﻴﺘﺭﻜ ﺏ ﻤ ﻥ ﺭﺴﺎﺌل‬ ‫‪ v‬ﺘﺠﺭﻴﺩﺍﻟﺒﻴﺎﻨﺎ ﺕ‪ :‬ﻫﻴﻜل ﻜﺎﺌ ﻥ ﻤﺎ ﻻ ﻴ ﻅﻬﺭ ﻤ ﻥﺍﻟﺨﺎﺭﺝ‬ ‫ﺍﺴﺘﻘﺒﺎل ﻷ ﻱ ﺭﺴﺎﻟﺔ ﻴﻨﺠﻡ ﻋﻨﻪ ﺘﻨﻔﻴﺫ ﻤﺠﻤﻭﻋﺔ ﻤ ﻥﺍﻟﻤﻨﺎ ﻫﺞ‪.‬‬ ‫‪،‬ﻭ‬ ‫ﻏﻴﺭﺍ ﺼ ﻁﻼ ﺤﻴﺔ‬ ‫‪،‬‬ ‫ﺍ ﻤﺎ ﻨ ﻅﺭﻨﺎ ﻤ ﻥﺍﻟﺨﺎﺭﺝ )ﺒﺎﻟﻨﺴﺒﺔ ﻟﻤﺴﺘﺨﺩﻡﺍﻟﻜﺎﺌ ﻥ(‬ ‫ﺍ ﺕ‪ :‬ﺇﺫ‬ ‫ﺍﺀ‬ ‫‪ v‬ﺘﺠﺭﻴﺩﺍﻹﺠﺭ‬ ‫‪ ،‬ﻓﻤﺜﻼ‪ :‬ﻫﻭ ﻻ‬ ‫ﺍﺨﻠﻲﺍﻟﻤ ﻁﺒﻕ‬ ‫ﺍﻟﻤﺴﺘﺨﺩﻡ ﻻ ﻴﻤﻠ ﻙﺃﺩﻨﻰ ﻤﻌﻠﻭﻤﺔ ﺤﻭلﺍﻟﻨﺸﺎ ﻁﺍﻟﺩ‬ ‫‪ ،‬ﻴ ﺤﺘﺎﺝ ﺇﻟﻰ ﺘﻨﻔﻴﺫ ﺒﻌ ﺽﺃﻭ ﻜلﺍﻟﻤﻨﺎ ﻫﺞﺃﻡ‬ ‫ﺍ ﻜﺎ ﻥﺍﻟﻌﻤلﺍﻟﻤ ﻁﻠﻭ ﺏ‬ ‫ﻴﺩﺭ ﻱ ﻤﺎ ﺇﺫ‬ ‫ﺍﻟﺦ‪.‬‬ ‫‪،‬ﺃﻭ ﺴﻴﻘﻭﻡ ﺒﺨﻠﻕ ﻜﺎﺌ ﻥ ﻤﺅﻗ ﺕ‪...‬‬ ‫ﻻ‬ ‫‪ ،‬ﺨﺩﻤﺎ ﺕﺍﻟﻜﺎﺌ ﻥ ﻟﻴﺴ ﺕ ﺇ ﺼ ﻁﻼ ﺤﻴﺔ ) ﻻ ﻴﻤﻜ ﻥ‬ ‫ﺤﺴ ﺏﺍﻟﻘﻴﻡﺍﻟﻘﺎﻨﻭﻨﻴﺔﺍﻟﻨﻤﻭﺫﺠﻴﺔ ﻟﻠﻜﺎﺌ ﻥ‬ ‫ﺍﻟﺘﻲ ﻫﻲ ﻤﺭﻜﺒﺔ ﻤ ﻥ‪:‬‬ ‫‪،‬ﻭ‬ ‫ﺘ ﺤﻘﻴﻘﻬﺎ( ﺇﻻ ﻤ ﻥ ﺨﻼل ﺭﺴﺎﺌل‬ ‫‪ v‬ﺇﺴﻡ‬ ‫ﺍ ﺕﺍﻟﺩﺨﻭل‬ ‫ﺍﻤﺘﺭ‬ ‫‪ v‬ﻗﺎﺌﻤﺔ ﺒﺎﺭ‬ ‫ﺍ ﺕﺍﻟﺨﺭﻭﺝ‬ ‫ﺍﻤﺘﺭ‬ ‫‪ v‬ﻗﺎﺌﻤﺔ ﺒﺎﺭ‬ ‫‪ ،‬ﺇﻨﻬﺎ‬ ‫ﺍﺠﻬﺘﻪ ‪interface‬‬ ‫ﻗﺎﺌﻤ ﺔﺍﻟﺭﺴﺎﺌلﺍﻟﺘﻲ ﻴﻘﺩﺭ ﺒﻔ ﻀﻠﻬﺎﺍﻟﻜﺎﺌ ﻥ ﻤ ﻥﺍﻻﺴﺘﺠﺎﺒﺔ ﺘﻤﺜل ﻭ‬ ‫‪ ،‬ﻓﻴﺠ ﺏﺃ ﻥ ﻴﺒﻘﻰ ﻤﺨﻔﻴﺎ ﻋ ﻥ‬ ‫ﺍﻟﻘﺴﻡﺍﻟﻌﺎﻡ ‪ public‬ﻤ ﻥﺍﻟﻜﺎﺌ ﻥ‪.‬ﺃﻤﺎ ﻜل ﻤﺎ ﻴﺨ ﺹﺍﻟﻤﻌﺎﻟﺠﺔ‬ ‫‪ ،‬ﻜلﺍﻟﻜﺎﺌﻨﺎ ﺕ‬ ‫‪ ،‬ﺘﻤﺎﻤﺎ‬ ‫ﺍ ﻤﺎ ﻴﻤﺜلﺍﻟﻘﺴﻡﺍﻟﺨﺎ ﺹ ‪ private‬ﻤ ﻥﺍﻟﻜﺎﺌ ﻥ‬ ‫ﺍﻟﻤﺴﺘﺨﺩﻡﺍﻟﻨﻬﺎﺌﻲ‪ :‬ﻭ ﻫﺫ‬ ‫ﺍﻥ‬ ‫‪ ،‬ﻴﻘﺩﺭ‬ ‫‪ ،‬ﺒﺎﻟﻤﻘﺎﺒل ﻜﺎﺌﻨﻴ ﻥ ﻴﻨﺘﻤﻴﺎ ﻥﻟ ﺼﻨﻔﻴ ﻥ ﻤﺨﺘﻠﻔﻴ ﻥ‬ ‫ﺍﺠﻬﺔ‬ ‫ﺍ ﺕﺍﻟﻭ‬ ‫ﺍﻟﻤﻨﺘﻤﻴﺔ ﻟﻨﻔ ﺱﺍﻟ ﺼﻨ ﻑ ﺘﺘﻤﺘﻊ ﺒﺫ‬ ‫ﺍﺠﻬﺔ ﻴﻤﻜ ﻥ ﺘﻤﺜﻴﻠﻬﺎ ﻋﻠﻰ ﺸﻜل ﺨﺎ ﺼﻴﺔ‬ ‫‪،‬ﺍﻟﻭ‬ ‫ﺍﺠﻬﺔ‪ .‬ﻤ ﻥ ﻭﺠﻬﺎ ﺕ ﻨ ﻅﺭ ﻤﺨﺘﻠﻔﺔ‬ ‫ﻋﻠﻰ ﺘﻘﺩﻴﻡ ﻨﻔ ﺱﺍﻟﻭ‬ ‫ﻤﺘﻤﻴﺯﺓﻟﻠ ﺼﻨ ﻑ‪.‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﺍ ﺕﺍﻟﺘﻭﺠﻪﺍﻟﻜﺎﺌﻨﻲ ‪oop‬‬ ‫ﺍﺠﻬﺔ ﺘﻤﺜل‬ ‫‪،‬ﺍﻟﻭ‬ ‫‪ ،‬ﻓﻲ ﻤﻌ ﻅﻡﻟﻐﺎ ﺕﺍﻟﺒﺭﻤﺠﺔﺍﻟ ﺤﺩﻴﺜﺔ ﺫ‬ ‫ﺘ ﻁﺒﻴﻘﻴﺎ‬ ‫ﻗﺎﺌﻤﺔﺍﻟﻤﻨﺎ ﻫﺞﺍﻟﺘﻲ ﻴﻤﻜ ﻥﺍﻟﻨﻔﺎﺫ ﺇﻟﻴﻬﺎ ﻤ ﻥ ﻗﺒلﺍﻟﻤﺴﺘﺨﺩﻡ‪.‬‬ ‫‪ ،‬ﺒ ﺤﻴﺙ ﻴﺴﻤﺢ ﺫﻟ ﻙ‬ ‫ﻤ ﻥﺍﻟﻤﺴﺘ ﺤﺴ ﻥ ﺇﺨﻔﺎﺀ ﺘﻔﺎ ﺼﻴل ﻤﻌﺎﻟﺠﺔﺍﻟﻜﺎﺌﻨﺎ ﺕ ﻋ ﻥﺃﻋﻴ ﻥﺍﻟﻤﺴﺘﺨﺩﻡ‬ ‫ﺍﺨﻠﻲﻟﺒﻴﺎﻨﺎ ﺕﺍﻟ ﺼﻨ ﻑ )ﺘﺒﺩﻴل ﺠﺩﻭل ﺒ ﺤ ﺯﻤﺔ ﺭﻤﻭ ﺯ( ﻤ ﻥ ﺩﻭ ﻥﺍﻟﻠﺠﻭﺀ ﺇﻟﻰ‬ ‫ﺒﺘﻐﻴﻴﺭ ﻤﺜﻼﺍﻟﻬﻴﻜلﺍﻟﺩ‬ ‫‪،‬‬ ‫ﺍﺜﻴﺘﻴ ﻥ )ﺒﻌﺩﻴ ﻥ(‬ ‫ﺘﻌﺩﻴل ﻜﻭﺩﺍﻟﻤﺴﺘﺨﺩﻡ‪.‬ﺃﻭ ﻜﻤﺜﺎل ﺁﺨﺭ‪:‬ﻟﻨﻌﺘﺒﺭﺃ ﻥ ﺼﻨﻔﺎ ﻤﺎ ﻴﺸﻜلﻟﻨﺎ ﻨﻘ ﻁﺔ ﺒﺈ ﺤﺩ‬ ‫ﺍﺘﻴ ﺏ‬ ‫ﺍﻟﺘﺭ‬ ‫ﺍ ﺼل ﻭ‬ ‫ﺍﻟﻲ ﻤﻭﻗﻊﺍﻟﻨﻘ ﻁﺔ ﻤ ﻥ ﻤ ﺤﻭﺭ ﻱﺍﻟﻔﻭ‬ ‫ﺍ ﻥ ﻋﻠﻰﺍﻟﺘﻭ‬ ‫ﺍﻟﺘﻲ ﺘﻌ ﻁﻴﻨﺎ ﻤﻨﻬﺎﺠﻴ ﻥ ﻴ ﺤﺩﺩ‬ ‫ﻭ‬ ‫ﺍﺨل‬ ‫ﺍ ﻜﺎﻨ ﺕﺍﻟﻨﻘ ﻁﺔ ﻤﻤﺜﻠﺔ ﺩ‬ ‫ﺍﻋﻲ ﺇﻋﻼﻡﺍﻟﻤﺴﺘﺨﺩﻡ ﻤﺎ ﺇﺫ‬ ‫‪ ،‬ﻭﺒﺎﻟﺘﺎﻟﻲﻟﻴ ﺱ ﻤ ﻥﺍﻟﺩ‬ ‫ﺍﻟﻌﻤﻭﺩ(‬ ‫ﺍﻟﺴ ﻁﺭ ﻭ‬ ‫)‬ ‫ﺍﻟ ﺼﻨ ﻑ ﻋﻠﻰ ﺸﻜل ﻗ ﻁﺒﻲﺃﻭ ﺨ ﻁﻲ‪.‬‬ ‫‪ ،‬ﺇﺫ ﻥ ﻫﻭ ﻤ ﻥ‬ ‫ﺍﻹﺨﻔﺎﺀ(‬ ‫ﺍﻡ ﺒﻤﺒﺩﺃﺍﻟﻜﺒﺴﻠﺔ )‬ ‫ﻜلﺍﻟﻠﻐﺎ ﺕﺍﻟﻜﺎﺌﻨﻴﺔﺍﻟﺘﻭﺠﻪ ﻻ ﺘﺸﺘﺭ ﻁﺍﻻﻟﺘ ﺯ‬ ‫ﺨ ﺼﻭ ﺼﻴﺎ ﺕ ﻭ ﻁﺭﻴﻘﺔ ﺘﻔﻜﻴﺭﺍﻟﻤ ﺼﻤﻡ‪.‬‬ ‫ﻟ ﻭﺭﺍﺜﺔ‪Heritage :‬‬ ‫‪ ٣‬ﺍ‬

‫ﺍﺜﺔ ﻫﻭ ﺜﺎﻨﻲ ﻤﺒﺩﺃ ﻤ ﻥﺍﻟﻤﺒﺎﺩ ﺉﺍﻷﺴﺎﺴﻴﺔﺍﻟﺜﻼﺜﺔ‪ .‬ﻭﻴﺘﻌﻠﻕ ﺒﺘﺭﺠﻤﺔﺍﻟﻤﻔﻬﻭﻡﺍﻟ ﻁﺒﻴﻌﻲ‬ ‫ﺍﻟﻭﺭ‬ ‫ﻟﻠﺘﻌﻤﻴﻡ ‪/‬ﺍﻟﺘﺨ ﺼﻴ ﺹ‪.‬‬ ‫‪،‬ﺃ ﻏﻠ ﺏﺍﻷﻨ ﻅﻤﺔﺍﻟ ﺤﻘﻴﻘﻴﺔ ﺘﺴﻌﻰ ﺇﻟﻰ ﺠﻌلﺍﻟﻌﻨﺎ ﺼﺭﺍﻟﺘﻲ ﺘﺭﻜﺒﻬﺎ ﻋﻠﻰ ﺸﻜل ﺘﺴﻠﺴﻠﻲ‬ ‫ﺇﺫ ﻥ‬ ‫‪ ،‬ﻭﺒﺎﻟﺘﻔ ﺼﻴل‬ ‫ﺍﺍﻟﻤﻭ ﻀﻭﻉ ﻜﺎﻨ ﺕ ﻋﻠﻰ ﻋﻼﻗﺔ ﺒﻌﻠﻡﺍﻷ ﺤﻴﺎﺀ‬ ‫) ﻫﻴﺎﺭﺸ ﻲ(‪.‬ﺍﻟﻔﻜﺭﺓﺍﻷﻭﻟﻰ ﺤﻭل ﻫﺫ‬ ‫ﺍ ﻋﻠﻰ ﻤﻌﺎﻴﻴﺭ ﻤﺨﺘﻠﻔﺔ‪.‬‬ ‫ﺍ ﺕﺍﻋﺘﻤﺎﺩ‬ ‫ﻜﺎﻨ ﺕ ﺒﺨ ﺼﻭ ﺹ ﺘﻘﻨﻴﺔ ﺘﺭﺘﻴ ﺏﺍﻟ ﺤﺸﺭ‬ ‫ﺍﺍﻟﻤﻔﻬﻭﻡ ﻋﻠﻰﺃﻨﻪ ﺒﺈﻤﻜﺎ ﻥ ﻜﺎﺌ ﻥ ﻤﺎ ﻤ ﻥﺍﻻﺴﺘﻔﺎﺩﺓ‬ ‫ﺍﺜﺔ‪ .‬ﻴﺭﺘﻜ ﺯ ﻫﺫ‬ ‫ﻋﻭﺩﺓ ﺇﻟﻰ ﻤﻭ ﻀﻭﻉﺍﻟﻭﺭ‬ ‫ﺍ ﺹ ﺘﺘﻌﻠﻕ ﺒﻪ‬ ‫ﺍﻟﺫ ﻱ ﻴﻤﻜ ﻥ ﻟﻪﺃ ﻥ ﻴ ﻀﻴ ﻑ ﻤﺠﻤﻭﻋﺔ ﻤ ﻥﺍﻟﺨﻭ‬ ‫‪،‬ﻭ‬ ‫ﺍ ﺹﺍﻟﻜﺎﺌ ﻥﺍﻷﻋﻠﻰ ﻤﻨﻪ‬ ‫ﻤ ﻥ ﺨﻭ‬ ‫ﻟﻭ ﺤﺩﻩ‪.‬‬ ‫ﺍﺍﻟﻤﻔﻬﻭﻡ ﺒﺎﻟ ﻁﺭﻴﻘﺔﺍﻵﺘﻴﺔ‪:‬‬ ‫‪ ،‬ﻴﻤﻜ ﻥ ﺘﺭﺠﻤﺔ ﻫﺫ‬ ‫ﻤ ﻥﺍﻟﺠﺎﻨ ﺏﺍﻟﻜﺎﺌﻨﻲ‬ ‫ﺍﺍﻟ ﺼﻨ ﻑ ﺒﺎﻟ ﺼﻨ ﻑ‬ ‫‪ ،‬ﻭﻨﺴﻤﻲ ﻫﺫ‬ ‫‪ v‬ﻨﺨ ﺼ ﺹ ﺼﻨ ﻑ ﺇﻟﻰﺍﻟﻤﺴﺘﻭﻯﺍﻷﻜﺜﺭ ﻋﻤﻭﻤﻴﺔ‬ ‫‪،‬ﺃﻭﺍﻟ ﺼﻨ ﻑﺍﻷ ﺏﺃﻭ ﻜﺫﻟ ﻙ ﺒﺎﻟ ﺼﻨ ﻑﺍﻟﻤﻤﺘﺎ ﺯ‪.‬‬ ‫ﺍﻟﻘﺎﻋﺩ ﻱ‬ ‫‪ ،‬ﻨﺸﺘﻕ ﻤﻔﻬﻭﻤﺎ ﻗﺎﻋﺩﻴﺎ‪.‬ﺍﻟ ﺼﻨ ﻑﺍﻟﺠﺩﻴﺩ ﻴ ﻁﻠﻕ ﻋﻠﻴﻪ‬ ‫‪ v‬ﻟﻜل ﻤﻔﻬﻭﻡ ﻤﺘﺨ ﺼ ﺹ‬ ‫ﺍﻟ ﺼﻨ ﻑﺍﻟﻤﺸﺘﻕﺃﻭﺍﻟ ﺼﻨ ﻑﺍﻹﺒ ﻥﺃﻭ ﻜﺫﻟ ﻙ ﺒﺎﻟ ﺼﻨ ﻑﺍﻟﻔﺭﻋﻲ‪.‬‬ ‫ﺍﺜﻴﺔ‬ ‫‪ ،‬ﻭﺒﺎﻟﺘﺎﻟﻲ ﻴﻤﻜﻨﻨﺎ ﺘﺭﺠﻤﺔ ﻜل ﻋﻼﻗﺔ ﻭﺭ‬ ‫ﺍﺜﺔ ﺘﻌﺒﺭ ﻋ ﻥ ﻋﻼﻗﺔ ﺘﻌﻤﻴﻡ ‪ /‬ﺘﺨ ﺼﻴ ﺹ‬ ‫ﺍﻟﻭﺭ‬ ‫ﺒﺎﻟﺠﻤﻠﺔﺍﻵﺘﻴﺔ‪:‬‬

‫ﻟﻘﺎ ﻋﺩ ﻱ‬ ‫ﻟ ﻤﺸﺘﻕ ﻫﻭﺇ ﺼﺩﺍ ﺭ ﺨﺎ ﺹ ﻤﻥ ﺼﻨﻔ ﻪﺍ‬ ‫ﻟ ﺼﻨ ﻑﺍ‬ ‫ﺍ‬ ‫ﺍﺜﺔ‪:‬‬ ‫ﺴﻨﻘﺩﻡ ﻤﺜﺎﻟﻴ ﻥ ﻜﻼﺴﻴﻜﻴﻴ ﻥﻟﺘﻤﺜﻴل ﻓﻜﺭﺓﺍﻟﻭﺭ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫‪.٣‬‬

‫‪ .١‬اﻟﻤﺜﺎلاﻷول‪:‬اﻟﻜﺎﺋﻨﺎ تاﻟﺒﻴﺎﻧﻴﺔ ‪Graphic objects‬‬

‫‪ ،‬ﻭ ﻫﺫﻩﺍﻷﺨﻴﺭﺓ‬ ‫‪ ،‬ﻜل ﻜﺎﺌ ﻥ ﺒﻴﺎﻨﻲ ﻴﻤﻜ ﻥﺍﻟﺘﻌﺒﻴﺭ ﻋﻨﻪ ﺒﻨﻘ ﻁﺔ‬ ‫ﻟﻨﻌﺘﺒﺭ ﻤﺠﻤﻭﻋﺔ ﻜﺎﺌﻨﺎ ﺕ ﺒﻴﺎﻨﻴﺔ‬ ‫ﺍﺜﻴﺘﻴ ﻥﺍﻟﺨ ﻁﻴﺘﻴ ﻥ ‪ X‬ﻭ‪Y‬‬ ‫‪ ،‬ﺴﻭ ﻑ‬ ‫ﺍ ﺨﻠﻕ ﻭ ﻫﺩﻡﺍﻟﻜﺎﺌ ﻥ‬ ‫‪ ،‬ﻭﻨ ﺤﺩﺩﻟﻬﺎﻟﻭﻨﻬﺎ‪ .‬ﻤﺎﻋﺩ‬ ‫ﻴﺘﻡ ﺘﻤﺜﻴﻠﻬﺎ ﺒﺎﻹ ﺤﺩ‬ ‫ﺍﺍﻟﻜﺎﺌ ﻥﺍﻟﺒﻴﺎﻨﻲ‪:‬‬ ‫ﻨﻌﻴ ﻥﺍﻟﻤﻨﺎ ﻫﺞﺍﻵﺘﻴﺔﻟﻬﺫ‬ ‫‪v‬‬ ‫‪v‬‬ ‫‪v‬‬ ‫‪v‬‬

‫ﺍﻟﺒﻴﺎﻨﺎ ﺕ(‬ ‫ﺍﺀﺓ ﺇﻟﻰﺍﻟﺨ ﺼﺎﺌ ﺹ )‬ ‫ﺍﻟﻘﺭ‬ ‫ﺃﻨﻔﺫ ﺒﺎﻟﻜﺘﺎﺒﺔ ﻭ‬ ‫ﺃﻨﺸﺭ‬ ‫ﺃﻤ ﺤﻭ‬ ‫ﺤﺭ ﻙﺍﻟﻜﺎﺌ ﻥ‪.‬‬

‫ﺇﺫ ﻥ ﺴﻨ ﺤ ﺼل ﻋﻠﻰ ﺸﻜلﺍﻟ ﺼﻨ ﻑ ‪ObjetGraphic‬ﺍﻟﻤﻘﺩﻡ ﻓﻲﺍﻟ ﺼﻔ ﺤﺔﺍﻵﺘﻴﺔ‪.‬‬ ‫‪ ،‬ﻜل ﻤﻨﻬﻤﺎ‬ ‫ﺍﺌﺭﺓ ‪Line & Circle‬‬ ‫ﺍﻟﺩ‬ ‫ﻨ ﻀﻴ ﻑ ﺒﻌﺩ ﺫﻟ ﻙ ﺼﻨﻔﻴ ﻥ ﻤﺘﺨ ﺼ ﺼﻴ ﻥ‪:‬ﺍﻟﺴ ﻁﺭ ﻭ‬ ‫ﺍﻭﻴﺔ‬ ‫ﺍﻟ ﺯ‬ ‫‪،‬ﺍﻟ ﻁﻭل ﻭ‬ ‫ﺍﺌﺭﺓ‬ ‫ﺍ ﺹﺍﻟﻤﺘﻌﻠﻘﺔ ﺒﻪ‪:‬ﺍﻟﻘ ﻁﺭ ‪ Rayon‬ﺒﺎﻟﻨﺴﺒﺔﻟﻠﺩ‬ ‫ﺍﺘﻪ ﺒﻌ ﺽﺍﻟﺨﻭ‬ ‫ﻴ ﻀﻴ ﻑﻟﺫ‬ ‫ﺒﺎﻟﻨﺴﺒﺔ ﻟﻠﺴ ﻁﺭ ‪Length & Angle‬‬ ‫ﻟﺩﺍﺌ ﺭﺓ‬ ‫ﻟﺴﻁ ﺭ ﻭﺍ‬ ‫‪،‬ﺃﻴ ﻀﺎ ﻴﺘﻤﺘﻊ ﻜل ﻤ ﻥﺍﻟ ﺼﻨﻔﻴ ﻥ‪:‬ﺍ‬ ‫ﺍ ﺕ ﻜل ﺼﻨ ﻑ ﺯﻴﺎﺩﺓ ﻋﻠﻰ ﺨ ﺼﺎﺌ ﺹﺍﻟ ﺼﻨ ﻑ‬ ‫ﺍﻟﺘﻲ ﺘﺘﺭﺠﻡ ﻤﻤﻴ ﺯ‬ ‫ﺒﺨ ﺼﺎﺌ ﺼﻪ )ﺒﻴﺎﻨﺎﺘﻪ(ﺍﻟﺨﺎ ﺼﺔ ﺒﻪ ﻭ‬ ‫ﺍﻟﻘﺎﻋﺩ ﻱﺍﻟﺫ ﻱ ﻭﺭﺜﺎ ﻋﻨﻪ‪.‬‬ ‫ﺍﻟ ﺼﻨﻔﻴ ﻥ‪ :‬ﺴﻁ ﺭ ﻭﺩﺍﺌ ﺭﺓ ﻟﻴﺴﺎ ﺒﺈﻤﻜﺎﻨﻬﻤﺎ ﺘ ﺤﻘﻴﻕﺍﻟﻜﻭﺩ ﻟﻠﻤﻨﻬﺎﺝ ‪GetX‬ﺍﻟﻤﺴﺅﻭل ﻋ ﻥ‬ ‫‪ ،‬ﻭﻟﻜ ﻥ ﺒﺈﻤﻜﺎﻨﻬﻤﺎ ﺇ ﻀﺎﻓﺔ ﻤﻨﺎ ﻫﺞﺃﺨﺭﻯ ﻟﻠﻭ ﺼﻭل ﺇﻟﻰ‬ ‫ﺍ ﺼل‬ ‫ﺘ ﺤﺩﻴﺩ ﻤﻭﻗﻊﺍﻟﻨﻘ ﻁﺔ ﻤ ﻥ ﻤ ﺤﻭﺭﺍﻟﻔﻭ‬ ‫ﺨ ﺼﺎﺌ ﺼﻬﻤﺎﺍﻟﺠﺩﻴﺩﺓ‪.‬‬ ‫‪ ،‬ﻓﺈﻨﻨﺎ ﺴﻨﻼ ﺤ ﻅﺃ ﻥ ﻜﻼﺍﻟ ﺼﻨﻔﻴ ﻥ‬ ‫ﺍ ﻓﻲﺍﻟﺘ ﺼﻤﻴﻡ‬ ‫ﺍ ﻤﺎ ﻗﻤﻨﺎ ﺒﺎﻟﺘﻤﻌ ﻥ ﺠﻴﺩ‬ ‫‪ ،‬ﺇﺫ‬ ‫ﺒﺎﻹ ﻅﺎﻓﺔ ﺇﻟﻰ ﺫﻟ ﻙ‬ ‫ﺍﺍﻟﻤﻨﻬﺎﺝ ‪Clear‬‬ ‫‪ ،‬ﺒ ﺤﻴﺙﺃ ﻥ ﻁﺭﻴﻘﺔ‬ ‫ﺍﺌﺭﺓ ﻗﺩ ﻗﺎﻡ ﺒﺈﻋﺎﺩﺓ ﺘﻌﺭﻴ ﻑﺍﻟﻤﻨﻬﺎﺝ ‪ Display‬ﻭﻜﺫ‬ ‫ﺴ ﻁﺭ ﻭﺩ‬ ‫‪ ،‬ﻭﻨﻔ ﺱﺍﻟﻔﻜﺭﺓ ﺘﻨ ﻁﺒﻕ ﻋﻠﻰ ﻁﺭﻴﻘﺔﺍﻟﻤ ﺤﻭ‪ :‬ﺇﻨﻪ‬ ‫ﺍﺌﺭﺓ‬ ‫ﻨﺸﺭﺍﻟﺴ ﻁﺭ ﻤﺜﻼ ﺘﺨﺘﻠ ﻑ ﻋ ﻥ ﻁﺭﻴﻘﺔ ﻨﺸﺭ ﺩ‬ ‫ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ‪Polymorphism‬ﺍﻟﻤ ﻁﺒﻕ ﻋﻠﻰﺍﻟﻤﻨﻬﺎﺠﻴ ﻥ ‪ Display‬ﻭ ‪ Clear‬ﻓﻲ ﺇ ﻁﺎﺭ‬ ‫ﺍﻟ ﺼﻨﻔﻴ ﻥ ﺴﻁ ﺭ ﻭﺩﺍﺌ ﺭﺓ‪.‬‬ ‫‪ ،‬ﻭﻟﻜ ﻥ ﻓﻲﺍﻟﻭﻗ ﺕﺍﻟ ﺤﺎﻟﻲ ﻴﻜﻔﻴ ﻙ ﻤﻌﺭﻓﺔ‬ ‫ﺴﻨﻌﻭﺩ ﺒﺎﻟﺘﻔ ﺼﻴل ﺤﻭل ﻤﻔﻬﻭﻡ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ‬ ‫ﺍﻟﺔ( ﻴﻤﻜﻨﻪﺍﺘﺨﺎﺫ ﻋﺩﺓﺃﺸﻜﺎل‪:‬‬ ‫ﺍﺀ ‪/‬ﺍﻟﺩ‬ ‫ﺃ ﻥﺍﻟﻤﻨﻬﺎﺝ )ﺃﻭﺍﻹﺠﺭ‬ ‫ﺍﻡ ﻨﻔ ﺱﺍﻹﺴﻡ‬ ‫ﺍﺌﺩ ‪overload‬ﺍﻟﺫ ﻱ ﻴﺴﻤﺢ ﺒﺎﺴﺘﺨﺩ‬ ‫‪ v‬ﺸﻜل ﻗﻭ ﻱ‪:‬ﺍﻟﺘ ﺤﻤﻴلﺍﻟ ﺯ‬ ‫ﺍ ﺕﺍﻟﻤﺨﺘﻠﻔﺔ‪.‬‬ ‫ﺍﻤﺘﺭ‬ ‫ﺍﻟﺔ ﻤﻊ ﻗﺎﺌﻤﺔ ﻤ ﻥﺍﻟﺒﺎﺭ‬ ‫ﺍﺀ ‪/‬ﺍﻟﺩ‬ ‫ﻟﻠﻤﻨﻬﺎﺝ ‪/‬ﺍﻹﺠﺭ‬ ‫‪ v‬ﺍﻟﺸﻜلﺍﻟﻘﻭ ﻱﻟﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕﺍﻟﺫ ﻱ ﻴﺘﻌﻠﻕ ﺒﺈﻋﺎﺩﺓ ﺘﻌﺭﻴ ﻑﺍﻟﻤﻨﻬﺎﺝﺍﻟﺘﺎﺒﻊ‬ ‫ﻟﻠ ﺼﻨ ﻑﺍﻷ ﺏ ﻤ ﻥ ﻗﺒلﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﺸﺘﻘﺔ ﻤﻨﻪ ﻤﻊﺍﺴﺘﻌﻤﺎل ﻨﻔ ﺱﺍﻟﺘﻭﻗﻴﻊ‬ ‫ﺍ ﺕ ﻭﻨﻔ ﺱ ﻨﻭﻉ ﻗﻴﻤﺔﺍﻟﻌﻭﺩﺓ(‪.‬‬ ‫ﺍﻤﺘﺭ‬ ‫)ﻨﻔ ﺱ ﻗﺎﺌﻤﺔﺍﻟﺒﺎﺭ‬ ‫ﺍ ﺕ ﻭﻨﻭﻉ ﻗﻴﻤﺔﺍﻟﻌﻭﺩﺓ(ﺍﻟﻤﻨﻬﺎﺠﻴ ﻥﺃﻨﺸ ﺭ‬ ‫ﺍﻤﺘﺭ‬ ‫ﻤ ﻥﺍﻟﻤﻬﻡ ﻤﻼ ﺤ ﻅﺔﺃ ﻥ ﺘﻭﻗﻴﻌﺎ ﺕ ) ﻗﺎﺌﻤﺔﺍﻟﺒﺎﺭ‬ ‫ﺍ ﻴﺴﻤﺢ ﺒ ﻁﻠ ﺏﺍﻟﻤﻨﻬﺎﺝ‬ ‫ﺃﻤﺤﻭ‪ ،‬ﻫﻲ ﻨﻔﺴﻬﺎ ﻓﻲﺍﻟ ﺼﻨ ﻑﺍﻷ ﺏﺃﻜﺜﺭ ﻤﻨﻪ ﻓﻲﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﺸﺘﻘﺔ‪ .‬ﻫﺫ‬ ‫ﻭ‬ ‫‪ ،‬ﻭﻤ ﻥ ﺩﻭ ﻥﺍﻟ ﺤﺎﺠﺔﻟﻤﻌﺭﻓﺔ ﺇﻟﻰﺃ ﻱ ﺼﻨ ﻑ‬ ‫ﻓﻲﺃ ﻱ ﻜﺎﺌ ﻥ ﻤ ﻥ ﻨﻔ ﺱﺍﻟﺘﺴﻠﺴل ﻭﺒﻨﻔ ﺱﺍﻷﺴﻠﻭ ﺏ‬ ‫ﻴﻨﺘﻤﻲﺍﻟﻤﻨﻬﺎﺝﺍﻟﻤ ﻁﻠﻭ ﺏ‪ .‬ﻗﻭﺓ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ‪ polymorphism‬ﻏﻴﺭ ﻤ ﺤﺩﻭﺩﺓ‪.‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

GraphicObject #NumberOfGraphicObjects: integer # Color : ColorType # X: integer # Y: integer + Create () + Destroy () + GetX() + GetY() + SetX() + SetY() + MoveTo(ToX : integer, ToY : integer) + Display () + Clear ()

Base class: general concept

Derived class: specialized concept

Line # Length: integer # Angle: float + Create () + Destroy () + GetLength(): Integer + SetLength(Value: Integer) + Display () + Clear ()

Circle # Rayon: integer + Create () + Destroy () + GetRayon(): Integer + SetRayon(Value: Integer) + Display () + Clear ()

PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com

‫‪ ،‬ﺘﻡﺍﻻﺴﺘﻐﻨﺎﺀ‬ ‫ﺍﺍﻟﺘ ﺼﻤﻴﻡ‬ ‫ﺍﻜﻡ ﻓﻲ ﻫﺫ‬ ‫ﻤ ﻥﺃﺠل ﺘﻔﺎﺩ ﻱﺍﻟﺘﺭ‬ ‫ﺍ ﺕﺍﻟﻤﻨﺎ ﻫﺞ‪.‬‬ ‫ﺍﻤﺘﺭ‬ ‫ﻋ ﻥﺒﺎﺭ‬ ‫ﻜﺎﺌﻥ ﺒﻴﺎﻨﻲ‬ ‫اﻟ ﺼﻨ ﻒ اﻟﻘﺎﻋﺪ ي‪:‬‬ ‫ﻔﻬﻮم اﻟﻌﺎم‬ ‫اﻟﻤ‬

‫‪ #‬ﻋﺩﺩﺍﻟﻜﺎﺌﻨﺎ ﺕﺍﻟﺒﻴﺎﻨﻴﺔ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪#‬ﺍﻟﻠﻭ ﻥ‪ :‬ﻨﻭﻉﺍﻟﻠﻭ ﻥ‬ ‫‪ #‬ﺱ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪ #‬ﻉ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪‬ﺩ )(‬ ‫ﺸﻴ‬ ‫‪‬ﻡ )(‬ ‫‪ +‬ﻫﺩ‬ ‫‪ +‬ﺨﺫ ﺱ )(‬ ‫‪ +‬ﺨﺫ ﻉ )(‬ ‫‪ +‬ﻀﻊ ﺱ )(‬ ‫‪ +‬ﻀﻊ ﻉ )(‬ ‫‪ ،‬ﻤﻭ ﻀﻊ ﻉ ‪ :‬ﺼ ﺤﻴﺢ(‬ ‫‪ +‬ﺘ ﺤﺭ ﻙ ﺇﻟﻰ )ﻤﻭ ﻀﻊ ﺱ‪ :‬ﺼ ﺤﻴﺢ‬ ‫‪+‬ﺃﻨﺸﺭ )(‬ ‫‪+‬ﺃﻤ ﺤﻭ )(‬

‫اﻟ ﺼﻨ ﻒ اﻟﻤﺸﺘ ﻖ‪:‬‬ ‫ﻔﻬﻮم اﻟﻤﺘﺨ ﺼ ﺺ‬ ‫اﻟﻤ‬

‫ﺴﻁ ﺭ‬

‫ﺩﺍﺌ ﺭﺓ‬ ‫‪ #‬ﻗ ﻁﺭ‪ :‬ﺼ ﺤﻴﺢ‬

‫‪ #‬ﻁﻭل‪ :‬ﺼ ﺤﻴﺢ‬ ‫ﺍﻭﻴﺔ‪ :‬ﺤﻘﻴﻘﻲ‬ ‫‪ #‬ﺯ‬

‫‪‬ﺩ )(‬ ‫ﺸﻴ‬ ‫‪‬ﻡ )(‬ ‫‪ +‬ﻫﺩ‬ ‫‪ +‬ﺨﺫﺍﻟﻘ ﻁﺭ )(‬ ‫‪ +‬ﻀﻊﺍﻟﻘ ﻁﺭ )(‬ ‫‪+‬ﺃﻨﺸﺭ )(‬ ‫‪+‬ﺃﻤ ﺤﻭ )(‬

‫‪‬ﺩ )(‬ ‫ﺸﻴ‬ ‫‪‬ﻡ )(‬ ‫‪ +‬ﻫﺩ‬ ‫‪ +‬ﺨﺫﺍﻟ ﻁﻭل )(‬ ‫‪ +‬ﻀﻊﺍﻟ ﻁﻭل )ﻗﻴﻤﺔ‪ :‬ﺼ ﺤﻴﺢ(‬ ‫‪+‬ﺃﻨﺸﺭ )(‬ ‫‪+‬ﺃﻤ ﺤﻭ )(‬

‫ﻟ ﺼﻨ ﻑ ‪GraphicObject‬‬ ‫ﺘ ﺴﻠ ﺴلﺍ‬ ‫ﺤﺴ ﺏﺍﻟ ـ ‪UML‬‬ ‫‪ ،‬ﻭ ﺤﻴﺙ‬ ‫ﺍﺜﺔ ﻴﺘﻡﺍﻹﺸﺎﺭﺓ ﺇﻟﻴﻬﺎ ﺒﺴﻬﻡ ﺫﻭ ﻨﻬﺎﻴﺔ ﻤﺜﻠﺜﻴﺔ‬ ‫‪ ،‬ﻋﻼﻗﺔﺍﻟﻭﺭ‬ ‫ﺍﻻﺘﺠﺎﻩ ﻴﻜﻭ ﻥ ﻨ ﺤﻭﺍﻟ ﺼﻨ ﻑﺍﻷ ﺏ‪.‬‬ ‫ﺍ ﺕﺍﻹﺴﻡ‬ ‫ﺍﻟﻤﻨﺎ ﻫﺞﺍﻟﻤﻜﺘﻭﺒﺔ ﺒﺨ ﻁ ﻤﺎﺌل ﻫﻲ ﻤﺠﺭﺩﺓ‪ .‬ﻓﻨﺴﺘﻨﺘﺞ ﻤﺒﺎﺸﺭﺓﺃ ﻥﺍﻷ ﺼﻨﺎ ﻑ ﺫ‬ ‫‪ ،‬ﻭﺒﺎﻟﺘﺎﻟﻲ ﻻ ﻴﻤﻜﻨﻨﺎ ﺨﻠﻕ ﻤﺜﻴﻼ ﺕ ﻋﻨﻬﺎ ﻤﺒﺎﺸﺭﺓ‪.‬‬ ‫ﺍﻟﻤﺎﺌل )‪ (italic‬ﻫﻲﺃﻴ ﻀﺎ ﻤﺠﺭﺩﺓ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫‪ ،‬ﻭﺒﺎﻟﺘﺎﻟﻲ ﻻ ﻴﻤﻜﻨﻨﺎ ﺨﻠﻕ ﻤﺜﻴﻼ ﺕ ﻋﻨﻬﺎ ﻤﺒﺎﺸﺭﺓ‪.‬‬ ‫ﺍﻟﻤﺎﺌل )‪ (italic‬ﻫﻲﺃﻴ ﻀﺎ ﻤﺠﺭﺩﺓ‬ ‫ﺍﻟﺨ ﺼﺎﺌ ﺹﺍﻟﻤﺴ ﻁﺭﺓ ﻫﻲﺃﻋ ﻀﺎ ﺀﻟﻠ ﺼﻨ ﻑ‪.‬‬ ‫‪،‬ﺍﻟﻤﻨﺎ ﻫﺞ ﻭ‬ ‫ﻟﻠﺘﺫﻜﻴﺭ‬ ‫‪،‬‬ ‫‪ ،‬ﺒﺄﺴﻠﻭ ﺏﺃﺩﺒﻲ‬ ‫‪ ،‬ﺇﺫ ﻥ‬ ‫‪ ‬ﻑ ﻤﺭﺓ ﺜﺎﻨﻴﺔ‬ ‫ﺃﺠﻠ ﺏﺍﻨﺘﺒﺎ ﻫ ﻙ ﺇﻟﻰﺃ ﻥﺍﻟﻤﻨﻬﺎﺝ ‪ MoveTo‬ﻟﻡ ﻴﻌﺭ‬ ‫ﺍﺍﻟﺸﻜل‪:‬‬ ‫ﻴﻤﻜﻨﻨﺎ ﺘﺭﻜﻴﺒﻪ ﻋﻠﻰ ﻫﺫ‬ ‫)‪method GraphicObject :: MoveTo (Pos X: Integer, Pos Y: Integer‬‬ ‫{‬ ‫]‪[object Clear‬‬ ‫]‪[object Set X : Pos X‬‬ ‫]‪[object Set Y : Pos Y‬‬ ‫]‪[object Display‬‬ ‫}‬ ‫ﻟﻌﺎ ﻡﻟﻠﻤﻨ ﻬﺎﺝ ‪MoveTo‬‬ ‫ﻟﻜ ﻭﺩﺍ‬ ‫ﺍ‬ ‫ﺍﺍﻟﺘﺭﻜﻴ ﺏ ﺴﻠﻴﻡ ﻤ ﻥ ﺤﻴﺙﺃ ﻥ ﻤﻨﻬﺎﺝ ﻤ ﺤﻭﺍﻟﺴ ﻁﺭ ‪Clear‬‬ ‫ﺇﻨﻪ ﻤ ﻥﺍﻟﺴﻬل ﻤﻼ ﺤ ﻅﺔﺃ ﻥ ﻫﺫ‬ ‫ﺍ ﻤﺎ ﺘﻡ ﺘﻨﻔﻴﺫﺍﻟﻤﻨﻬﺎﺝ ‪ MoveTo‬ﻷ ﻱ ﻜﺎﺌ ﻥ ﻤﺸﺘﻕ ﻤ ﻥﺍﻟ ﺼﻨ ﻑ ‪Line‬‬ ‫‪ ،‬ﻭﻨﻔ ﺱﺍﻟﺸﻲﺀ‬ ‫ﻴﺘﻡ ﻁﻠﺒﻪ ﺇﺫ‬ ‫ﺍ ﺘﻡ‬ ‫ﻟﻠﻜﺎﺌﻨﺎ ﺕﺍﻟﻤﺸﺘﻘﺔ ﻤ ﻥﺍﻟ ﺼﻨ ﻑ ‪ .Circle‬ﻤﺭﺓﺃﺨﺭﻯ ﻨﺴﺘﻌﻤل ﻫﻨﺎ ﻤﺒﺩﺃ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ‪ .‬ﻓﺈﺫ‬ ‫ﺍﺍﻟﻤﻨﻬﺎﺝ ﻴﻘﻭﻡ ﺒ ﻁﻠ ﺏ ‪Clear‬‬ ‫‪ ،‬ﻓﺈ ﻥ ﻫﺫ‬ ‫ﺘ ﻁﺒﻴﻕﺍﻟﻤﻨﻬﺎﺝ ‪ MoveTo‬ﻋﻠﻰ ﻜﺎﺌ ﻥ ﻤ ﻥ ﻨﻭﻉ ‪Circle‬‬ ‫‪،‬‬ ‫ﻭ ‪Display‬ﺍﻟﺘﺎﺒﻌﻴ ﻥﻟﻠ ﺼﻨ ﻑ ‪) Circle‬ﻨﺸﻴﺭ ﺇﻟﻰ ‪ Circle::Display‬ﻭ ‪( Circle::Clear‬‬ ‫ﺃﻤﺎﻟﻭ ﺘﻡ ﺘ ﻁﺒﻴﻕﺍﻟﻤﻨﻬﺎﺝ ‪ MoveTo‬ﻋﻠﻰ ﻜﺎﺌ ﻥ ﻤ ﻥ ﻨﻭﻉ ‪Line‬‬ ‫ﺍ‬ ‫‪ ،‬ﻓﻔﻲ ﻫﺫﻩﺍﻟ ﺤﺎﻟﺔ ﻴﻘﻭﻡ ﻫﺫ‬ ‫ﺍﻟﻤﻨﻬﺎﺝﺒ ﻁﻠ ﺏ ‪ Clear‬ﻭ ‪Display‬ﺍﻟﺘﺎﺒﻌﻴ ﻥﻟﻠ ﺼﻨ ﻑ ‪) Line‬ﻭ ﻫﻤﺎﺍﻟﻤﻨﻬﺎﺠﻴ ﻥ ‪Line::Clear‬‬ ‫ﻭ‪.( Line::Display‬‬ ‫ﺍﻟﺘﻲ ﻨﻭﺭﺩ ﺒﻌ ﻀﻬﺎ‪:‬‬ ‫ﺍﻴﺎ ﻭ‬ ‫‪ ،‬ﻨﺴﺘﺨﻠ ﺹ ﺠﻤﻠﺔ ﻤ ﻥﺍﻟﻤ ﺯ‬ ‫ﺍﺍﻟﻤﺜﺎل‬ ‫ﻤﻊ ﺒﺴﺎ ﻁﺔ ﻫﺫ‬ ‫‪v‬‬ ‫‪v‬‬ ‫‪v‬‬ ‫‪v‬‬ ‫‪v‬‬ ‫‪v‬‬

‫ﺍﺩﺍﻟﻤﺘﺸﺎﺒﻬﺔ ﻭﺠﻌﻠﻨﺎ ﻫﺎ ﻓﻲﺍﻷ ﺼﻨﺎ ﻑ‬ ‫ﺍﻟﻜﻭﺩ ﻴﻜﻭ ﻥﺃﻗل ﺤﺠﻤﺎ ﻷﻨﻨﺎ ﺠﻤﻌﻨﺎﺍﻷﻜﻭ‬ ‫ﺍﻷﻜﺜﺭ ﻋﻤﻭﻤﻴﺔ‪.‬‬ ‫ﺍﻟﻘﺎﻋﺩﻴﺔ ﻭ‬ ‫‪ ،‬ﺒ ﺤﻴﺙﻟﻴ ﺱ‬ ‫‪ ،‬ﻓﻘ ﻁ ﻨﻜﺘ ﺏﺍﻟﻜﻭﺩﺍﻟﺨﺎ ﺹ ﻟﻠ ﺼﻨ ﻑ‬ ‫ﻋﻠﻰ ﻤﺴﺘﻭﻯﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﺸﺘﻘﺔ‬ ‫‪ ،‬ﻭﺒﺎﻟﺘﺎﻟﻲ ﻴﺴﻴﺭﺍﻟﺘ ﻁﻭﻴﺭ‬ ‫ﺍﻋﻲ ﺇﻋﺎﺩﺓ ﻨﻔ ﺱﺍﻟﺘﻌﻠﻴﻤﺎ ﺕ ﻋﻨﺩ ﻜل ﻤﺭ ﺤﻠﺔ‬ ‫ﻤ ﻥﺍﻟﺩ‬ ‫ﺒﻭﺜﻴﺭﺓ ﺴﺭﻴﻌﺔ‪.‬‬ ‫‪ ،‬ﻭﺒﺎﻟﺘﺎﻟﻲ ﻴﻤﻜ ﻥ‬ ‫‪ ،‬ﻴﺠﻌل ﻨ ﻅﺎﻡﺍﻟﻌﻤل ﻤﻬﻴﻜﻼ ﺒﺄﺴﻠﻭ ﺏ ﺠﻤﻴل‬ ‫ﻗﻭﻟﺒﺔ ﻤﻔﻬﻭﻡ ﻤﺎ‬ ‫ﺘ ﻁﻭﻴﺭﻩ‪.‬‬ ‫ﺍﻩ ﻻ ﺤﻘﺎ‪.‬‬ ‫‪ ،‬ﻜﻤﺎ ﺴﻨﺭ‬ ‫ﺍﺜﺔ‬ ‫ﻤﻴﻜﺎﻨﻴ ﺯﻡ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕﺍﻟﻘﻭ ﻱ ﻴﻌﺘﻤﺩ ﺘﻤﺎﻤﺎ ﻋﻠﻰﺍﻟﻭﺭ‬ ‫‪ ،‬ﻤﻤﺎ‬ ‫ﺍﻤﻪ ﻏﺎﻟﺒﺎ‬ ‫ﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻌﺎﻤﺔ( ﻴﺘﻡﺍﺴﺘﺨﺩ‬ ‫ﻜﻭﺩﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻌﻠﻴﺎ ﻓﻲﺍﻟﺘﺴﻠﺴل )‬ ‫ﺍﻷﺨ ﻁﺎﺀ ‪.debug‬‬ ‫ﺍﺕﻭ‬ ‫ﻴﺴﻬل ﻋﻤﻠﻴﺔﺍﻜﺘﺸﺎ ﻑﺍﻟﺜﻐﺭ‬ ‫‪ ،‬ﻓﺈﻨﻪ ﻴ ﺼﻴﺭ ﻤ ﻥﺍﻟﺴﻬل ﺇ ﻀﺎﻓﺔﺃ ﺼﻨﺎ ﻑ‬ ‫ﺍ ﺒ ﻁﺭﻴﻘﺔ ﺠﻴﺩﺓ‬ ‫‪‬ﺭ‬ ‫ﺍ ﻜﺎ ﻥﺍﻟﺘﺴﻠﺴل ﻤ ﺼﻭ‬ ‫ﺇﺫ‬ ‫‪ ،‬ﻤﻊﺍﻷﺨﺫ ﺒﻌﻴ ﻥﺍﻻﻋﺘﺒﺎﺭﺍﻻﺨﺘﻼﻓﺎ ﺕﺍﻟﻤﻭﺠﻭﺩﺓ ﺒﻴ ﻥﺍﻟ ﺼﻨ ﻑﺍﻟﺠﺩﻴﺩ‬ ‫ﺠﺩﻴﺩﺓ‬ ‫ﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﻭﺠﻭﺩﺓ ﻀﻤ ﻥﺍﻟﺘﺴﻠﺴل‪:‬ﻨﺘﻜﻠﻡ ﺇﺫ ﻥ ﻋ ﻥﺍﻟﺒﺭﻤﺠﺔﺍﻟﻤﺘﻨﻭﻋﺔ‬ ‫ﻭ‬ ‫‪.differential programming‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫‪.٣‬‬

‫ﻟﺒﺔ ﺤﻅﻴﺭﺓﻟﻠﻌﺭﺒﺎﺕ‬ ‫ﻟﺜﺎﻨﻲ‪:‬ﻗ ﻭ‬ ‫ﻟﻤﺜﺎلﺍ‬ ‫‪ .٢‬ﺍ‬

‫ﺍﻟﺘﺨ ﺼﻴ ﺹ ﻤ ﻥﺃﺠل ﺘﺭﻜﻴ ﺏ ﻨ ﻅﺎﻡ ﺫﻭ‬ ‫ﺍﻡﺍﻟﺘﻌﻤﻴﻡ‪/‬‬ ‫ﺍﺍﻟﻤﺜﺎلﺃﺴﻠﻭ ﺏﺍﺴﺘﺨﺩ‬ ‫ﺴﻴﺒﻴ ﻥﻟﻨﺎ ﻫﺫ‬ ‫ﺘﻭﺠﻪ ﻜﺎﺌﻨﻲ ﻨﺎﺠﻊ‪.‬‬ ‫ﺘﺘﻭﻓﺭ ﻤﺅﺴﺴﺔ ﻋﻠﻰ ﺤ ﻅﻴﺭﺓ ﻋﺭﺒﺎ ﺕ ﺘ ﻀﻡ‪:‬‬ ‫‪v‬‬ ‫‪v‬‬ ‫‪v‬‬ ‫‪v‬‬

‫ﺍ ﺕ ‪Cars‬‬ ‫ﺴﻴﺎﺭ‬ ‫ﺸﺎ ﺤﻨﺎ ﺕ ‪Trucks‬‬ ‫ﺍﻓﺎ ﺕ ‪Helicopters‬‬ ‫ﻁﻭ‬ ‫ﺴﻔ ﻥ ‪Boats‬‬

‫ﺘﻭﺩ ﻫﺫﻩﺍﻟﻤﺅﺴﺴﺔ ﺇﻨﺠﺎ ﺯ ﻨﻤﻭﺫﺝ ﻴﻤﻜ ﻥ ﻤ ﻥ ﺨﻼﻟﻪ ﻭ ﻀﻊﺃ ﻱ ﻨﻭﻉ ﻤ ﻥﺍﻟﻌﺭﺒﺎ ﺕ ﻀﻤ ﻥ‬ ‫ﺍﻟﻘﺎﻟ ﺏﺍﻟﻤﻼﺌﻡﻟﻪ‪.‬ﺍﻟﻬﺩ ﻑ ﻫﻭ ﺨﻠﻕ ﻨ ﻅﺎﻡﺃ ﺼﻨﺎ ﻑ ﻴﺘﻡ ﻋ ﻥ ﻁﺭﻴﻘﻪﺍﻟﺘﻌﺎﻤل ﺒﻨ ﻅﺎﻡ ﻤﻊ ﺨ ﺼﻭ ﺼﻴﺎ ﺕ‬ ‫ﺍﻟﺸﺎ ﺤﻨﺔ‬ ‫‪ ،‬ﻓﻨﻼ ﺤ ﻅﺃ ﻥﺍﻟﺴﻴﺎﺭﺓ ﻭ‬ ‫ﺍﻉﺍﻟﺘﻲ ﻴﻤﻜ ﻥ ﻗﻭﻟﺒﺘﻬﺎ‬ ‫ﻜل ﻨﻭﻉ ﻤ ﻥﺍﻟﻌﺭﺒﺎ ﺕ‪ .‬ﻨﻨ ﻁﻠﻕ ﻤ ﻥﺍﻷﻨﻭ‬ ‫ﺍﻓﺔ ﻭﺴﻔﻴﻨﺔ ﻓﻲﺍﻟﺠﺎﻨ ﺏﺍﻵﺨﺭ‪.‬‬ ‫‪ ،‬ﻭﻨﺘﺭ ﻙﺍﻟ ﺼﻨﻔﻴ ﻥﺍﻵﺨﺭﻴ ﻥ‪ :‬ﻁﻭ‬ ‫ﻴﻤﻜ ﻥﺍﺸﺘﻘﺎﻗﻬﻤﺎ ﻤ ﻥ ﻨﻔ ﺱﺍﻟ ﺼﻨ ﻑ‬ ‫‪ ،‬ﺇﻻﺃﻨﻬﺎ ﺘﺘﻘﺎﺴﻡﺍﻟﻌﺩﻴﺩ ﻤ ﻥ‬ ‫ﺍ ﻀﺢ ﺒﻴ ﻥﺍﻟﻌﺭﺒﺎ ﺕ‬ ‫‪ ،‬ﻓﻌﻠﻰﺍﻟﺭ ﻏﻡ ﻤ ﻥﺍﻻﺨﺘﻼ ﻑﺍﻟﻭ‬ ‫ﻭ ﺯﻴﺎﺩﺓ ﻋﻠﻰ ﺫﻟ ﻙ‬ ‫‪،‬ﺍﻟﺘﺒﺎ ﻁﺅ‬ ‫ﺍﻉ‬ ‫‪،‬ﺍﻹﺴﺭ‬ ‫ﺍﻟﺨ ﺼﻭ ﺼﻴﺎ ﺕ ﻤ ﻥ ﺤﻴﺙ ﺸﻜﻠﻬﺎﺍﻟﻤﺘ ﺤﺭ ﻙ‪ .‬ﻭﺃﻴ ﻀﺎ ﺒﺒﻌ ﺽﺍﻟﻨﺸﺎ ﻁﺎ ﺕ ﻜﺎﻹﻗﻼﻉ‬ ‫‪ ،‬ﻜلﺃ ﺼﻨﺎﻓﻨﺎﻟﻬﺎ‬ ‫ﺍﻉﺍﻟﻌﺭﺒﺎ ﺕ‪.‬ﺃﻴ ﻀﺎ‬ ‫ﺃﻭﺍﻟﺘﻭﻗ ﻑ‪ .‬ﻓﻜل ﻫﺫﻩﺍﻷﻋﻤﺎلﻟﻬﺎ ﻤﻌﺎ ﻥ ﻟﻜل ﻨﻭﻉ ﻤ ﻥﺃﻨﻭ‬ ‫ﺍﻟﺫ ﻱ ﻨﺴﻤﻴﻪ‪ :‬ﻋ ﺭﺒﺔ‪.‬‬ ‫‪،‬ﻭ‬ ‫ﺍ ﺤﺩ‬ ‫ﺃ ﺼلﺃﻭ ﺠﺩ ﻭ‬ ‫ﺇﺫ ﻥ ﻨ ﺤ ﺼل ﻋﻠﻰﺍﻟﻨﻤﻭﺫﺝﺍﻵﺘﻲ‪:‬‬

‫‪Vehicle‬‬

‫‪Boat‬‬

‫‪Helicopter‬‬

‫‪RollingVehicle‬‬

‫‪Truck‬‬

‫‪Car‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﻋﺭﺒﺔ‬

‫ﺴﻔﻴﻨﺔ‬

‫‪‬ﺍﺭﺓ‬ ‫ﻋﺭﺒﺔ ﺩ ﻭ‬

‫ﻁﻭﺍﻓﺔ‬

‫ﺘﺴﻠﺴل ﻤﻤﻜ ﻥﻟﻸ ﺼﻨﺎ ﻑ ﻤ ﻥﺃﺠل ﺤ ﻅﻴﺭﺓ‬ ‫ﻋﺭﺒﺎ ﺕ ﻨﻤﻭﺫﺠﻴﺔ ﻏﻴﺭ ﻤﺘﺠﺎﻨﺴﺔ‬

‫ﺴﻴﺎ ﺭﺓ‬

‫ﺸﺎﺤﻨﺔ‬

‫ﻨﻤ ﻭﺫﺝﻟﺤﻅﻴﺭﺓ ﻋﺭﺒﺎﺕ‬ ‫‪،‬‬ ‫‪،‬ﺍﺘﺒﻌﻨﺎﺃﺴﻠﻭ ﺏﺍﻟﺘﻌﻤﻴﻡ‪ :‬ﻤ ﻥ ﺨﻼل ﻤﺠﻤﻭﻉﺍﻟﻜﺎﺌﻨﺎ ﺕ‬ ‫ﺍﺍﻟﻨﻤﻭﺫﺝ‬ ‫ﻤ ﻥﺃﺠل ﺘ ﺤﻘﻴﻕ ﻫﺫ‬ ‫ﺍﺍﻷﺴﻠﻭ ﺏ‬ ‫ﺍﺴﺘﺨﻠ ﺼﻨﺎﺍﻟﻌﻨﺎ ﺼﺭﺍﻟﻤﺸﺘﺭﻜﺔﺍﻟﺘﻲ ﺘﺴﻤﺢﻟﻨﺎ ﺒﺠﻤﻌﻬﺎ ﻭﻭ ﻀﻌﻬﺎ ﻓﻲ ﺇ ﻁﺎﺭ ﻋﺎﻡ‪ .‬ﻫﺫ‬ ‫‪ ،‬ﻭ ﻫﻭ ﻨﻤ ﻁ ﻤﺴﺘ ﺤﺴ ﻥﻟﺨﻠﻕ ﺘﺴﻠﺴلﺃ ﺼﻨﺎ ﻑ‪.‬‬ ‫ﻴﺴﻤﻰﺍﻟﺘﻌﻤﻴﻡ‬ ‫ﺍﺝﺃ ﺼﻨﺎ ﻑ ﺠﺩﻴﺩﺓ ﻀﻤ ﻥ ﻨ ﻅﺎﻡ‬ ‫ﺍ ﺘﻌﻠﻕﺍﻷﻤﺭ ﺒﺈﺩﺭ‬ ‫ﺃﺴﻠﻭ ﺏﺍﻟﺘﺨ ﺼﻴ ﺹ ﻴﺴﺘﺨﺩﻡ ﺒﻜﺜﺭﺓ ﺇﺫ‬ ‫‪ ،‬ﻓﺈﻨﻪ ﻴﻜﻭ ﻥ ﺒﺎﻹﻤﻜﺎ ﻥ‬ ‫ﺍﺕ‬ ‫ﺍﺭﺓ ﺇﻟﻰﺍﻗﺘﻨﺎﺀ ﺒﻌ ﺽﺍﻟ ﻁﺎﺌﺭ‬ ‫ﺍ ﺴﻌ ﺕﺍﻹﺩ‬ ‫‪ ،‬ﺇﺫ‬ ‫ﻤﻭﺠﻭﺩ ﻤﺴﺒﻘﺎ‪ .‬ﻋﻠﻰ ﻜل‬ ‫‪،‬‬ ‫ﺍﻟﺘﻲ ﻨﺸﺘﻕ ﻤﻨﻬﺎ ﻁﺎﺌ ﺭﺓ ﻭ ﻁﻭﺍﻓﺔ‬ ‫‪،‬ﻭ‬ ‫ﺇ ﻀﺎﻓﺔ ﺼﻨ ﻑ ﺠﺩﻴﺩ )ﻤ ﻥ ﺨﻼلﺍﻟﺘﻌﻤﻴﻡ( ‪AerialVehicle‬‬ ‫ﻓﻨ ﺤ ﺼل ﺇﺫ ﻥ ﻋﻠﻰﺍﻟﺘ ﺼﻤﻴﻡﺍﻵﺘﻲ‪:‬‬ ‫‪Vehicle‬‬

‫‪Boat‬‬

‫‪AerialVehicle‬‬

‫‪Airplane‬‬

‫‪Helicopter‬‬

‫‪RollingVehicle‬‬

‫‪Truck‬‬

‫‪Car‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﺘﺴﻠﺴل ﻤﻤﻜ ﻥﻟﻸ ﺼﻨﺎ ﻑ ﻤ ﻥﺃﺠل‬ ‫‪،‬‬ ‫ﺤ ﻅﻴﺭﺓ ﻨﻤﻭﺫﺠﻴﺔ ﻋﺭﺒﺎ ﺕ ﻏﻴﺭ ﻤﺘﺠﺎﻨﺴﺔ‬ ‫ﺍﺕ‬ ‫ﺒﻌﺩ ﺇ ﻀﺎﻓﺔﺍﻟ ﻁﺎﺌﺭ‬

‫ﻋﺭﺒﺔ ﻁﻴﺎﺭﺓ‬

‫ﺴﻔﻴﻨﺔ‬

‫ﻁﺎﺌ ﺭﺓ‬

‫ﻁﻭﺍﻓﺔ‬

‫ﻋﺭﺒﺔ‬

‫‪‬ﺍﺭﺓ‬ ‫ﻋﺭﺒﺔ ﺩ ﻭ‬

‫ﺸﺎﺤﻨﺔ‬

‫ﺴﻴﺎ ﺭﺓ‬

‫ﺍﺍﻟﻨﻭﻉ ﻤ ﻥﺍﻟﺘﺭﺘﻴ ﺏ ﻴﺄﺨﺫﺃ ﺤﻴﺎﻨﺎ ﺇﺴﻡ ‪taxonomy‬‬ ‫‪ ،‬ﻓﻤ ﻥﺃﺠل ﻭ ﻀﻊ ﺘﻘﺩﻴﻡ ﻟﻬﺫﻩ‬ ‫ﻫﺫ‬ ‫ﺍﺒ ﻁﺔﻟﺠﻌل ﺘ ﺼﻨﻴ ﻑ‬ ‫ﺍ ﺕ ﺩﻭﻤﺎ ﻋ ﻥ ﻭﺴﺎﺌل ﺘ ﻁﺒﻴﻘﻴﺔ ﻤﺘﺭ‬ ‫ﺍﻟﻤﺒﺎﺩﺭﺓ‪ :‬ﻴﺒ ﺤﺙﺍﻟﻤﺘﺨ ﺼ ﺼﻭ ﻥ ﻓﻲﺍﻟ ﺤﺸﺭ‬ ‫ﺍ ﺕ ﻴﺴﻴﺭ ﻓﻲﺃ ﺤﺴ ﻥ ﻤﺎ ﻴﻤﻜ ﻥ‪.‬‬ ‫ﺍﻟ ﺤﺸﺭ‬ ‫ﻤﺒﺩﺃﺍﻟﺘﻌﻤﻴﻡ‪/‬ﺍﻟﺘﺨ ﺼﻴ ﺹ ﻫﻭ ﺒﺩﻴﻬﻲ ﻭﻗﻭ ﻱ ﻷﻨﻪ ﻴﺴﻤﺢ ﺒﺘﻌﺭﻴ ﻑﺍﻟﺘ ﺼﺭﻓﺎ ﺕﺍﻟﻤﺘﺸﺎﺒﻬﺔ‬ ‫‪ ،‬ﻜل ﺼﻨ ﻑ ﻓﺭﻋﻲ ﻴﻤﻜﻨﻨﺎﺍﻻﺨﺘﻴﺎﺭ ﺒﻴ ﻥ ﺇﻋﺎﺩﺓ ﺘﻌﺭﻴﻔﻪﺃﻭ ﺘﻭﺭﻴﺜﻪ‬ ‫ﻋﻠﻰ ﻁﻭل ﺸﺠﺭﺓﺍﻹﺸﺘﻘﺎﻗﺎ ﺕ‬ ‫ﻤ ﻥﺍﻟ ﺼﻨ ﻑﺍﻷﻋﻠﻰ ﻤﻨﻪ‪.‬‬ ‫ﻟﻤﺠﺭﺩﺓ‪abstract :‬‬ ‫‪ .٣ .٣‬ﺍﻷ ﺼﻨﺎ ﻑﺍ‬ ‫‪،‬‬ ‫‪ ،‬ﻋﺭﺒﺔ ﺩﻭﺍﺭﺓ ﻭ ﻋﺭﺒﺔ ﻁﻴﺎ ﺭﺓ‬ ‫‪ ،‬ﻻﺒﺩ ﻭﺃﻨﻨﺎ ﻻ ﺤ ﻅﻨﺎﺃ ﻥﺍﻷ ﺼﻨﺎ ﻑ ﻋﺭﺒﺔ‬ ‫ﺍﺀﺓ ﻤﺘﻤﻌﻨﺔ‬ ‫ﺒﻘﺭ‬ ‫‪ ،‬ﻭﻟﻜ ﻥ ﻷ ﻥ ﻫﺫﻩ‬ ‫ﺍ ﻟﻴ ﺱ ﻤ ﻥ ﺒﺎ ﺏ ﺘﻨﻤﻴﻕﺍﻟﺘ ﺼﻤﻴﻡ‬ ‫ﻤﻜﺘﻭﺒﺔ ﺒﺨ ﻁ ﻤﺎﺌل ﻓﻲ ﺍﻟﺘ ﺼﻤﻴﻡﺍﻟﺴﺎﺒﻕ‪ .‬ﻫﺫ‬ ‫ﺍﻷ ﺼﻨﺎ ﻑ ﻫﻲ ﻤﺠﺭﺩﺓ‪.‬‬ ‫ﺍ ﻜﺎﻨ ﺕ ﻻ ﺘﻤﻨﺢ ﻋﻤﻼ ﺒﺭﻤﺠﻴﺎ ‪implementation‬‬ ‫ﻨﻘﻭل ﻋ ﻥﺃ ﺼﻨﺎ ﻑﺃﻨﻬﺎ ﻤﺠﺭﺩﺓ ﺇﺫ‬ ‫‪ ،‬ﻻ‬ ‫‪،‬ﺍﻟ ﺼﻨ ﻑﺍﻟﻤﺠﺭﺩ‬ ‫ﺍلﺍﻟﻐﻤﻭ ﺽ؟ ﻋﻠﻰ ﻜل‬ ‫‪ ،‬ﻭﻤﻨﺎ ﻫﺠﻬﺎ ﺘ ﺼﻴﺭﺃﻴ ﻀﺎ ﻤﺠﺭﺩﺓ‪ .‬ﺭﺒﻤﺎ ﻤﺎ ﺯ‬ ‫ﻟﻤﻨﺎ ﻫﺠﻬﺎ‬ ‫‪ ،‬ﻴﻤﻜ ﻥ ﺫﻟ ﻙﻟﻸ ﺼﻨﺎ ﻑﺍﻟﻤﺸﺘﻘﺔ ﻤﻨﻪ ﻤ ﻥ ﺨﻼل ﺘﻭﻓﻴﺭﺍﻟﻜﻭﺩﻟﻜل‬ ‫ﻴﻤﻜﻨﻪﺃ ﻥ ﻴﺨﻠﻕ ﻤﺜﻴﻼ ﺕ )ﻜﺎﺌﻨﺎ ﺕ(‬ ‫‪ ،‬ﻭﺒﺎﻟﺘﺎﻟﻲ ﻴ ﺯﻭل ﻋﻨﻬﺎﺍﻟﺘﺠﺭﻴﺩ ﻭﺘ ﺼﻴﺭ ﻗﺎﺩﺭﺓ ﻋﻠﻰﺍﻟﻘﻴﺎﻡ ﺒﻌﻤل‬ ‫ﻤ ﻥﺍﻟﻤﻨﺎ ﻫﺞﺍﻟﺘﻲ ﻜﺎﻨ ﺕ ﻤﺠﺭﺩﺓ‬ ‫‪ ،‬ﻨﺘﻜﻠﻡ ﺇﺫ ﻥ ﻋﻡﺃ ﺼﻨﺎ ﻑ ﺤﺴﻴﺔ ‪.concrete‬ﺍﻷ ﺼﻨﺎ ﻑﺍﻟ ﺤﺴﻴﺔ ﻫﻲﺍﻟﻭ ﺤﻴﺩﺓﺍﻟﻘﺎﺩﺭﺓ ﻋﻠﻰ‬ ‫ﺒﺭﻤﺠﻲ‬ ‫ﺨﻠﻕ ﻤﺜﻴﻼ ﺕ‪.‬‬ ‫ﻤﺎ ﻫﻭ ﻫﺩ ﻑﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﺠﺭﺩﺓ؟ ﻫﻭ ﺨﻠﻕ ﺇ ﻁﺎﺭ ﻋﻤلﻟﻸ ﺼﻨﺎ ﻑﺍﻟﻤﺸﺘﻘﺔ ﻤ ﻥ ﺨﻼل‬ ‫ﺍﻟﺘﺴﻠﺴل ﻓﻲﺍﻷ ﺼﻨﺎ ﻑ‬ ‫ﺘﻘﺩﻴﻡ ﻤﺠﻤﻭﻋﺔ ﻤ ﻥﺍﻟﻤﻨﺎ ﻫﺞﺍﻟﺘﻲ ﻨﺠﺩ ﻫﺎ ﻋﻠﻰ ﻁﻭلﺍﻟﺘﻔﺭﻉ )‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫‪ ،‬ﺘﻌﺘﺒﺭ ﻫﺫﻩﺍﻵﻟﻴﺔﺃﺴﺎﺴﻴﺔﻟﺘ ﺤﻘﻴﻕ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ‪.polymorphism‬‬ ‫ﺍﻹﺒ ﻥ‪(...‬‬ ‫ﺍﻷ ﺏ‪/‬‬ ‫ﺍﻟﺠﺩ‪/‬‬ ‫‪ ،‬ﻓﻤ ﻥﺍﻟ ﻁﺒﻴﻌﻲﺃﻨﻪ ﻻ ﻴﻤﻜﻨﻨﺎﺃ ﻥ ﻨﺨﻠﻕ ﻤﺜﻴﻼ ﺕ ﻋﻨﻪ‪ :‬ﻋ ﺭﺒﺔ‬ ‫ﺍ ﻤﺎﺍﻋﺘﺒﺭﻨﺎﺍﻟ ﺼﻨ ﻑ ﻋ ﺭﺒﺔ‬ ‫‪ ،‬ﺇﺫ‬ ‫ﺒﺎﻟﻤﻘﺎﺒل‬ ‫‪،‬‬ ‫‪ ،‬ﻭﻟﻜ ﻥ ﺘﺭﻤ ﺯ ﺇﻟﻰ ﻤﻔﻬﻭﻡ ﻜﺎﺌ ﻥ ﻴﻘﻠﻊ ﻭﻴﺒ ﻁ ﺊ ﻭﻴﺴﺎﺭﻉﺃﻭ ﻴﺘﻭﻗ ﻑ‬ ‫ﻻ ﺘﺭﻤ ﺯ ﺇﻟﻰﺃ ﻱ ﻜﺎﺌ ﻥ ﺤﺴﻲ‬ ‫ﺍﺍﻟﻜﺎﺌ ﻥ ﺴﻴﺎﺭﺓﺃﻭ ﻁﺎﺌﺭﺓﺃﻭ ﺸﺎ ﺤﻨﺔ‪.‬‬ ‫ﺍﺀ ﻜﺎ ﻥ ﻫﺫ‬ ‫ﺴﻭ‬ ‫ﺍﺴﺔ‬ ‫ﺍ ﻴﺘﻌﻠﻕ ﻏﺎﻟﺒﺎ ﺒﺩﻓﺘﺭ ﺤﻤﻭﻟﺔﺍﻟﺒﺭﻨﺎﻤﺞ‪ .‬ﺒﺩﺭ‬ ‫‪ ،‬ﻫﺫ‬ ‫ﺍﺍﻟﻜﺎﺌ ﻥ ﺤﺴﻲﺃﻭ ﻤﺠﺭﺩ‬ ‫ﺘ ﺤﺩﻴﺩ ﻤﺎ ﺇﺫ‬ ‫‪ ،‬ﻴﻤﻜ ﻥ ﺘ ﺤﺩﻴﺩ ﻤﺎ ﻫﻲﺍﻷ ﺼﻨﺎ ﻑﺍﻟ ﺤﺴﻴﺔ‪:‬ﺍﻟﺘﻲ ﺘﻤﺘﻠ ﻙ ﻤﺜﻴﻼ ﺕ‪ .‬ﻭﻤ ﻥ ﺨﻼل‬ ‫ﺍﺍﻷﺨﻴﺭ‬ ‫ﻤﺘﻌﻤﻘﺔ ﻟﻬﺫ‬ ‫ﺍﻟﺘﻲ ﺘﺴﻤﺢﺒﺎﻻﺴﺘﻔﺎﺩﺓ ﻤ ﻥ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ‬ ‫ﻫﺫﻩﺍﻷﺨﻴﺭﺓ ﻴﻤﻜ ﻥ ﺘ ﺤﺩﻴﺩﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﺠﺭﺩﺓ ﻭ‬ ‫ﺍﺒﺎﺘﺒﺎﻉﺃﺴﻠﻭ ﺏﺍﻟﺘﻌﻤﻴﻡ‪.‬‬ ‫‪ ،polymorphism‬ﻭ ﻫﺫ‬ ‫‪.٣‬‬

‫ﻟ ﻭﺭﺍﺜﺔ‪:‬‬ ‫ﻟﻤﺭﺘﺒﻁﺔ ﺒﺎ ﺴﺘﺨﺩﺍ ﻡﺍ‬ ‫ﻟ ﺼﻌ ﻭﺒﺎﺕﺍ‬ ‫‪ .٤‬ﺍ‬

‫ﺴﻨﺭﻯ ﻨﻤﻭﺫﺠﻴ ﻥ ﺤﻴﺙ ﻜﺎ ﻥﺍﻟﺘﻘﺴﻴﻡ ﻭ ﻫﻤﻲ‪ .‬ﻏﺎﻟﺒﺎ ﻤﺎ ﻴﻜﻭ ﻥ ﺘ ﺤﺩﻴﺩﺍﻟﺘﺴﻠﺴلﺍﻟﻤﻨﺎﺴ ﺏ‬ ‫ﺍﺭ ﺨﺎ ﺹ‬ ‫ﺍﺜﺔ ﻴﺠ ﺏﺃ ﻥ ﺘﺘﺭﺠﻡ ﺇﻟﻰ "ﺍﻟ ﺼﻨ ﻑﺍﻟﻤﺸﺘﻕ ﻫﻭ ﺇ ﺼﺩ‬ ‫‪ ،‬ﻋﻼﻗﺔﺍﻟﻭﺭ‬ ‫ﺼﻌﺒﺎ‪.‬ﺍﻟﻘﺎﻋﺩﺓ ﺴﻬﻠﺔ‬ ‫ﻤ ﻥ ﺼﻨﻔﻪﺍﻟﻘﺎﻋﺩ ﻱ "‪.‬‬ ‫‪.٣‬‬

‫ﺪا‪:‬‬ ‫‪ .٠ ١ .٤‬ﺗﺴﻠﺴ ﻞ ﻣ ﻜﺜ ﻒ ﺟ‬

‫ﻴﺠ ﺏﺍﻻﻨﺘﺒﺎﻩ ﺇﻟﻰ ﻋﺩﻡ ﺘﻜﺜﻴ ﻑ ﻭﺇﺜﻘﺎلﺍﻟﺘﺴﻠﺴل ﺒﺎﻻﺸﺘﻘﺎﻕﺍﻟﻐﻴﺭ ﻤﻨ ﻅﻡ‪ .‬ﻓﻠﻨﻌﺘﺒﺭ ﻤﺜﻼ‬ ‫‪ ،‬ﻷﻨﻨﺎ ﻨﻔﻬﻡ‬ ‫‪ ،‬ﻻ ﻴﻤﻜﻨﻨﺎﺍﻟﺘﻌﻠﻴﻕ‬ ‫ﺍﻟﺫ ﻱ ﻤﻨﻪ ﻨﺸﺘﻕﺍﻟ ﺼﻨﻔﻴ ﻥ ﻗﻁ ﻭ ﻜﻠﺏ‪ .‬ﻓﻠ ﺤﺩﺍﻵ ﻥ‬ ‫‪،‬ﻭ‬ ‫ﺍﻟ ﺼﻨ ﻑ ﺤﻴﻭﺍﻥ‬ ‫‪ ،‬ﻴﻌﺘﺒﺭ‬ ‫ﺒﺄ ﻥﺍﻻﺨﺘﻼ ﻑﺍﻟﻤﻭﺠﻭﺩ ﺒﻴ ﻥ ﻫﺫﻴ ﻥﺍﻟﻨﻭﻋﻴ ﻥ ﻴﺘ ﻁﻠ ﺏ ﻤﻨﺎ ﺨﻠﻕ ﺼﻨﻔﻴ ﻥ ﻤﺨﺘﻠﻔﻴ ﻥ‪ .‬ﺒﺎﻟﻤﻘﺎﺒل‬ ‫‪،‬‬ ‫‪ ،‬ﻓﺒﺴﺒ ﺏﻟﻭ ﻥﺍﻟﺸﻌﺭ‬ ‫‪ ،‬ﺴﻭﺀﻟﻠﺘﻘﺩﻴﺭ‬ ‫ﺃ ﺼﻔ ﺭ ﻤ ﻥﺍﻟ ﺼﻨ ﻑ ﻜﻠﺏ‬ ‫ﺃﺴﻭﺩ ﻭ ﻜﻠﺏ_‬ ‫ﺍﺸﺘﻘﺎﻕﺍﻟ ﺼﻨﻔﻴ ﻥ ﻜﻠﺏ_‬ ‫‪ ،‬ﻤﻤﺎ ﺴﻴﺜﻘلﺍﻟﺘﺴﻠﺴل ﻷﺴﺒﺎ ﺏ ﺒﺴﻴ ﻁﺔ‪ .‬ﻜﺎ ﻥ ﻤ ﻥﺍﻷ ﺤﺴ ﻥ ﺩﻤﺞ‬ ‫‪،‬ﺃﻭ ﻋﺩﺓﺃ ﺼﻨﺎ ﻑ‬ ‫ﺘﻡ ﺨﻠﻕ ﺼﻨﻔﻴ ﻥ‬ ‫ﺼﻔﺔﺍﻟﻠﻭ ﻥ )ﺃﻭ ﺒﻌ ﺽﺍﻟ ﺼﻔﺎ ﺕﺍﻟﺒﺴﻴ ﻁﺔ( ﻀﻤ ﻥ ﺨ ﺼﺎﺌ ﺹ )ﺒﻴﺎﻨﺎ ﺕ(ﺍﻟ ﺼﻨ ﻑﺍﻷﺴﺎﺴﻲ ﻜﻠﺏ‪.‬‬ ‫‪ ،‬ﻓﺎﻟﺘ ﺼﻤﻴﻡﺍﻵﺘﻲ‬ ‫‪ ،‬ﻴﺠ ﺏﺍﻟ ﺤﺭ ﺱ ﻋﻠﻰ ﻋﺩﻡ ﺩﻤﺞﺃ ﺼﻨﺎ ﻑ ﻭﺴﻴ ﻁﺔ ﻜﺜﻴﺭﺓ‬ ‫ﺒﻨﻔ ﺱﺍﻷﺴﻠﻭ ﺏ‬ ‫ﺍ ﻴﺠ ﺏ ﺤﺫﻓﻪ‪.‬‬ ‫‪،‬ﻟﺫ‬ ‫ﻴﺒﻴ ﻥﺃ ﻥ ﻫﻨﺎ ﻙ ﺼﻨ ﻑ ﻭﺴﻴ ﻁ ﻏﻴﺭ ﻀﺭﻭﺭ ﻱ ﻭﻻ ﻴﻤﻠ ﻙﺃ ﻱﺍﺸﺘﻘﺎﻕ ﺤﻘﻴﻘﻲ‬

‫‪base‬‬

‫‪example of a‬‬ ‫‪superfluous class‬‬ ‫)‪( intermediary1‬‬ ‫)ﻭﺴﻴ ﻁ ‪(١‬‬

‫‪intermediary1‬‬

‫‪paper 1‬‬

‫‪intermediary2‬‬

‫‪paper 3‬‬

‫‪paper 2‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﻗﺎﻋﺩﺓ‬

‫ﻭ ﺴﻴﻁ ‪١‬‬

‫ﻤﺜﺎل ﻋ ﻥ ﺼﻨ ﻑ ﻁﻔﻴﻠﻲ‬ ‫)ﻭﺴﻴ ﻁ ‪(١‬‬

‫ﻭ ﺭﻗﺔ ‪١‬‬

‫ﻭﺴﻴﻁ‪٢‬‬

‫ﻭ ﺭﻗﺔ‪٣‬‬

‫ﻭ ﺭﻗﺔ‪٢‬‬

‫‪ ،‬ﺍﻟ ﺼﻨ ﻑ ﻭﺴﻴﻁ ‪ ١‬ﻻ ﻴﻌﻤل ﺇﻻ ﻋﻠﻰ‬ ‫ﺍ ﻜﺎ ﻥﺍﻟ ﺼﻨ ﻑ ﻗﺎﻋﺩ ﻱ ﻴﻤﺘﻠ ﻙ ﺼﻨﻔﻴ ﻥﺍﺒﻨﻴ ﻥ‬ ‫‪ ،‬ﺇﺫ‬ ‫ﺇﺫ ﻥ‬ ‫ﺇﺜﻘﺎل ﻏﻴﺭ ﻀﺭﻭﺭ ﻱﻟﻠﺘﺴﻠﺴل‪ .‬ﺇﺫ ﻥ ﻫﻭ ﺼﻨ ﻑ ﻤﺠﺭﺩ )ﻜﻤﺎ ﻨﺸﻴﺭ ﺇﻟﻰ ﺨ ﻁﻪ ﺒﻨﻭﻉ ﻤﺎﺌل( ﻭﻻ‬ ‫ﺍ ﺤﺩﺓ‪ .‬ﻴﻤﻜﻨﻨﺎ ﺇﺫ ﻥ ﺤﺫﻓﻪ‬ ‫‪ ،‬ﻭﻓﻲ ﻨﻔ ﺱﺍﻟﻭﻗ ﺕ ﻻ ﻴ‪‬ﺸﺘﻕ ﺇﻻ ﻤﺭﺓ ﻭ‬ ‫ﻴﻤﻜﻨﻪﺃ ﻥ ﻴﻤﺘﻠ ﻙ ﻤﺜﻴﻼ ﺕ )ﻜﺎﺌﻨﺎ ﺕ(‬ ‫ﺍﺍﻟﻤﺜﺎلﻴﺴﻤﺢ ﺒ ﺯﻴﺎﺩﺓ ﻗﺎﻋﺩﺓﻟﻐﻭﻴﺔ‪ :‬ﻨﺴ ﻤﻲ ﻭ ﺭﻗﺔ‬ ‫ﻤﻊ ﺇ ﻀﺎﻓﺔ ﺨ ﺼﺎﺌ ﺼﻪ ﻓﻲﺍﻟ ﺼﻨ ﻑ ﻭﺴﻴﻁ‪ .٢‬ﻫﺫ‬ ‫ﺫ ﻱ ﻻ ﻴ ﻤﻠﻙ ﻤﺸﺘﻘﺎ ﺕ‪.‬‬ ‫ﻟ‬ ‫ﻟ ﺼﻨ ﻑﺍ‬ ‫ﺍ‬ ‫‪.٣‬‬

‫ﺪ‪construction inheritance :‬‬ ‫‪ .٠ ٢ .٤‬وراﺛﺔاﻟﺘﺸﻴﻴ‬

‫‪ ،‬ﺤﻴﺙ ﻴﻨ ﺹ ﻋﻠﻰﺍﺸﺘﻘﺎﻕ‬ ‫ﺍﺜﺔ‬ ‫ﺍﺜﺔﺍﻟﺘﺸﻴﻴﺩ ﻫﻭ ﻤﺜﺎل ﺁﺨﺭ ﺴﻴ ﺊ ﻓﻴﻡ ﻴﺨ ﺹﺍﺴﺘﻌﻤﺎلﺍﻟﻭﺭ‬ ‫ﻭﺭ‬ ‫ﺍ ﻤﺎ ﺘﻡﺍﻋﺘﺒﺎﺭ‬ ‫‪ ،‬ﺇﺫ‬ ‫‪ ،‬ﻤﻊ ﺇ ﻀﺎﻓﺔ ﻟﻪ ﺨ ﺼﺎﺌ ﺹ ﺘﻐﻴﺭ ﺠﺫﺭﻴﺎ ﻤ ﻥﺍﻟﻤﻔﻬﻭﻡﺍﻟﻤﺴﺘﺨﺩﻡ‪ .‬ﻓﻜﻤﺜﺎل‬ ‫ﺼﻨ ﻑ‬ ‫‪ ،‬ﻴﻤﻜ ﻥ ﻤﻼ ﺤ ﻅﺔﺃ ﻥ‬ ‫‪ ،‬ﺜﻡ ﻨﻘﻭﻡ ﺒﺈ ﻀﺎﻓﺔ ﺒﻌﺩ ﺜﺎﻨﻲﻟﻪ‪ .‬ﻋﻠﻰ ﻜل‬ ‫ﺃ ﻥﺍﻟﻤﺴﺘ ﻁﻴل ﻫﻭ ﻋﺒﺎﺭﺓ ﻋ ﻥ ﺴ ﻁﺭ‬ ‫ﺍﺭ ﺨﺎ ﺹ ﻤ ﻥ‬ ‫‪ ،‬ﻷ ﻥﺍﻟﺠﻤﻠﺔ‪" :‬ﺍﻟﻤﺴﺘ ﻁﻴل ﻫﻭ ﺇ ﺼﺩ‬ ‫ﺍﺜﺔ ﻓﻲﺍﻟ ﺤﺎﻟﺔﺍﻷﺨﻴﺭﺓ ﺼﺎﺭ ﺕ ﻏﻴﺭ ﻤﻨﺎﺴﺒﺔ‬ ‫ﺍﻟﻭﺭ‬ ‫ﺍﻟﺴ ﻁﺭ "ﻟﻴ ﺱﻟﻬﺎﺃ ﻱ ﻤﻌﻨﻰ‪.‬‬ ‫‪.٣‬‬

‫‪.٤‬‬

‫ﺎﺳﻘﺔ‪the conceptual incoherence :‬‬ ‫‪ .٠ ٣‬اﻟﺘﺼﻮراتاﻟﻐﻴﺮ ﻣﺘﻨ‬

‫ﺍ ﺕ ﻀﺎﻟﺔ‪ .‬ﻓﻠﻨﻌﺘﺒﺭ ﻤﺜﻼﺍﻟ ﺼﻨ ﻑ ﻁﺎﺌ ﺭﺍﻟﻤ ﺯﻭﺩ‬ ‫ﺍﺜﺔ ﺒﻌ ﺽﺍﻷ ﺤﻴﺎ ﻥ ﺇﻟﻰ ﺘ ﺼﻭﺭ‬ ‫ﺘﺅﺩ ﻱﺍﻟﻭﺭ‬ ‫ﺍﺀ‬ ‫‪ ،‬ﺴﻭ‬ ‫‪ ،‬ﻨﺴﺘ ﻁﻴﻊ ﻤﺜﻼﺍﺸﺘﻘﺎﻕﺍﻟ ﺼﻨ ﻑ ﺩﺠﺎﺠﺔﺍﻟﺘﻲ ﻫﻲ ﻤ ﻥ ﻓ ﺼﻴﻠﺔﺍﻟ ﻁﻴﻭﺭ‬ ‫ﺒﺎﻟﻤﻨﻬﺎﺝﻴﻁﻴ ﺭ‬ ‫‪ ،‬ﻭﻟﻜ ﻥ ﻜل ﻤﻨﺎ ﻴﻌﻠﻡﺃ ﻥﺍﻟﺩﺠﺎﺠﺔ ﻻ ﺘ ﻁﻴﺭ ﺭ ﻏﻡ‬ ‫ﺍﺜﺔﺃﻭ ﻋ ﻥ ﻁﺭﻴﻕ ﺇﻋﺎﺩﺓﺍﻟﺘﻌﺭﻴ ﻑ‬ ‫ﺒﺄﺴﻠﻭ ﺏﺍﻟﻭﺭ‬ ‫ﺃﻨﻬﺎ ﻤ ﻥ ﻓ ﺼﻴﻠﺔﺍﻟ ﻁﻴﻭﺭ‪ .‬ﺇﺫ ﻥ ﻓﻲ ﻫﺫﻩﺍﻟ ﺤﺎﻟﺔ ﻨﺴﺘ ﻁﻴﻊﺃ ﻥ ﻨﻘﻭل " ﺩﺠﺎﺠﺔ ﻫﻲ ﻁﺎﺌﺭ ﻤﺘﺨ ﺼ ﺹ"‪.‬‬ ‫ﺍﺜﺔﺍﻻﺨﺘﻴﺎﺭﻴﺔ‪:‬ﺍﻟﻤﺒﺭﻤﺞ ﻤﺩﻋﻭ ﻻﺨﺘﻴﺎﺭ ﻤﺎ ﻫﻲﺍﻟﻤﻨﺎ ﻫﺞ‬ ‫‪ ،‬ﺘ ﻁﺭ ﺡ ﺒﻌ ﺽﺍﻟﻠﻐﺎ ﺕﺍﻟﻭﺭ‬ ‫ﻜﺫﻟ ﻙ‬ ‫‪ ،‬ﻓﺈﻨﻪ‬ ‫ﺍ ﻥ ﻤ ﻥ ﺘﺴﻠﺴل ﻁﺎﺌ ﺭ‬ ‫ﺍﻟﺨ ﺼﺎﺌ ﺹﺍﻟﺘﻲ ﻴﻤﻜﻨﻬﺎﺃ ﻥ ﺘﻭﺭﺙ‪ .‬ﻭﺇ ﻥﻟ ﺯﻡﺍﻷﻤﺭ ﻤ ﺤﻭ ﻤﻨﻬﺎﺝﺍﻟ ﻁﻴﺭ‬ ‫ﻭ‬ ‫ﺍ ﻴﻌﺘﻡ ﻜﻠﻴﺔ ﻤﻔﻬﻭﻡ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ‪polymorphism‬ﺍﻟﺫ ﻱ‬ ‫‪ ،‬ﻫﺫ‬ ‫ﻻ ﻴ ﻁﺭ ﺡﺃ ﻱ ﻤﺸﻜﻠﺔ‪ .‬ﺒﺎﻟﻤﻘﺎﺒل‬ ‫ﺍ ﻓﻲﺍﻷ ﺼﻨﺎ ﻑ‬ ‫ﺍ ﻓﻲﺍﻟ ﺼﻨ ﻑﺍﻟﻘﺎﻋﺩ ﻱ ﻴﻤﻜ ﻥﺃ ﻥ ﻴﻜﻭ ﻥ ﻤﻭﺠﻭﺩ‬ ‫ﻴﻨ ﺹ ﻋﻠﻰﺃ ﻥ ﻤﻨﻬﺎﺠﺎ ﻤﻭﺠﻭﺩ‬ ‫ﺍﻟﻭﺭﻴﺜﺔ‪.‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﻟﻤﺘﻌﺩﺩﺓ ‪the multiple inheritance :‬‬ ‫ﻟ ﻭﺭﺍﺜﺔﺍ‬ ‫‪ . ٥ .٣‬ﺍ‬ ‫‪ ،‬ﺤﻴﺙﻨﺴﻤﺢ ﻟ ﺼﻨ ﻑ ﻤ ﻥﺃ ﻥ ﻴﻤﺘﻠ ﻙﺍﻟﻌﺩﻴﺩ‬ ‫ﺍﺜﺔﺍﻟﻌﺎﺩﻴﺔ‬ ‫ﺍﺜﺔﺍﻟﻤﺘﻌﺩﺩﺓ ﻫﻲ ﺘﻭﺴﻊﻟﻠﻭﺭ‬ ‫ﺍﻟﻭﺭ‬ ‫ﺍﻷ ﺼﻨﺎ ﻑﺍﻷﺒﺎﺀﻟﻜﻲ ﻨﻌ ﻁﻲ ﻗﺎﻟﺒﺎﻟﻠﺘﻌﻤﻴﻡﺍﻟﻤﺘﻌﺩﺩ‪.‬‬ ‫ﺍﺍﻟﻤﺜﺎل‪:‬ﻟﻨﻔﺭ ﺽﺃﻨﻨﺎ ﻨﺭﻴﺩ ﺯﻴﺎﺩﺓﺍﻟ ﺼﻨ ﻑ‬ ‫‪ ،‬ﻓﻠﻨﻨﺘﺒﻪ ﺇﻟﻰ ﻫﺫ‬ ‫ٌﺸﻜل ﻋﻠﻴﻨﺎﺍﻟﻔﻬﻡ‬ ‫ﺍ ﻤﺎﺃ‬ ‫ﺇﺫ‬ ‫ﻫﻭﻓ ﺭﻜﺭﺍﻓ ﺕ ‪) Hovercraft‬ﻟﻡﺃﺠﺩﻟﻬﺎ ﻤ ﺼ ﻁﻠ ﺤﺎ ﻤﻨﺎﺴﺒﺎ( ﻟﻨﻤﻭﺫﺝ ﺤ ﻅﻴﺭﺓﺍﻟﻌﺭﺒﺎ ﺕﺍﻟﺴﺎﺒﻘﺔ‪.‬‬ ‫‪ ،‬ﺇﺫ ﻥ ﻨﻘﺩﺭ‬ ‫‪‬ﻴﺔ‬ ‫‪ ،‬ﻭﻓﻲ ﻨﻔ ﺱﺍﻟﻭﻗ ﺕ ﻋﺭﺒﺔ ﺒﺭ‬ ‫‪ ،‬ﻋﺒﺎﺭﺓ ‪(..‬‬ ‫ﺍﻓ ﺕ ﻫﻭ ﺴﻔﻴﻨﺔ )ﺒﺎﺨﺭﺓ‬ ‫ﻭﻨﻌﻠﻡﺃ ﻥ ﻫﻭﻓﺭﻜﺭ‬ ‫ﺍﺍﻟﺸﻜل‪:‬‬ ‫ﻋﻠﻰﺃ ﻥ ﻨﻘﻭﻟﺒﻬﺎ ﻋﻠﻰ ﻫﺫ‬ ‫‪RollingVehicle‬‬

‫‪Boat‬‬

‫‪Hovercraft‬‬

‫ﻋﺭﺒﺔ ﺩﻭﺍ ﺭﺓ‬

‫ﺴﻔﻴﻨﺔ‬

‫ﻫﻭﻓ ﺭﻜﺭﺍﻓ ﺕ‬

‫ﻟﻤﺘﻌﺩﺩﺓ‬ ‫ﻟ ﻭﺭﺍﺜﺔﺍ‬ ‫ﻤﺜﺎل ﻋ ﻥﺍ ﺴﺘﻌﻤﺎلﺍ‬ ‫‪ ،‬ﺒل ﺘ ﻁﺭ ﺡ ﻨﻔﺴﻬﺎ ﻓﻲﺃﺸﻜﺎل‬ ‫ﺍﺍﻟ ﺤﺩ‬ ‫ﺍﺜﺔﺍﻟﻤﺘﻌﺩﺩﺓ ﻻ ﺘﻨﺘﻬﻲ ﻋﻨﺩ ﻫﺫ‬ ‫ﻤﺸﺎﻜلﺍﺴﺘﻌﻤﺎلﺍﻟﻭﺭ‬ ‫‪ ،‬ﻓﺈﻨﻨﺎ ﻨﺠﺩ‬ ‫‪ ،‬ﻓﻤﺜﻼﻟﻭ ﻜﺎ ﻥ ﻋﻨﺩﻨﺎ ﺼﻨﻔﻴ ﻥ ﻗﺎﻋﺩﻴﻴ ﻥ ﻴﻤﻠﻜﺎ ﻥ ﺨ ﺼﺎﺌ ﺹﺃﻭ ﻤﻨﺎ ﻫﺞ ﻤﺘﺸﺎﺒﻬﺔ‬ ‫ﺃﺨﺭﻯ‬ ‫ﺍﻟﺘﻲ ﻴﺠ ﺏﺃ ﻥ ﻨ ﺤﻠﻬﺎ‪ .‬ﺒﻌ ﺽﺍﻟﻠﻐﺎ ﺕ ﺘﺸﺘﺭ ﻁ ﺇﺫ ﻥ‬ ‫‪،‬ﻭ‬ ‫ﺍﺠﻬﺔ ﻤﺸﻜﻠﺔ ﺘﺸﺎﺒ ﻙ ﻓﻲﺍﻟﺘﺴﻤﻴﺔ‬ ‫ﺃﻨﻔﺴﻨﺎ ﻓﻲ ﻤﻭ‬ ‫ﺍﺍﻹﺸﻜﺎل ﺇﻟ ﺤﺎﻕﺍﻟﻤﻨﻬﺎﺝﺃﻭﺍﻟﺨﺎ ﺼﻴﺔ ﺒﺎﺴﻡﺍﻟ ﺼﻨ ﻑﺍﻟﺘﺎﺒﻌﺔﻟﻪ‪.‬‬ ‫ﻟ ﺤل ﻫﺫ‬ ‫ﺍﺭﻴﺔ‪ .‬ﻓﻔﻲﺍﻟﻤﺜﺎل‬ ‫ﺍﺜﺔ ﺘﻜﺭ‬ ‫ﺍﺜﺔﺍﻟﻤﺘﻌﺩﺩﺓ ﺇﻟﻰ ﻭﺭ‬ ‫‪ ،‬ﻭ ﻫﻲﺃﻨﻪﺃ ﺤﻴﺎﻨﺎ ﺘﺘ ﺤﻭلﺍﻟﻭﺭ‬ ‫ﻤﺸﻜﻠﺔﺃﺨﺭﻯ‬ ‫ﺍﻷﺨﺭﻯ‬ ‫‪،‬ﻭ‬ ‫ﺍ ﺤﺩﺓ ﻤ ﻥ ﺨﻼلﺍﻟ ﺼﻨ ﻑ ‪B‬‬ ‫‪،‬ﻭ‬ ‫ﺍﻵﺘﻲ ﻨﺠﺩﺍﻟ ﺼﻨ ﻑ ‪ D‬ﻴﺭ ﺙ ﻨﺴﺨﺘﻴ ﻥ ﻤ ﻥﺍﻟ ﺼﻨ ﻑ ‪A‬‬ ‫ﻋ ﻥ ﻁﺭﻴﻕﺍﻟ ﺼﻨ ﻑ ‪C‬‬ ‫ﺍلﺍﻟﻤ ﻁﺭﻭ ﺡ ﺒﺄ ﻱ ﻤ ﻥﺍﻟﻨﺴﺨﺘﻴ ﻥ ﺴﻴ ﺤﺘﻔ ﻅ؟ ﺒﻌ ﺽﺍﻟﻠﻐﺎ ﺕ ﻜﺎﻟﺴﻲ‬ ‫ﺍﻟﺴﺅ‬ ‫‪،‬ﻭ‬ ‫ﺍ ﻤﺎ ﺤﺩﺜ ﺕ‪.‬‬ ‫ﺒﻠ ﺱ ﺒﻠ ﺱ ﺘﻘﺘﺭ ﺡ ﺁﻟﻴﺔ ﺘﺴﻤﺢﺒﻤﻌﺎﻟﺠﺔ ﻫﺫﻩﺍﻟﻤﻌ ﻀﻠﺔﺍﻟﺸﺎﺌﻜﺔ ﺇﺫ‬ ‫‪A‬‬

‫‪B‬‬

‫‪C‬‬

‫‪D‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﺍﻟﻌﺩﻴﺩ ﻤ ﻥ ﻤﻜﺘﺒﺎ ﺕﺍﻷ ﺼﻨﺎ ﻑ ﺘﺴﺘﺨﺩﻡ ﺼﻨ ﻑ ﻗﺎﻋﺩ ﻱ ﻤﺠﺭﺩ ﻷﺠلﺍﻻﺴﺘﻔﺎﺩﺓ ﻤ ﻥ ﺁﻟﻴﺎ ﺕ‬ ‫ﺍﺭﻴﺔ ﻜﻠﻤﺎ‬ ‫ﺍﺜﺔﺍﻟﺘﻜﺭ‬ ‫ﺍﻡﺍﻟﻭﺭ‬ ‫ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ‪ .polymorphism‬ﻭﺃﻴ ﻀﺎ ﻗﺩ ﻨﻘﻊ ﻓﻲ ﻤﺸﺎﻜلﺍﺴﺘﺨﺩ‬ ‫ﺍﺜﺔﺍﻟﻤﺘﻌﺩﺩﺓ‬ ‫ﺍﺠﻬﺎ ﺕﺍﻟﻤﻭﻓﺭﺓ ﻤ ﻥ ﻗﺒل ﺒﻌ ﺽﺍﻟﻠﻐﺎ ﺕﺍﻟﺘﻲ ﺘﻨﻔﻲﺍﻟﻭﺭ‬ ‫ﺍﺜﺔﺍﻟﻤﺘﻌﺩﺩﺓ‪.‬ﺍﻟﻭ‬ ‫ﺍﺴﺘﻌﻤﻠﻨﺎﺍﻟﻭﺭ‬ ‫ﺍﺜﺔ‪.‬‬ ‫)ﻜﺎﻟﺴﻲ ﺒﻠ ﺱ ﺒﻠ ﺱ ﻭﺍﻟﺠﺎﻓﺎ( ﺘﻘﺘﺭ ﺡ ﺘﻨﺎﻭﺒﺎ ﻫﺎﻤﺎ ﻭﻤﻨﺎﺴﺒﺎ ﻟﺘﻌﺩﺩﺍﻟﻭﺭ‬ ‫ﻟﻭﺍﺠ ﻬﺎﺕ‪the interfaces :‬‬ ‫‪ . ٦ .٣‬ﺍ‬ ‫ﺍ ﺡ ﻋﺩﺓ‬ ‫ﺍﺜﺔﺍﻟﻤﺘﻌﺩﺩﺓ ﺩﻓﻌ ﺕ ﺒﻌ ﺽﺍﻟﻤ ﺼﻤﻤﻴ ﻥ ﻟﻠﻐﺎ ﺕ ﺇﻟﻰﺍﻗﺘﺭ‬ ‫ﺍﻟﻤﺸﺎﻜلﺍﻟﻤﺭﺘﺒ ﻁﺔ ﺒﺎﻟﻭﺭ‬ ‫ﺍﺠﻬﺔ ﺸﺒﻴﻬﺔ ﺒ ﺼﻨ ﻑ ﻤ ﻥ ﺩﻭ ﻥ‬ ‫ﻟﻭﺍﺠﻬﺎ ﺕ‪.‬ﺍﻟﻭ‬ ‫ﺤﻠﻭل‪ .‬ﺇﻟﻰﺃ ﻥ ﺭﺃﻴﻨﺎ ﻅﻬﻭﺭ ﺁﻟﻴﺎ ﺕﺃﺨﺭﻯ ﻜﺎ‬ ‫‪،‬ﺃﻤﺎ ﻤﻨﺎ ﻫﺠﻬﺎ ﻓﻬﻲ ﻜﻠﻬﺎ ﻤﺠﺭﺩﺓ‪.‬‬ ‫ﺍﺒ ﺕ‬ ‫ﺍ ﺀ ﺜﻭ‬ ‫‪ ،‬ﻭﻟﻜﻨﻬﺎ ﺘﻘﺩﺭ ﻋﻠﻰﺍ ﺤﺘﻭ‬ ‫ﺨ ﺼﺎﺌ ﺹ )ﺒﻴﺎﻨﺎ ﺕ(‬ ‫ﺍﺠﻬﺔ ﻗﻴﺩ‬ ‫‪ ،‬ﻓﺈﻨﻪ ﻴﻘﺩﺭ ﻋﻠﻰ ﻭ ﻀﻊﺍﻟﻭ‬ ‫ﺍﺜﺔﺍﻟﺘﻲ ﻴﺘﻤﺘﻊ ﺒﻬﺎﺍﻟ ﺼﻨ ﻑ‬ ‫ﺍ ﺕﺍﻟﻭﺭ‬ ‫ﺯﻴﺎﺩﺓ ﻋﻠﻰ ﻤﻤﻴ ﺯ‬ ‫ﺍﻟﻜلﺍﻟﻤﻨﺎ ﻫﺞﺍﻟﻤﻭﺠﻭﺩﺓ ﻓﻴﻬﺎ‪ .‬ﻫﺫﻩﺍﻵﻟﻴﺔ ﻗﻭﻴﺔﻟﻠﻐﺎﻴﺔ‬ ‫ﺍ ﻜﺎﻨ ﺕ ﺘﻤﻠ ﻙ ﺘﻨﻔﻴﺫ‬ ‫ﺍﻟﺘﻨﻔﻴﺫ ‪ Implement‬ﺇﺫ‬ ‫ﺍﺠﻬﺎ ﺕ ﻤ ﻥ ﺩﻭ ﻥﺃ ﻥ ﺘﻜﻭ ﻥﻟﻬﺎ‬ ‫ﻷﻨﻬﺎ ﺘﺨﻠﻕ ﻋﻼﻗﺎ ﺕ ﻗﻭﻴﺔ ﺒﻴ ﻥ ﻤﺨﺘﻠ ﻑﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﻨﻔﹼﺫﺓﻟﻨﻔ ﺱﺍﻟﻭ‬ ‫ﺍﺠﻬﺎ ﺕ ﻫﻲ ﻤﺘﻌﺩﺩﺓﺍﻟ ﺼﻔﺎ ﺕ‬ ‫‪،‬ﺍﻟﻤﻨﺎ ﻫﺞﺍﻟﻤﻭﺠﻭﺩﺓ ﻀﻤ ﻥﺍﻟﻭ‬ ‫ﻋﻼﻗﺔﺃﺒﻭﻴﺔ‪ .‬ﻋﻠﻰﺍﻟﺨ ﺼﻭ ﺹ‬ ‫ﺍﺠﻬﺔ‪.‬‬ ‫‪ ،‬ﻷﻨﻬﺎ ﺘﻨﻔﺫ ﺒ ﺼﻔﺔ ﻤ ﺤﺎﻴﺩﺓ ﻓﻲ ﻜل ﺼﻨ ﻑ ﻴﺴﺘﺨﺩﻡ ﻨﻔ ﺱﺍﻟﻭ‬ ‫‪polymorphs‬‬ ‫ﺍﺠﻬﺎ ﺕ‪ .‬ﻫﺫﻩﺍﻵﻟﻴﺔﺍﻟ ﺼﺎﺩﺭﺓ ﻋ ﻥ‬ ‫‪ ،‬ﻜل ﺼﻨ ﻑ ﻴﻤﻜﻨﻪ ﺘﻨﻔﻴﺫ ﻤﺎ ﻴ ﺤﻠﻭﻟﻪ ﻤ ﻥﺍﻟﻭ‬ ‫ﺒﺎﻟﻤﻘﺎﺒل‬ ‫ﺍﻟﺠﺎﻓﺎ‪.‬‬ ‫‪ Smalltalk‬ﺘﻡ ﺘﺒﻨﻴﻬﺎ ﻤ ﻥ ﻗﺒل ﻟﻐﺔﺍﻟﺴﻲﺍﻟﻜﺎﺌﻨﻴﺔ )ﺃﻭ ﻜﻤﺎ ﻴﺴﻤﻴﻬﺎﺍﻟﺒﻌ ﺽ‪:‬ﺍﻟﺸﻴﺌﻴﺔ( ﻭ‬ ‫‪،‬‬ ‫ﺍ ﺼﺔﻨﻭﻭﻴﺔ‬ ‫‪ ،‬ﻟﻨﻔﺭ ﺽ ﻤﺜﻼﺃ ﻥ ﻨ ﻅﺎﻡ ﻜﺎﺌﻨﺎ ﺕ ﻴﺭﻴﺩ ﻗﻭﻟﺒﺔ ﻏﻭ‬ ‫ﻤ ﻥﺃﺠل ﺘﺜﺒﻴ ﺕﺍﻷﻓﻜﺎﺭ‬ ‫ﺍﺠﺩ ﻋﻠﻰﺍﻟﺘ ﺼﻤﻴﻡ‪ .‬ﻓﺒﺩلﺍﺸﺘﻘﺎﻕ ﻜل‬ ‫ﻭ ﺤﻴﺙ ﺒﻌ ﺽ ﻤﺭﻜﺒﺎﺘﻬﺎ ﺘﺎﺒﻌﺔﻟﻔﺭﻭﻉ ﺘﺴﻠﺴﻠﻴﺔ ﻴﺠ ﺏﺃ ﻥ ﺘﺘﻭ‬ ‫ﺍﻟﺘﻲ ﺘﻘﺘﺭ ﺡ ﻋﺭ ﻀﻬﺎ ﻋﻠﻰﺍﻟﺘ ﺼﻤﻴﻡ )ﺒﻌ ﺽﺍﻷ ﺼﻨﺎ ﻑ ﻻ ﻴﺠ ﺏﺃ ﻥ‬ ‫‪،‬ﻭ‬ ‫ﺍﻷ ﺼﻨﺎ ﻑ ﻟﻨﻔ ﺱﺍﻟﻌﺎﺌﻠﺔ‬ ‫ﺍﺠﻬﺔ ﻗﺎﺒﻠﺔﻟﻠﻌﺭ ﺽ ﺇﻟﻰﺍﻟﺘﻲ‬ ‫‪ ،‬ﻴﺴﺘ ﺤﺴ ﻥ ﺭﺒ ﻁ ﻭ‬ ‫‪ ،‬ﻓﺒﺩل ﺫﻟ ﻙ‬ ‫ﺍ ﺴﻴﺌﺎ‬ ‫ﺍ ﻤﺎ ﻴﻌﺘﺒﺭ ﺘ ﺼﻭﺭ‬ ‫‪ ،‬ﻭ ﻫﺫ‬ ‫ﺘﻌﺭ ﺽ(‬ ‫ﻴﺠ ﺏﺃ ﻥ ﺘ ﻅﻬﺭ ﻓﻲﺍﻟﺘ ﺼﻤﻴﻡ‪ .‬ﻨﺸﻴﺭﺃﻴ ﻀﺎ ﺇﻟﻰﺃﻨﻪ ﻟﻭ ﻜﺎﻨ ﺕ ﻜلﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻤﺸﺘﻘﺔ ﻤ ﻥ ﺼﻨ ﻑ‬ ‫‪ ،‬ﻓﺈ ﻥ ﻜلﺍﻷ ﺼﻨﺎ ﻑﺍﻟﻐﻴﺭ ﺒﻴﺎﻨﻴﺔ ﺴﺘﺜﻘل ﺒﺎﻟﻌﺩﻴﺩ ﻤ ﻥﺍﻟﻤﻨﺎ ﻫﺞﺍﻟﻐﻴﺭ‬ ‫ﻗﺎﻋﺩ ﻱ ﻴﻘﺘﺭ ﺡ ﻤﻨﺎ ﻫﺞﻟﻠﺭﺴﻡ‬ ‫ﻀﺭﻭﺭﻴﺔ‪.‬‬ ‫‪ ،‬ﻭﻟﻜﻨﻪ ﻴﺘﻌﻠﻕ ﺒﻨ ﻅﺭﺓ‬ ‫‪،‬ﻟﻴ ﺱﺒﺎﻟﺒﺴﺎ ﻁﺔ ﺒﻤﺎ ﻜﺎ ﻥ‬ ‫ﺍﺠﻬﺎ ﺕ‬ ‫ﺍﻡﺍﻟﻭ‬ ‫ﺍﺴﺘﺨﺩ‬ ‫ﺍﻟﺘﻤﻴﻴ ﺯ ﺒﻴ ﻥﺍﻻﺸﺘﻘﺎﻕ ﻭ‬ ‫‪ ،‬ﺒﺎﻟﺭﺠﻭﻉ ﺇﻟﻰ ﻤﺜﺎل‬ ‫ﺍﺩ ﺇﻨﺠﺎ ﺯﻩ‪ .‬ﺇﺫ ﻥ‬ ‫‪ ،‬ﻭﺃﻴ ﻀﺎ ﺒﺒﻴﺌﺔﺍﻟﺒﺭﻨﺎﻤﺞﺍﻟﻤﺭ‬ ‫ﺍﻟﻤ ﺼﻤﻡ(‬ ‫ﺍﻟﻤﺘ ﺼﻭﺭ )‬ ‫‪،‬ﺃﻭ‬ ‫ﺍﺠﻬﺔ ﻤ ﻥ ﻋﺭﺒﺔ ﺒﺤﺭﻴﺔ‬ ‫‪ ،‬ﻭﺘ ﺯﻭﻴﺩﻩ ﺒﻭ‬ ‫‪ ،‬ﻫلﻴﺠ ﺏﺍﺸﺘﻘﺎﻗﻪ ﻓﻘ ﻁ ﻤ ﻥ ﻋﺭﺒﺔ ﺩﻭﺍﺭﺓ‬ ‫ﻫﻭﻓ ﺭﻜﺭﺍﻓ ﺕ‬ ‫‪،‬‬ ‫‪ ،‬ﺨﻠﻕ ﺼﻨ ﻑ ﺠﺩﻴﺩ ﻤﺴﺘﻘل‬ ‫‪،‬ﺃﻭﺃﻴ ﻀﺎ‬ ‫ﺍﺠﻬﺔ ﻤ ﻥ ﻋﺭﺒﺔ ﺒﺭﻴﺔ‬ ‫ﺍﺜﺔ ﻤ ﻥ ﺴﻔﻴﻨﺔ ﻭﺘ ﺯﻭﻴﺩﻩ ﺒﻭ‬ ‫ﺍ ﺀ ﻭﺭ‬ ‫ﺇﺠﺭ‬ ‫‪ ،‬ﻭﻟﻜ ﻥ ﺘﺘﻌﻠﻕ ﺒﺎﻷﻭﻟﻭﻴﺎ ﺕﺍﻟﺘﻲ‬ ‫ﺍلﻟﻴﺴ ﺕ ﺒﺴﻴ ﻁﺔ‬ ‫ﺍﺍﻟﺴﺅ‬ ‫ﺍﺠﻬﺘﻴ ﻥ ﻤﻌﺎ‪.‬ﺍﻹﺠﺎﺒﺔ ﻋ ﻥ ﻫﺫ‬ ‫ﻭﺘ ﺯﻭﻴﺩﻩ ﺒﺎﻟﻭ‬ ‫ﺍﺜﺔ‪ .‬ﻤﺭﺓﺃﺨﺭﻯ ﻴ ﻁﺭ ﺡ ﻤﺸﻜل ﻁﺒﻴﻌﺔ‬ ‫ﻨﺭﻴﺩ ﺇﻋ ﻁﺎﺀ ﻫﺎ ﻟﻠﻨﻤﻭﺫﺝ‪:‬ﺍﻟﻤﻌﻴﺎﺭﺍﻷﻓ ﻀل ﻫﻭ ﻋﻤلﺍﻟﻭﺭ‬ ‫ﺍﺩ‪.‬‬ ‫‪ ،‬ﻭﺒﺒﻴﺌﺔﺍﻟﺘ ﻁﺒﻴﻕﺍﻟﻤﺭ‬ ‫ﺍﻟﺘﻲ ﺘﺘﻌﻠﻕ ﺒﺸﺨ ﺼﻴﺔ ﺼﺎﻨﻊﺍﻟﻨﻤﻭﺫﺝ‬ ‫‪،‬ﻭ‬ ‫ﺍﻟﺘﻘﺴﻴﻡ‬ ‫ﻟﺘﺭﻜﻴﺏ ‪:aggregation‬‬ ‫‪ ٤‬ﺍ‬ ‫‪.٤‬‬

‫‪ .١‬ﺘﻌﺭﻴ ﻑ‪:‬‬

‫‪‬ﻥ‬ ‫ﺍﻟﺘﻲﻴﺘﺭﺠﻡ ﻫﺫﻩﺍﻟﻤﺭﺓﺍﻟﻌﻼﻗﺔ "ﻤﻜ ﻭ‬ ‫‪،‬ﻭ‬ ‫ﺍﻟﺘﺭﻜﻴ ﺏ ﻫﻭ ﻨﻭﻉ ﺁﺨﺭ ﻤ ﻥﺍﻟﻌﻼﻗﺔ ﺒﻴ ﻥ ﺼﻨﻔﻴ ﻥ‬ ‫‪ ،‬ﻴﻤﻜﻨﻨﺎﺃ ﻥ ﻨﻘﻭلﺃ ﻥﺍﻟ ﺼﻨ ﻑ‬ ‫‪ ،‬ﻓﻲ ﻨ ﻅﺎﻡ ﻤﻴﻜﺎﻨﻴﻜﻲ‬ ‫ﻟﻪ‪ ."...‬ﻓﻤﺜﻼ‬ ‫ﻤ ﻥ‪"...‬ﺃﻭ "ﻴﻤﻠﻙ‪"...‬ﺃﻭﺃﻴ ﻀﺎ "‬

‫‪ ،‬ﻭ ﺼﻨ ﻑ ﻤ ﻥ ﺇﻁﺎ ﺭ‪ .‬ﺨﻠﻕ ﻤﺜﻴﻼ ﺕ‬ ‫‪،‬ﺃﺭﺒﻌﺔﺃ ﺼﻨﺎ ﻑ ﻤ ﻥ ﻋﺠﻠﺔ‬ ‫ﺴﻴﺎ ﺭﺓ ﻤﻜﻭ ﻥ ﻤ ﻥ ﺼﻨ ﻑ ﻤ ﻥ ﻤﺤ ﺭﻙ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﺍ ﺕ ﻋﻠﻰ‬ ‫ﺍﺘﻬﺎ ﻜﺎﺌﻨﺎ ﺕﺃﻭ ﻤﺅﺸﺭ‬ ‫ﺍﻟﺘﻲ ﻫﻲ ﻓﻲ ﺤﺩ ﺫ‬ ‫ﺍﻤﻴﺔ ﺇﻟﻰﺍﺴﺘﻌﻤﺎلﺍﻟﺨ ﺼﺎﺌ ﺹ ﻭ‬ ‫ﻴﻤﺭ ﺒ ﺼﻔﺔ ﺇﻟ ﺯ‬ ‫ﻜﺎﺌﻨﺎ ﺕﺃﻭﺃﻴ ﻀﺎ ﻤﺜﻴل ﻋ ﻥ ﺼﻨ ﻑ ﺤﺎﻭ ﻴ ﺤﻘﻕ ﻫﻭ ﻜﺫﻟ ﻙ ﻤﺒﺩﺃﺍﻟﺘﺭﻜﻴ ﺏ‪.‬ﺍﻟﺸﻲﺀﺍﻟﻬﺎﻡ ﻓﻲﺍﻟﺘﺭﻜﻴ ﺏ‬ ‫ﻫﻭ ﻜﺎﺭﺩﻴﻨﺎﻟﻴﺘﻪ‪ .‬ﻟﻨﻌﺘﺒﺭ ﻤﺜﻼ ﺘﺭﻜﻴ ﺏ ﻋﺠﻼ ﺕ ﻤ ﻥ ﺴﻴﺎﺭﺓ‪.‬ﺃ ﻱ ﺴﻴﺎﺭﺓ ﺘﺘﺭﻜ ﺏ ﻤ ﻥﺃﺭﺒﻊ ﻋﺠﻼ ﺕ‬ ‫‪ ،‬ﻭﺃ ﻱ ﻋﺠﻠﺔ ﻻ ﻴﻤﻜﻨﻬﺎﺃ ﻥ‬ ‫ﺍ ﺕﺍﻟﺜﻼﺙ ﻋﺠﻼ ﺕ(‬ ‫ﺍ ﺕﺍﻟﺸﺎﺫﺓ ﺫ‬ ‫‪،‬ﺃﻭﺍﻟﺴﻴﺎﺭ‬ ‫)ﻤﻊ ﺇ ﻫﻤﺎل ﻋﺠﻠﺔﺍﻟﻨﺠﺩﺓ‬ ‫‪ ،‬ﻭ ‪ ٤‬ﻤ ﻥ ﺠﺎﻨ ﺏ‬ ‫ّﺏ‬ ‫ﺘﹸﻤﺘﻠ ﻙ ﻤ ﻥﺃﻜﺜﺭ ﻤ ﻥ ﺴﻴﺎﺭﺓ‪ .‬ﻜﺎﺭﺩﻴﻨﺎﻟﻴﺔﺍﻟﺘﺭﻜﻴ ﺏ ﻫﻲ ﺇﺫ ﻥ ‪ ١‬ﻤ ﻥ ﺠﺎﻨ ﺏﺍﻟﻤﺭﻜِ‬ ‫ﺍﻟﻤﺭﻜﱠ ﺏ‪.‬‬ ‫ﺍﻟﻤﺜﺎلﺍﻵﺘﻲﻴﺴﻤﺢ ﺒﺘﺜﺒﻴ ﺕﺍﻟﻤﻔﺎ ﻫﻴﻡ‪:‬‬ ‫‪Wheel‬‬

‫‪Chassis‬‬

‫‪٤‬‬

‫‪Motor‬‬

‫‪١‬‬ ‫‪١‬‬

‫‪١‬‬

‫‪١‬‬ ‫‪١‬‬

‫‪Car‬‬

‫ﻋﺠﻠﺔ‬

‫ﺇﻁﺎ ﺭ‬

‫‪٤‬‬

‫ﻤﺤ ﺭﻙ‬

‫‪١‬‬ ‫‪١‬‬

‫‪١‬‬

‫‪١‬‬ ‫‪١‬‬

‫ﺴﻴﺎ ﺭﺓ‬

‫ﻟﻨ ﺴﺒﺔﻟﻠ ﺼﻨ ﻑ ﻋﺭﺒﺔ‬ ‫ﻤﺜﺎلﻟﺘﺭﻜﻴﺏ ﺒﺎ‬ ‫ﺍﻋﺩﺃﻨ ﻅﻤﺔﺍﻟﻜﺎﺌ ﻥﺍﻟﻌﺎﻟﻤﻴﺔ ‪ UML‬ﺘﺴﺘﻌﻤل ﺴﻬﻤﺎ ﻴﻜﻭ ﻥ ﺸﻜل ﻤﻘﺩﻤﺘﻪ ﻤﻌﻴ ﻥ ﻟﺘﻘﺩﻴﻡ‬ ‫ﻗﻭ‬ ‫ّ ﺏ‪.‬ﺃﻤﺎﺍﻟﻜﺎﺭﺩﻴﻨﺎﻻ ﺕ ﻓﺘﻜﻭ ﻥ ﻤ ﺤﺩﺩﺓ‪.‬‬ ‫ﺍﻟﺘﺭﻜﻴ ﺏ ‪.aggregation‬ﺍﻟﻤﻌﻴ ﻥ ﻴﻜﻭ ﻥ ﺠﻬﺔﺍﻟﻤﺭﻜِ‬ ‫ﺍ ﺤﺩﺓ(‪.‬‬ ‫ّ ﺏ ﺘﻜﻭ ﻥ ﺒﺠﺎﻨ ﺏﺍﻟﻤﻌﻴ ﻥ )ﻓﻲﺍﻟﺒﻴﺎ ﻥ‪ :‬ﻋﺠﻠﺔ ﺘﻨﺘﻤﻲﻟﺴﻴﺎﺭﺓ ﻭ‬ ‫‪ v‬ﻜﺎﺭﺩﻴﻨﺎﻟﻴﺔﺍﻟﻤﺭﻜِ‬ ‫ﻜ ﺏ ﺘﻜﻭ ﻥ ﺒﺠﺎﻨ ﺏﺍﻟﺨ ﻁ )ﻓﻲﺍﻟﺒﻴﺎ ﻥ‪ :‬ﺴﻴﺎﺭﺓ ﺘﻤﺘﻠ ﻙﺃﺭﺒﻊ ﻋﺠﻼ ﺕ(‪.‬‬ ‫‪ v‬ﻜﺎﺭﺩﻴﻨﺎﻟﻴﺔﺍﻟﻤﺭﱠ‬ ‫‪.٤‬‬

‫ﻟﻭﺍﺠ ﻬﺎﺕ‪:‬‬ ‫ﻟﻤﺘﻌﺩﺩﺓﺃ ﻭﺍ‬ ‫ﻟﺘﺭﻜﻴﺏ ﻜﺘﻨﺎ ﻭﺏﻟﻠ ﻭﺭﺍﺜﺔﺍ‬ ‫‪ .٢‬ﺍ‬

‫ﺍﺜﺔﺍﻟﻤﺘﻌﺩﺩﺓﺃﻭ ﻓﻲ‬ ‫ﺃ ﺤﻴﺎﻨﺎ ﻴﻜﻭ ﻥ ﺒﺎﻹﻤﻜﺎ ﻥ ﺘﺭﺠﻤﺔ ﺒﻤﻔﻬﻭﻡﺍﻟﺘﺭﻜﻴ ﺏ ﻤﻔﺎ ﻫﻴﻡ ﺘ ﻅﻬﺭ ﻓﻲﺍﻟﻭﺭ‬ ‫ﺍ ﺕ‪ .‬ﻭﻓﺠﺄﺓ ﻨﺭﻴﺩ ﺩﻤﺞﺃﻭﺍﻜ ﺱ‬ ‫ﺍﺭ‬ ‫ﺍﺩ‬ ‫ﺍ ﺕ ﻭﺭ‬ ‫ﺍﺠﻬﺎ ﺕ‪ .‬ﻓﻠﻨﻔﺭ ﺽ ﻤﺜﻼ ﻨ ﻅﺎﻡ ﻋﺴﻜﺭ ﻱ ﻴﺠﻤﻊ ﻁﺎﺌﺭ‬ ‫ﺍﻟﻭ‬ ‫‪AWACS‬‬ ‫ﺍ‪ .‬ﻓﻜﻴ ﻑ ﻨﻘﻭﻟ ﺏ )ﻨ ﺼﻨﻊ ﻨﻤﻭﺫﺝﺃﻭ ﻗﺎﻟ ﺏ( ﻫﺫﻩ‬ ‫ﺍﺭ‬ ‫ﺍﺩ‬ ‫ﺍﻟﺘﻲ ﻫﻲ ﻁﺎﺌﺭﺓ ﺘﻤﺘﻠ ﻙ ﺭ‬ ‫‪،‬ﻭ‬ ‫ﺍﻟﻭ ﻀﻌﻴﺔ؟‬ ‫‪١‬‬ ‫‪٢‬‬

‫ﺍﺜﺔﺍﻟﻤﺘﻌﺩﺩﺓ‪:‬ﻨﺸﺘﻕﺍﻟ ﺼﻨ ﻑﺃﻭﺍﻜ ﺱ ﻤ ﻥﺍﻟ ﺼﻨﻔﻴ ﻥ ﺭﺍﺩﺍ ﺭ ﻭ ﻁﺎﺌ ﺭﺓ‪.‬‬ ‫ﺍﻟﻭﺭ‬ ‫ﺍﺠﻬﺎ ﺕ‪:‬‬ ‫ﻨﺴﺘﻌﻤلﺍﻟﻭ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﺍﺠﻬﺔ ﻻﻗﻁ ) ﺼﻨ ﻑ ﻴﺠﻤﻊ ﻜل‬ ‫‪ ،‬ﻭﻨ ﻅﻴ ﻑﻟﻬﺎ ﻭ‬ ‫ﻨﺸﺘﻕﺃﻭﺍﻜ ﺱ ﻤ ﻥ ﻁﺎﺌ ﺭﺓ‬ ‫ﺍ ﺕ(‪.‬‬ ‫ﺍﺭ‬ ‫ﺍﺩ‬ ‫ﺍﻉﺍﻟﺭ‬ ‫ﺃﻨﻭ‬ ‫ﻟﺔ ﻁﻴﺎ ﺭﺓ ) ﺼﻨ ﻑ ﻴﺠﻤﻊ‬ ‫ﺍﺠﻬﺔﺁ‬ ‫‪ ،‬ﻭﻨ ﻅﻴ ﻑﻟﻬﺎ ﻭ‬ ‫ﻨﺸﺘﻕﺃﻭﺍﻜ ﺱ ﻤ ﻥ ﺭﺍﺩﺍ ﺭ‬ ‫ﺍ ﺕ(‪.‬‬ ‫ﺍﻉﺍﻟ ﻁﺎﺌﺭ‬ ‫ﻜلﺃﻨﻭ‬ ‫ﻟﺔ ﻁﻴﺎ ﺭﺓ‪.‬‬ ‫ﺍﺠﻬﺘﻴ ﻥ ﻻﻗﻁ ﻭﺁ‬ ‫ﻨﺨﻠﻕ ﺼﻨ ﻑﺃﻭﺍﻜ ﺱ ﺠﺩﻴﺩ ﻭﻨ ﺯﻭﺩﻩ ﺒﻭ‬ ‫ﺍﺴﺘﻌﻤﺎلﺍﻟﺘﺭﻜﻴ ﺏ‪:‬‬ ‫‪ ،‬ﻭﻨ ﻅﻴ ﻑﻟﻬﺎ ﺨﺎ ﺼﻴﺔ ﺭﺍﺩﺍ ﺭ‪.‬‬ ‫ﻨﺸﺘﻕﺃﻭﺍﻜ ﺱ ﻤ ﻥ ﻁﺎﺌ ﺭﺓ‬ ‫ﻨﺸﺘﻕﺃﻭﺍﻜ ﺱ ﻤ ﻥ ﺭﺍﺩﺍ ﺭﻟﻬﺎ ﺨﺎ ﺼﻴﺔ ﻁﺎﺌ ﺭﺓ‬ ‫ﻨﺨﻠﻕ ﺼﻨ ﻑﺃﻭﺍﻜ ﺱ ﺠﺩﻴﺩ ﻭﻨ ﺯﻭﺩﻩ ﺒﺨﺎ ﺼﻴﺘﻴ ﻥ‪ :‬ﺭﺍﺩﺍ ﺭ ﻭ ﻁﺎﺌ ﺭﺓ‪.‬‬ ‫‪...‬‬ ‫ﺍ ﻤﺎ ﻅﻬﺭﺃ ﻥ ﺒﻌ ﺽ‬ ‫ﻫﺫﻩﺍﻹﻤﻜﺎﻨﻴﺎ ﺕﺍﻟﻤﺘﻌﺩﺩﺓ ﺘﻭ ﻀﺢ ﻤﺩﻯ ﻏﻨﻰﺍﻟﻜﺎﺌ ﻥ ﻭﻓﻌﺎﻟﻴﺘﻪ‪ .‬ﻭﺇﺫ‬ ‫‪ ،‬ﻓﺒﺘﻐﻴﺭﺍﻟﻤﻌ ﻁﻴﺎ ﺕ ﺘﺘﻐﻴﺭﺍﻟ ﻁﺭﻕ‪ .‬ﻜﻤﺎﺃﻨﻪ‬ ‫‪ ،‬ﻓﺈﻨﻬﺎ ﻟﻴﺴ ﺕﻨﺘﻴﺠﺔ ﺜﺎﺒﺘﺔ‬ ‫ﺍﻟﻨﻤﺎﺫﺝﺃ ﺤﺴ ﻥ ﻤ ﻥ ﻏﻴﺭ ﻫﺎ‬ ‫ﺍﺜﺔ ﻤﻊﺍﻟﺘﺭﻜﻴ ﺏ ﻜﻤﺎ ﺴﻨﺸﻴﺭ ﺇﻟﻰ‬ ‫‪،‬ﺃﻭﺍﻟﻭﺭ‬ ‫ﺍ ﺤﺩ‬ ‫ﺍﺠﻬﺎ ﺕ ﻤﻊﺍﻟﺘﺭﻜﻴ ﺏ ﻓﻲ ﺁ ﻥ ﻭ‬ ‫ﺍﻡﺍﻟﻭ‬ ‫ﻴﻤﻜ ﻥﺍﺴﺘﺨﺩ‬ ‫ﺫﻟ ﻙ‪.‬‬ ‫ﺍﻟﺘﻲ ﻟﻴﺴ ﺕ ﺒﺎﻟ ﻀﺭﻭﺭﺓ‬ ‫‪،‬ﻭ‬ ‫‪٣ ,٢ ،‬‬ ‫‪٢ ,٢ ،‬‬ ‫ﺍ ﺕ ﻴﻔ ﻀلﺍﻟ ﺤﺎﻻ ﺕ ‪١‬‬ ‫ﺍﺭ‬ ‫ﺍﺩ‬ ‫‪،‬ﺃ ﻱ ﻤ ﺼﻤﻡ ﺭ‬ ‫ﺍ ﺫﻟ ﻙ‬ ‫ﻋﺩ‬ ‫‪.١,٣ ،‬‬ ‫‪١,٢ ،‬‬ ‫ﺍﻟﺘﻲ ﻗﺩ ﺘﻜﻭ ﻥ‪١ :‬‬ ‫ﺍ ﺕﺍﻟﺫ ﻱ ﻗﺩ ﻴﻔ ﻀل ﺤﺎﻻ ﺕﺃﺨﺭﻯ ﻭ‬ ‫ﻨﻔ ﺱ ﻓﻜﺭﺓ ﺼﺎﻨﻊﺍﻟ ﻁﺎﺌﺭ‬ ‫ﺍﻟﺘ ﺼﻤﻴﻤﺎ ﺕﺍﻵﺘﻴﺔ ﺘﺒﻴ ﻥ ﻤﺨﺘﻠ ﻑﺍﻟ ﺤﺎﻻ ﺕﺍﻟﺘﻲ ﻴﻤﻜﻨﻨﺎ ﺘ ﺤﻘﻴﻘﻬﺎ‪.‬‬

‫‪Interfacing‬‬ ‫‪plots flying‬‬

‫‪Interfacing‬‬ ‫‪Detector‬‬

‫‪Radar‬‬

‫‪Airplane‬‬

‫‪AWACS 2.3‬‬ ‫‪AWACS 2.2‬‬ ‫‪AWACS 2.1‬‬ ‫‪AWACS 1‬‬

‫ﻟﻭﺍﺠ ﻬﺎﺕ‬ ‫ﻟﺒﺔﺃﻭﺍﻜ ﺱ ﺒﺎ ﺴﺘﺨﺩﺍ ﻡﺍ‬ ‫ﻗﻭ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫‪ǎ‬‬

‫‪ǚ‬‬

‫ﻭﺍﺠ ﻬﺔ ﻻﻗﻁ‬

‫ﺭﺍﺩﺍ ﺭ‬

‫ﻁﺎﺌ ﺭﺓ‬

‫‪Ǜ‬‬

‫واﻛ ﺲ ‪٣٫٢‬‬ ‫أ‬ ‫واﻛ ﺲ ‪٢ ٫٢‬‬ ‫أ‬

‫واﻛ ﺲ ‪١ ٫٢‬‬ ‫أ‬ ‫واﻛ ﺲ ‪١‬‬ ‫أ‬

‫ﻟ ﻰ ﺇﺩﺭﺍﺝ‬ ‫ﻟﻤﺘﻘﻁﻌﺔﺘﺸﻴ ﺭ ﺇ‬ ‫ﺍﻷﺴﻬﻡﺍ‬ ‫ﻟ ﺼﻨ ﻑ‪.‬‬ ‫ﻭﺍﺠﻬﺔ ﻀﻤﻥﺍ‬

‫ﺍﺠﻬﺎ ﺕ ﻓﻲ ﻟﻐﺔﺃﻨ ﻅﻤﺔ‬ ‫‪ ،‬ﻻ ﻴﻭﺠﺩ ﻤﺒﺩﺃ ﺜﺎﺒ ﺕ ﻓﻴﻡ ﻴﺨ ﺹ ﺘﻘﺩﻴﻡ ﻭﺘﻤﺜﻴلﺍﻟﻭ‬ ‫ﻓﻲﺍﻟﻭﻗ ﺕﺍﻟ ﺤﺎﻟﻲ‬ ‫‪،‬ﺍﻟﻭﺴﻴﻠﺔﺍﻷﻜﺜﺭ ﺒﺴﺎ ﻁﺔ ﺘﺘﻤﺜل ﻓﻲﺍﻟﺘ ﺼﺭﻴﺢ ﺒ ﺼﻨ ﻑ ﻤﺠﺭﺩ )ﻤ ﻥ ﺩﻭ ﻥ‬ ‫ﺍﻟﻜﺎﺌ ﻥ ‪.UML‬ﺃﻴ ﻀﺎ‬ ‫ﺨ ﺼﺎﺌ ﺹ( ﻭ ﺤﻴﺙﺍﻹﺴﻡ ﻴﻜﻭ ﻥ ﻤﺴﺒﻭﻗﺎ ﺒﺎﻟﻤ ﺼ ﻁﻠﺢ ‪.Interface‬‬ ‫ﺍﻟﺘﺨ ﺼﻴ ﺹ ﻭﻟﻜ ﻥ ﻤﻊ ﺨ ﻁ ﻤﺘﻘ ﻁﻊ‬ ‫ﺍﺴﺘﺨﺩﻤﻨﺎ ﺴﻬﻤﺎ ﻴﺸﺒﻪ ﺫﻟ ﻙﺍﻟﻤﺴﺘﻌﻤل ﻓﻲ ﺘﻤﺜﻴلﺍﻟﺘﻌﻤﻴﻡ‪/‬‬ ‫ﺍﺠﻬﺔ‪.‬‬ ‫ﺍﺠﻬﺔ ﻤ ﻥ ﻗﺒلﺍﻟ ﺼﻨ ﻑ‪ .‬ﺭﺃ ﺱﺍﻟﺴﻬﻡ ﻴﻜﻭ ﻥ ﻤﻭﺠﻪ ﻨ ﺤﻭﺍﻟﻭ‬ ‫ﺍﺝ ﻟﻭ‬ ‫ﻟﺘﻭ ﻀﻴﺢﺃﻨﻪ ﺇﺩﺭ‬ ‫‪Airplane‬‬

‫‪Interfacing‬‬ ‫‪plots flying‬‬

‫‪AWACS 3.2‬‬

‫‪AWACS 3.1‬‬

‫‪AWACS 3.3‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﻁﺎﺌ ﺭﺓ‬

‫ﺭﺍﺩﺍ ﺭ‬

‫ﺃﻭﺍﻜ ﺱ ‪٢,٣‬‬

‫ﺃﻭﺍﻜ ﺱ ‪١,٣‬‬

‫ﺃﻭﺍﻜ ﺱ ‪٣,٣‬‬

‫ﻟ ﻭﺭﺍﺜﺔ‬ ‫ﻟﺘﺭﻜﻴﺏ ﻭﺍ‬ ‫ﻟﺒﺔﺃﻭﺍﻜ ﺱ ﺒﺎ ﺴﺘﺨﺩﺍ ﻡﺍ‬ ‫ﻗﻭ‬ ‫‪٥‬‬ ‫‪.٥‬‬

‫ﻟ ﺼﻔﺎﺕ ‪: Polymorphisme‬‬ ‫ﺘﻌﺩﺩﺍ‬ ‫‪ .١‬ﺘﻌﺭﻴ ﻑ‪:‬‬

‫ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ﻫﻭﺍﻟﻤﺒﺩﺃﺍﻟﺜﺎﻟﺙ ﻤ ﻥﺍﻟﻤﺒﺎﺩ ﺉﺍﻟﺘﻲ ﻴﺭﺘﻜ ﺯ ﻋﻠﻴﻬﺎ ﻭﺠﻭﺩﺍﻟﻜﺎﺌ ﻥ‪.‬ﺃﻭ‬ ‫‪ ،‬ﻓﺈ ﻥ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ﻴﺴﻤﺢ ﻷ ﻱ‬ ‫ﺍﻷﻗﻭﻯ‪ .‬ﻭﻜﻤﺎ ﻴﺸﻴﺭ ﺇﻟﻴﻪﺍﺴﻤﻪ‬ ‫ﺍﻭ‬ ‫ﺒﺎﻷ ﺤﺭﻯ ﻫﻭﺍﻟﻤﺒﺩﺃﺍﻷﻜﺜﺭ ﺘﺄﺜﻴﺭ‬ ‫‪ ،‬ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ﻴﻤﻜ ﻥ‬ ‫ﻤﻨﻬﺎﺝ ﻤ ﻥﺃ ﻥ ﻴﺘﺨﺫ ﻋﺩﺓ ﻭﺠﻭﻩ ﻓﻲﺃ ﺼﻨﺎ ﻑ ﻤﺨﺘﻠﻔﺔ‪ .‬ﻓﻤ ﻥ ﺨﻼلﺍﻟﻠﻐﺎ ﺕ‬ ‫‪ ،‬ﻓﻲ ﺤﻴ ﻥ ﻴ ﺼﻨﻔﻪ ﺁﺨﺭﻭ ﻥ ﻀﻤ ﻥﺍﻷ ﺼﻨﺎ ﻑﺍﻟﺘﺎﺒﻌﺔ‬ ‫ﺍﻟﺘﻌﺒﻴﺭ ﻋﻨﻪ ﻓﻲ ﻤﺠﻤﻭﻉﺃ ﺼﻨﺎ ﻑ ﻨ ﻅﺎﻡ ﻤﺎ‬ ‫ﻟﻨﻔ ﺱﺍﻟﺘﺴﻠﺴل‪.‬‬ ‫ةﺗﻌﺪداﻟ ﺼﻔﺎ ت‪:‬‬ ‫‪ .٢ .٥‬ﻗﻮ‬ ‫ﺴﻭ ﻑ ﻨﺒﻴ ﻥ ﻗﻭﺓ ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ﻤ ﻥ ﺨﻼل ﻤﻌﺎﻟﺠﺔﻟﻤﺜﺎل ﻜﺎﺌﻥ ﺒﻴﺎﻨﻲ ‪GraphicObject‬‬ ‫ﺍﺌﺭ ﻭﺃﺸﻴﺎﺀ‬ ‫‪ ،‬ﺩﻭ‬ ‫‪ ،‬ﻤﺜﻠﺜﺎ ﺕ‬ ‫‪.‬ﺃ ﻱ ﺼﻭﺭﺓ ﻴﻤﻜ ﻥ ﺭﺅﻴﺘﻬﺎ ﻜﻤ ﺯﻴﺞ ﻤ ﻥﺍﻷﺸﻜﺎلﺍﻟﻬﻨﺩﺴﻴﺔ‪ :‬ﻤﺭﺒﻌﺎ ﺕ‬ ‫ﺍﺍﻟﺸﻜل ﻤﻤﻜ ﻥ ﻤ ﻥ ﺨﻼل ﻤﺒﺩﺃ‬ ‫ﺃﺨﺭﻯ ﻴﻤﻜ ﻥﺍﺸﺘﻘﺎﻗﻬﺎ ﻤ ﻥﺍﻟ ﺼﻨ ﻑ ﻜﺎﺌﻥ ﺒﻴﺎﻨﻲ‪ .‬ﺘﺭﻜﻴ ﺏ ﻋﻠﻰ ﻫﺫ‬ ‫ﺍ ﺕ )‪ .(notion of pointers downward compatibility‬ﻋﻠﻰ‬ ‫ﺍﻓﻕﺍﻟﺘﻨﺎ ﺯﻟﻲﻟﻠﻤﺅﺸﺭ‬ ‫ﺍﻟﺘﻭ‬ ‫ﻟ ﻤ ﺭﺠﻊ ‪ ("Reference‬ﻋﻠﻰ ﻜﺎﺌ ﻥﻟ ﺼﻨ ﻑ ﻤﺘﺨ ﺼ ﺹ ﻴﻤﻜ ﻥ‬ ‫‪ ،‬ﻤﺅﺸﺭ )ﺃﻭ ﻓﻲ ﺒﻌ ﺽﺍﻟﻠﻐﺎ ﺕ "ﺍ‬ ‫ﻜل‬ ‫ﺍﺌﻤﺎﺃ ﻥ ﻴﺅﺸﺭ ﻋﻠﻰ ﻜﺎﺌ ﻥ ﻤ ﻥ ﺼﻨ ﻑ ﻋﺎﻡ‪.‬‬ ‫ﺩ‬ ‫ﺍﻤﺎ ﻋﻠﻴﻨﺎ ﻁﻠ ﺏﺍﻟﻤﻨﻬﺎﺝﺃﻨﺸ ﺭ ‪Display‬‬ ‫‪ ،‬ﻓﺈﻨﻪ ﻴﻜﻭ ﻥﻟ ﺯ‬ ‫ﺍ ﻤﺎﺃﺭﺩﻨﺎ ﺘﺨ ﻁﻴ ﻁ ﺭﺴﻡ ﺘﺎﻡ‬ ‫ﺇﺫ‬ ‫‪،‬ﻟﻘﺩ ﺤﺎﻓ ﻅﻨﺎ ﻋﻠﻰ ﺘﻭﻗﻴﻌﺎ ﺕ‬ ‫ﺍﺭ ﺫﻟ ﻙ‬ ‫ﻟﻜل ﻨﻭﻉ ﻤ ﻥﺍﻟﻜﺎﺌﻨﺎ ﺕﺍﻟﺘﻲ ﺘﺩﺨل ﻓﻲ ﺭﺴﻤﻨﺎ‪ .‬ﻋﻠﻰ ﻏﺭ‬ ‫ﺍﻡ‬ ‫ﻤﺨﺘﻠ ﻑ ﻤﻨﺎ ﻫﺞﺍﻟﻨﺸﺭﻟﻜلﺍﻟﻜﺎﺌﻨﺎ ﺕﺍﻟﻤﻨﺘﻤﻴﺔﻟﻨﻔ ﺱ ﺘﺴﻠﺴل ﻜﺎﺌﻥ ﺒﻴﺎﻨﻲ‪ :‬ﺇﻨﻪﺍﻟﺸﺭ ﻁ ﻗﺒلﺍﺴﺘﺨﺩ‬ ‫‪ ،‬ﻴﻤﻜﻨﻨﺎﺍﻵ ﻥﺍﺴﺘﻌﻤﺎل ﻜﻭﺩﺍﻟﺸﻜل‪:‬‬ ‫ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ‪ .‬ﺇﺫ ﻥ‬ ‫‪method Drawing :: Display‬‬ ‫{‬ ‫‪for every GraphicObject include‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫{‬ ‫]‪[Object Display‬‬ ‫}‬ ‫}‬

‫ﻟ ﺼﻔﺎﺕﻓﻲ ﻤﺠﻤ ﻭﻋﺔ‬ ‫ﺇ ﺴﺘﻌﻤﺎل ﺘﻌﺩﺩﺍ‬ ‫ﺍﺓﺍﻟﻤﻨﻬﺎﺝﺍﻟﻤﻨﺎﺴ ﺏﻟﻠﻜﺎﺌ ﻥﺍﻟﻤﻨﺎﺴ ﺏ‪.‬ﺍﻵﻟﻴﺔ‬ ‫ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕﻟﻠﻤﻨﻬﺎﺝﺃﻨﺸ ﺭ ﻴ ﻀﻤ ﻥ ﻤﻨﺎﺩ‬ ‫ﺍﺘﻴﺠﻴﺔﺍﻟﺭﺒ ﻁﺍﻟﻤﺘﺄﺨﺭﺃﻭ ‪.late Bending‬‬ ‫ﺍﺍﻟﻤﻴﻜﺎﻨﻴ ﺯﻡﺍﻟﻌﺠﻴ ﺏ ﺘﺭﺘﻜ ﺯ ﻋﻠﻰﺍﺴﺘﺭ‬ ‫ﺍﺨﻠﻴﺔﻟﻬﺫ‬ ‫ﺍﻟﺩ‬ ‫‪ ،‬ﻭﻴ‪‬ﺸﻔﹼﺭ‬ ‫ﺍﺒ ﻁ‬ ‫ﺍﻟﺔ ﻴ‪ ‬ﺤﺴ ﺏﺃﺜﻨﺎﺀ ﺘ ﺤﺭﻴﺭﺍﻟﺭﻭ‬ ‫ﺍﺀﺃﻭ ﺩ‬ ‫ﺍ ﻥ ﻁﻠ ﺏ ﺇﺠﺭ‬ ‫‪ ،‬ﻋﻨﻭ‬ ‫ﻟﻨﻔﺭ ﺽ ﺒﺭﻨﺎﻤﺠﺎ ﻜﻼﺴﻴﻜﻴﺎ‬ ‫‪ ،‬ﻤﻜﺎ ﻥ‬ ‫‪‬ﺭﻉ )‪ .(early Bending‬ﻓﻲ ﺤﺎﻟﺔﺍﻟﺭﺒ ﻁﺍﻟﻤﺘﺄﺨﺭ‬ ‫ﺒﺩﻗﺔ ﻓﻲﺍﻟﺒﺭﻨﺎﻤﺞ‪ :‬ﺇﻨﻪﺍﻟﺭﺒ ﻁﺍﻟﻤﺘﺴ‬ ‫ﺍ ﻥﺍﻟ ﻁﻠ ﺏ‪.‬‬ ‫ﺍﻟﻤﻨﻬﺎﺝﺍﻟﻤ ﻁﻠﻭ ﺏ ﻴﻘﻊ ﻓﻲﺍﻟﻜﺎﺌ ﻥ ﻨﻔﺴﻪ‪ .‬ﺇﺫ ﻥ ﻓﻲﺃﺜﻨﺎﺀﺍﻟﺘﻨﻔﻴﺫ ﻴﻨﺸ ﺊﺍﻟﺒﺭﻨﺎﻤﺞ ﻋﻨﻭ‬ ‫ﻟﻰ‬ ‫‪ ،‬ﻭﻴﺘﻌﻠﻕﺍﻷﻤﺭ ﺒﺎﻟﻤﻨﻬﺎﺝﺘﺤ ﺭﻙ ﺇ‬ ‫‪ ،‬ﻓﻠﻨﻔﺭ ﺽ ﻤﺜﺎﻻ ﺁﺨﺭ‬ ‫ﺍﺍﻟﻤﺜﺎل ﻤﺒﻬﻤﺎ‬ ‫ﻗﺩ ﻴﻜﻭ ﻥ ﻫﺫ‬ ‫‪MoveTo‬‬ ‫ﺍﻉﺍﻟﻜﺎﺌ ﻥﺍﻟﺒﻴﺎﻨﻲ‬ ‫ﺍﺍﻟﻜﻭ ﺩ ﻴﻌﺩ ﺼﺎﻟ ﺤﺎ ﻷ ﻱ ﻨﻭﻉ ﻤ ﻥﺃﻨﻭ‬ ‫ﺍﻟﺫ ﻱ ﺸﺭ ﺤﻨﺎﻩ ﺴﺎﺒﻘﺎ‪ .‬ﺇﺫ ﻥ ﻫﺫ‬ ‫‪،‬ﻭ‬ ‫ﺍﺜﻴﺎ ﺕ ﺜﻡ ﻨﺸﺭ‪ .‬ﻤﺭﺓ‬ ‫‪ ،‬ﺘﻐﻴﻴﺭﻟ ﻺ ﺤﺩ‬ ‫ﺍ ﺼل‬ ‫ﺍﺌﻤﺎ ﻋﻠﻰ ﻤ ﺤﻭ ﻤﺘﻭ‬ ‫ﺍﻟﺫ ﻱ ﻨ ﻁﺒﻘﻪ ﻋﻠﻴﻪ‪:‬ﺍﻟﺘ ﺤﺭﻴ ﻙ ﻴﻌﺘﻤﺩ ﺩ‬ ‫ﺍﺍﻟﻜﻭﺩ ﺒﻔ ﻀل ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ‪ polymorphism‬ﻷﻨﻪ ﻤ ﻁﻠﻭ ﺏﺃ ﻥ ﺘﻜﻭ ﻥ ﻤﻨﺎ ﻫﺞ‬ ‫‪ ،‬ﻴﻌﻤل ﻫﺫ‬ ‫ﺃﺨﺭﻯ‬ ‫ﺍﺩ ﻫﻲﺍﻟﺘﻲ ﺘﻡ ﻁﻠﺒﻬﺎ‪.‬‬ ‫ﺍﻟﻨﺸﺭﺍﻟﻤﻨﺎﺴﺒﺔ ﻟﻠﻜﺎﺌ ﻥﺍﻟﻤﺭ‬ ‫ﺍﻟﻤ ﺤﻭ ﻭ‬ ‫‪،‬‬ ‫ﺍﺍﻋﺘﺒﺭﻨﺎﺃ ﻥﺍﻟﻤ ﺤﻭ ﻴﺘﻠﺨ ﺹ ﻓﻲ ﺇﻋﺎﺩﺓ ﺭﺴﻡﺍﻟﻜﺎﺌ ﻥ ﻭﻟﻜ ﻥ ﺒﻠﻭ ﻥﺍﻟﺨﻠﻔﻴﺔ‬ ‫‪ ،‬ﺇﺫ‬ ‫ﻨﻔ ﺱﺍﻟﺸﻲ ﺀ‬ ‫ﺍﺍﻟﺸﻜل‪:‬‬ ‫ﻓﺈﻨﻪ ﻴﻤﻜﻨﻨﺎ ﺘﻌﺭﻴ ﻑ ﻤﻨﻬﺎﺝﺍﻟﻤ ﺤﻭ ﺒﻬﺫ‬ ‫‪method GraphicObject :: Delete‬‬ ‫{‬ ‫]‪[Object SetColor: BackgroundColor‬‬ ‫]‪[Object Display‬‬ ‫}‬ ‫ﻟﻤﻨ ﻬﺎﺝ ‪delete‬‬ ‫ﻟ ﺼﻔﺎﺕﻓﻲﺍ‬ ‫ﺇ ﺴﺘﻌﻤﺎل ﺘﻌﺩﺩﺍ‬ ‫‪.٥‬‬

‫‪.٣‬‬

‫اﺋﺪ ‪Overloading‬‬ ‫ﺷﻜﻞ ﻧﺎﺟﻊﻟﺘﻌﺪداﻟ ﺼﻔﺎ ت‪:‬اﻟﺘﺤﻤﻴﻞاﻟﺰ‬

‫ﺍﻟﺫ ﻱ ﻴﺴﻤﺢ‬ ‫‪،‬ﻭ‬ ‫ﺍﺌﺩ ﻫﻭ ﺁﻟﻴﺔ ﻤﻘﺘﺭ ﺤﺔ ﺒﻜﺜﺭﺓ ﻤ ﻥ ﻗﺒلﻟﻐﺎ ﺕﺍﻟﺘﻭﺠﻪﺍﻟﻜﺎﺌﻨﻲ‬ ‫ﺍﻟﺘ ﺤﻤﻴلﺍﻟ ﺯ‬ ‫ﺍ ﺕ ﺘ ﺤﻤل ﻨﻔ ﺱﺍﻹﺴﻡ‪.‬‬ ‫ﺍﺀ‬ ‫ﺍل ‪ /‬ﺇﺠﺭ‬ ‫ﺒﺘﺨ ﺼﻴ ﺹ ﺘﻭﻗﻴﻌﺎ ﺕ ﻤﺨﺘﻠﻔﺔﻟﻤﻨﺎ ﻫﺞ ‪ /‬ﺩﻭ‬ ‫‪ ،‬ﻨﻘﺩﺭﺃ ﻥ ﻨﻘﺘﺭ ﺡ ﺘﻭﻗﻴﻌﻴ ﻥ ﻤﺨﺘﻠﻔﻴ ﻥ ﻟﻠﻤﻨﻬﺎﺝﺃﻨﺸ ﺭ‬ ‫ﻜﻤﺜﺎل‬ ‫ﺍ ﻤﺎﺃﺭ ﺩﻨﺎﺍﺴﺘﻌﻤﺎل ﻭﺴﻴ ﻁ ﻨﺸﺭ ﺒﺎﻟﻐﻴﺎ ﺏ ‪.Default‬‬ ‫ﺍ ﺕ ﺇﺫ‬ ‫ﺍﻤﺘﺭ‬ ‫‪ v‬ﻤ ﻥ ﺩﻭ ﻥ ﺒﺎﺭ‬ ‫ﺍﻤﺘﺭ‪.‬‬ ‫‪ v‬ﺘ ﺤﺩﻴﺩ ﻭﺴﻴ ﻁ ﺒﺒﺎﺭ‬

‫‪٦‬‬

‫ﻛﺔ ‪The Relation of Association :‬‬ ‫ا‬ ‫ﻋﻼﻗﺔاﻟﺸﺮ‬

‫ﺍﻟﺒﺭﻤﺠﻴﺔ ﻭﻟﻴﺴ ﺕﺍﻻﻗﺘ ﺼﺎﺩﻴﺔ( ﻫﻲ ﺜﺎﻟﺙ ﻨﻭﻉ ﻤﻬﻡ ﻤ ﻥﺍﻟﻌﻼﻗﺔﺍﻟﺘﻲ ﻓﺭ ﻀﻨﺎ ﻫﺎ‬ ‫ﺍﻜﺔ )‬ ‫ﺍﻟﺸﺭ‬ ‫ﺍﻟﺘﺭﻜﻴ ﺏ ‪Aggregation‬‬ ‫ﺍﺜﺔ ﻻ ﺘﻌﺎﻨﻲ ﻤ ﻥﺃ ﻱ‬ ‫ﺍ ﻜﺎﻨ ﺕﺍﻟﻭﺭ‬ ‫‪ ،‬ﻓﺈﺫ‬ ‫ﺍﺜﺔ ‪ Heritage‬ﻭ‬ ‫ﺒﻌﺩ ﻜل ﻤ ﻥﺍﻟﻭﺭ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﺍﻜﺔ ﻴ ﺼﻌ ﺏ‬ ‫‪ ،‬ﻷﻨﻬﺎ ﺘﺘﺭﺠﻡﺍﻟﺠﻤﻠﺔ "‪ ...‬ﻫﻲ ﺸﻜل ﺨﺎ ﺹ ﻤ ﻥ ‪ ."(IS A) ...‬ﻓﺈ ﻥ ﻋﻼﻗﺔﺍﻟﺸﺭ‬ ‫ﺇﻟﺘﺒﺎ ﺱ‬ ‫‪ ،‬ﻓﺈﻨﻬﺎ ﻴﻤﻜﻨﻨﺎﺍﻟﻘﻭل‪ ..." :‬ﻴﺘ ﺼل ﻤﻊ‬ ‫‪ ،‬ﻓ ﺤﺴ ﺏ ﻤﺨﺘﻠ ﻑﺍﻟﻨﺎﺸﺭﻴ ﻥ‬ ‫ﺍﻟﺭﻤ ﺯ ﺇﻟﻴﻬﺎ‪ .‬ﻋﻠﻰ ﻜل‬ ‫ﺘﻤﺜﻴﻠﻬﺎ ﻭ‬ ‫‪ ،‬ﻴﻤﻜ ﻥ ﺒﺴﻬﻭﻟﺔ‬ ‫‪،‬ﺃﻭ ﺒﺎﻹﻨﺠﻠﻴ ﺯﻴﺔ " ‪ ." USES A‬ﻓﻔﻲ ﺒﻌ ﺽﺍﻟ ﺤﺎﻻ ﺕ‬ ‫‪،"...‬ﺃﻭ "‪ ...‬ﻴﺴﺘﻌﻤل ‪"...‬‬ ‫ﺃ ﻥ ﺘﺨﺘﻠ ﻁﺍﻷﻤﻭﺭ ﻤﻊ ﻋﻼﻗﺔﺍﻟﺘﺭﻜﻴ ﺏ ‪ ...") aggregation‬ﻴﺘﺭﻜ ﺏ ﻤ ﻥ ‪ ("...‬ﻜﻤﺎ ﺴﻨﺭﻯ ﻓﻲ‬ ‫ﺍﻟﻤﺜﺎلﺍﻟﺫ ﻱ ﺴﻴﺄﺘﻲ ﻻ ﺤﻘﺎ‪.‬‬ ‫ﺍﻨﺎ ﺕ‪.‬‬ ‫‪ ،‬ﻓﻠﻨﻔﺭ ﺽ ﻤﺜﺎﻻ ﻜﻼﺴﻴﻜﻴﺎ‪ ،‬ﻭﻴﺘﻌﻠﻕﺍﻷﻤﺭ ﺒ ﺤﺩﻴﻘﺔﺍﻟ ﺤﻴﻭ‬ ‫ﻤ ﻥﺃﺠل ﺘﺜﺒﻴ ﺕﺍﻟﻤﻔﺎ ﻫﻴﻡ‬ ‫‪ ،‬ﻭﻴﺘﺠﺎﻭ ﺏ ﻤﻊ ﺘﻔﻜﻴﺭﺍﻟﻤ ﺼﻤﻡ‪.‬‬ ‫ﻓﻤ ﻥ ﺠﻬﺔ ﻨﺫﻜﹼﺭﺃ ﻥ ﻤﺒﺩﺃﺍﻟﻜﺒﺴﻠﺔ ﺸﺨ ﺼﻲ‬ ‫ﺍﻨﺎ ﺕ ﺇﺫ ﻥ ﺘﺘﻜﻭ ﻥ ﻤ ﻥ‪:‬‬ ‫ﺤﺩﻴﻘﺔﺍﻟ ﺤﻴﻭ‬ ‫‪ v‬ﻤﺠﻤﻭﻉﺃﻗﻔﺎ ﺹ‬ ‫ﺍﻨﺎ ﺕ‬ ‫‪ v‬ﻤﺠﻤﻭﻋﺔ ﺤﻴﻭ‬ ‫ﺍﺱ‬ ‫‪ v‬ﻤﺠﻤﻭﻋﺔ ﺤﺭ‬ ‫ﻴ ﻅﻬﺭ ﺒﻭ ﻀﻭ ﺡﺃ ﻥ ﻫﺫﻩﺍﻟﻌﻼﻗﺎ ﺕ ﻤ ﻥﺍﻟﺘﺭﻜﻴ ﺏ ‪.aggregation‬‬ ‫ﺍﺭﺓ‬ ‫ﺍﻨﻴ ﻥ ﺇﺩ‬ ‫ﺍﻨﺎ ﺕ ) ﺤﺴ ﺏ ﻗﻭ‬ ‫ﺍ ﻤﻌﻴﻨﺎ ﻤ ﻥﺍﻟ ﺤﻴﻭ‬ ‫ﺍﻗ ﺏ ﻋﺩﺩ‬ ‫‪،‬ﺃ ﻱ ﺤﺎﺭ ﺱ ﻴﺠ ﺏﺃ ﻥ ﻴﺭ‬ ‫ﻋﻭ ﺽ ﺫﻟ ﻙ‬ ‫ﺍ ﻤﻌﻴﻨﺎ ﻤ ﻥ‬ ‫‪،‬ﺃ ﻱ ﻗﻔ ﺹ ﻴ ﺤﻭ ﻱ ﻋﺩﺩ‬ ‫ﺍل‬ ‫ﺍ ﺁﺨﺭ ﻤ ﻥﺍﻷﻗﻔﺎ ﺹ‪ .‬ﻋﻠﻰ ﻨﻔ ﺱﺍﻟﻤﻨﻭ‬ ‫‪ ،‬ﻭﻴﻨ ﻅ ﻑ ﻋﺩﺩ‬ ‫ﺍﻟ ﺤﺩﻴﻘﺔ(‬ ‫ﺍﺭﺓﺍﻟ ﺤﺩﻴﻘﺔ(‪.‬‬ ‫ﺍﺌﻤﺎ ﺤﺴ ﺏ ﺇﺩ‬ ‫ﺍﻨﺎ ﺕ ) ﺩ‬ ‫ﺍﻟ ﺤﻴﻭ‬ ‫ﺍﻟﻌﻼﻗﺎ ﺕﺍﻷﺨﻴﺭﺓ ﻻ ﺼﻠﺔﻟﻬﺎ ﺒﺎﻟﺘﺭﻜﻴ ﺏ ‪) aggregation‬ﻋﺎﺩﺓ ﻤﺎ ﻨﻌﺘﺒﺭﺃ ﻥ ﻨﻔ ﺱﺍﻟﻜﺎﺌ ﻥ‬ ‫ﺍﻜﺎ ﺕ‪ .‬ﺇﺫ ﻥ ﻨﻘﻭﻡ ﺒﺠﻌل ﻜل ﻋﻼﻗﺔ ﻻ ﺘﺘﻨﺎﺴ ﺏ‬ ‫ﺍ ﻤ ﻥ ﻗﺒلﺍﻟﻜﺎﺌﻨﺎ ﺕﺍﻷﺨﺭﻯ( ﻭﻟﻜﻨﻬﺎ ﺸﺭ‬ ‫ﻟﻴ ﺱ ﻤﻌﺘﻤﺩ‬ ‫‪ ،‬ﻓﻨ ﺤ ﺼل ﺇﺫ ﻥ ﻋﻠﻰﺍﻟﺘ ﺼﻤﻴﻡﺍﻟﺫ ﻱ ﺴﻴﺄﺘﻲ ﻻ ﺤﻘﺎ‪.‬‬ ‫ﺍﻜﺔ‬ ‫ﺍﺜﺔﺃﻭﺍﻟﺘﺭﻜﻴ ﺏ ﻀﻤ ﻥ ﺤﺎﻟﺔﺍﻟﺸﺭ‬ ‫ﻤﻊﺍﻟﻭﺭ‬ ‫ﻋﻠﻰ ﻁﺭﻴﻘﺔﺍﻟﺘﺭﻜﻴ ﺏ ‪aggregation‬‬ ‫‪ ،‬ﺴﻭ ﻑ ﻨ ﺤﺩﺩ ﻜﺎﺭﺩﻴﻨﺎﻟﻴﺎ ﺕ ﻭﻤﻬﺎﻡ ﻋﻠﻰ ﻋﻼﻗﺔ‬ ‫ﺍﺀﺓ‪:‬‬ ‫‪ ،‬ﻨﺴﺘ ﻁﻴﻊ ﻗﺭ‬ ‫ﺍ ﻤﺎﺍﻋﺘﺒﺭﻨﺎﺍﻟﻌﻼﻗﺔ ﺒﻴ ﻥﺍﻟ ﺼﻨﻔﻴ ﻥ ﻗﻔ ﺹ ﻭ ﺤﺎ ﺭ ﺱ‬ ‫‪ ،‬ﺇﺫ‬ ‫ﺍﻜﺔ‪ .‬ﻜﻤﺜﺎل‬ ‫ﺍﻟﺸﺭ‬ ‫ﱠ ﻑ ﻤﻥ ﻗﺒل ﺤﺎ ﺭ ﺱ ﻭﺍ ﺤﺩﻓﻘﻁ"‬ ‫‪‬ﻨﻅ‬ ‫ﻟﻰ ﻥ ﻗﻔ ﺹ ‪ /‬ﺃ ﻱ ﻗﻔ ﺹ ﻴ‬ ‫ّ ﻑ ﻤﻥ ‪٠‬ﺇ‬ ‫‪‬ﻨﻅ‬ ‫ِ‬ ‫"ﺃ ﻱ ﺤﺎ ﺭ ﺱ ﻴ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫‪Zoo‬‬

‫*‬

‫*‬ ‫‪is cleaned by ١‬‬

‫‪Cage‬‬ ‫‪containing‬‬

‫*‬

‫‪١‬‬

‫‪Guardian‬‬

‫‪clean‬‬ ‫‪feeds١‬‬

‫*‬

‫‪n‬‬ ‫‪is fed by‬‬

‫‪Animal‬‬

‫‪is contained‬‬

‫ﺤﺩﻴﻘﺔ ﺤﻴﻭﺍﻨﺎ ﺕ‬

‫*‬

‫*‬ ‫ﻳُﻨ ﻈَ ﻒ ﻣ ﻦ ﻗﺒﻞ ‪١‬‬

‫ﻗﻔ ﺹ‬ ‫ﻳﺤﻮ ي‬

‫ِﻒ‬ ‫ﻳﻨ ﻈ‬

‫‪١‬‬

‫ﺤﺎ ﺭ ﺱ‬

‫*‬ ‫‪١‬‬

‫*‬ ‫ﻣﺤﺘﻮ ى ﻣ ﻦ ﻗﺒﻞ‬

‫ﺤﻴﻭﺍﻥ‬

‫ﻳﻄﻌﻢ‬

‫‪n‬‬ ‫ﻳُﻄﻌﻢ ﻣ ﻦ ﻗﺒﻞ‬

‫ﻟﺸﺭﺍﻜﺔ‬ ‫ﻟﺘﺭﻜﻴﺏ ﻭﺍ‬ ‫ﻟﺒﺔ ﺤﺩﻴﻘﺔ ﺤﻴﻭﺍﻨﺎﺕ ﺒﺎ‬ ‫ﻗﻭ‬ ‫‪ ،‬ﻨﻤﻭﺫﺝ‬ ‫ﺍﻜﺔ‪ .‬ﻓﻜﻤﺜﺎل ﺜﺎﻨﻲ‬ ‫‪ ،‬ﻏﺎﻟﺒﺎ ﻤﺎﻴ ﺼﻌ ﺏ ﺘ ﺤﺩﻴﺩ ﻤﺎ ﻫﻭ ﺘﺭﻜﻴ ﺏ ﻤﻡ ﻫﻭ ﺸﺭ‬ ‫ﺭ ﻏﻡ ﺫﻟ ﻙ‬ ‫ﺍﻨﺎ ﺕ‪.‬‬ ‫‪ ،‬ﻭ ﻫﺫﻩﺍﻷﺨﻴﺭﺓ ﺘﺭﻜ ﺏ ﺤﻴﻭ‬ ‫ﺍﻷﻗﻔﺎ ﺹ‬ ‫ﺍ ﺱﻭ‬ ‫ﻤﺎ ﻴ ﺤﺩﺩﺃ ﻥﺍﻟ ﺤﺩﻴﻘﺔ ﺘﺭﻜ ﺏ ‪aggregate‬ﺍﻟ ﺤﺭ‬ ‫ﺍﺍﻟﺸﻜل‪:‬‬ ‫ﻫﺫﻩﺍﻟ ﺤﺎﻟﺔ ﺘ ﺼﻤﻡ ﺒﻬﺫ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫‪Zoo‬‬ ‫‪١‬‬

‫‪١‬‬

‫‪n‬‬ ‫‪Cage‬‬ ‫‪١‬‬

‫‪n‬‬ ‫‪is cleaned by‬‬

‫‪١‬‬

‫‪Guardian‬‬

‫‪clean‬‬

‫‪0..n‬‬

‫‪feeds١‬‬

‫‪Animal‬‬ ‫‪٠‬‬

‫‪0..n‬‬ ‫‪is fed by‬‬

‫ﺤﺩﻴﻘﺔ ﺤﻴﻭﺍﻨﺎ ﺕ‬ ‫‪١‬‬

‫‪١‬‬

‫‪n‬‬

‫ﻗﻔ ﺹ‬ ‫‪١‬‬

‫‪n‬‬

‫ﹶ ﻑ ﻤ ﻥ ﻗﺒل‬ ‫ﻴ‪‬ﻨ ﻅ‬

‫‪١‬‬

‫ﻴ‪‬ﻨ ﻅِ ﻑ‬

‫‪0..n‬‬

‫ﺤﺎ ﺭ ﺱ‬ ‫‪١‬‬

‫ﺤﻴﻭﺍﻥ‬ ‫‪٠‬‬

‫ِﻢ‬ ‫ﻳُﻄﻌ‬

‫‪0..n‬‬ ‫ﻳُﻄﻌﻢ ﻣ ﻦ ﻗﺒﻞ‬

‫ﻟﺸﺭﺍﻜﺔ‬ ‫ﻟﺘﺭﻜﻴﺏ ﻭﺍ‬ ‫ﻟﺏﺁﺨﺭﻟﺤﺩﻴﻘﺔ ﺤﻴﻭﺍﻨﺎﺕ ﺒﺎ‬ ‫ﻗﺎ‬ ‫ذجاﻟﻜﺎﺋﻦ‪:‬‬ ‫‪ ٧‬ﺧﺘﺎم ﻧﻤﻮ‬ ‫ﺍﺭ‬ ‫‪ ،‬ﻭﻟﻜ ﻥﺍﻟﻤﺸﻭ‬ ‫ﺍﺴﺔ ﻤﺒﺴ ﻁﺔﻟﺠ ﺯﺀ ﻗﻠﻴل ﻤ ﻥﺍﻟﻤﻔﺎ ﻫﻴﻡﺍﻟﻤﺘﻌﻠﻘﺔ ﺒﻤﻔﻬﻭﻡﺍﻟﻜﺎﺌ ﻥ‬ ‫ﻟﻘﺩ ﺭﺃﻴﻨﺎ ﺩﺭ‬ ‫ﺍﻜﺔ ﻫﻲ‬ ‫ﺍﻟﺸﺭ‬ ‫‪،‬ﺍﻟﺘﺭﻜﻴ ﺏ ﻭ‬ ‫ﺍﺜﺔ‬ ‫ﺍﺴﻌﺔ‪ .‬ﻋﻼﻗﺎ ﺕﺍﻟﻭﺭ‬ ‫ﺍﺘﻬﺎ ﻭ‬ ‫‪ ،‬ﻷ ﻥﺍﻟﻤﻔﺎ ﻫﻴﻡ ﻜﺜﻴﺭﺓ ﻭﻤﻤﻴ ﺯ‬ ‫ﺍل ﻁﻭﻴﻼ‬ ‫ﻤﺎ ﺯ‬ ‫ﺍﻷﺴﺎﺴﻴﺔ ﻓﻲﺍﻟﻜﺎﺌﻨﺎ ﺕ‪ .‬ﻓﺒﻌ ﺽﺍﻟﻤﺒﺭﻤﺠﻴ ﻥ ﻴﺭﻯﺃﻨﻪ ﻤ ﻥ ﺨﻼل ﻫﺫﻩﺍﻟﻌﻨﺎ ﺼﺭﺍﻟﺜﻼﺜﺔ ﻴﻤﻜ ﻥ ﻓﻌل‬ ‫ﺍﺠ ﺏ‬ ‫‪ ،‬ﻭﻴﻌﻤﻠﻭ ﻥ ﺒﻬﺎ‪.‬ﺍﻟﻨﻘ ﻁﺔﺍﻷﺴﺎﺴﻴﺔﺍﻟﻭ‬ ‫ﺍﻉﺃﺨﺭﻯ ﻤ ﻥﺍﻟﻌﻼﻗﺎ ﺕ‬ ‫‪ ،‬ﺁﺨﺭﻭ ﻥ ﻴﺘﻨﺎﻭﻟﻭ ﻥﺃﻨﻭ‬ ‫ﻜل ﺸﻲﺀ‬ ‫‪ ،‬ﻭﺒ ﺤﺎﻟﺔ‬ ‫ﺍﻟﻤﺭﺘﺒ ﻁ ﺒﺘﻔﻜﻴﺭﺍﻟﻤ ﺼﻤﻡ‬ ‫ﺍ ﻜﻠﻴﺎ ﻋﻠﻰ ﻤﻔﻬﻭﻡﺍﻟﻜﺒﺴﻠﺔ ﻭ‬ ‫ﺤﻔ ﻅﻬﺎ ﻫﻲﺃ ﻥﺍﻟﻘﻭﻟﺒﺔ ﺘﻌﺘﻤﺩﺍﻋﺘﻤﺎﺩ‬ ‫ﺍﺩ ﺇﻨﺠﺎ ﺯﻩ‪.‬‬ ‫ﺍﻟﺘ ﻁﺒﻴﻕﺍﻟﻤﺭ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﺍ‬ ‫‪ ،‬ﻭﻴﻌﺩ ﺒﺫﻟ ﻙﺍﺠﺘﻬﺎﺩ‬ ‫ﺍﺍﻟﻌﻤل ﻫﻭﺍﻷﻭل ﻤ ﻥ ﻨﻭﻋﻪ ﺒﺎﻟﻨﺴﺒﺔﻟﻲ‬ ‫‪،‬ﺃﺸﻴﺭ ﺇﻟﻰﺃ ﻥ ﻫﺫ‬ ‫ﻗﺒلﺍﻟﺨﺘﺎﻡ‬ ‫ﺍ‬ ‫‪ ،‬ﻓﻼ ﻻ ﺘﺘﺭﺩﺩﻭ‬ ‫ﺸﺨ ﺼﻴﺎ‪ .‬ﻗﺩ ﻴﻨﻘ ﺼﻪﺍﻟﻜﺜﻴﺭ ﻤ ﻥﺍﻟﻤﻔﺎ ﻫﻴﻡﺃﻭﺍﻟﺘﻨ ﻅﻴﻡﺃﻭ ﺤﺘﻰ ﻁﺭﻴﻘﺔﺍﻟﺸﺭ ﺡ‬ ‫ﺍ‪.‬‬ ‫‪ ،‬ﻭﺸﻜﺭ‬ ‫ﺍ ﺤﺎﺘﻜﻡ ﻭﺇ ﻀﺎﻓﺎﺘﻜﻡ‬ ‫ﺒﺎﻗﺘﺭ‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ا ت‪:‬‬ ‫‪ ٨‬ﻗﺎﻣﻮ ساﻟﻤﻔﺮد‬ ‫ﻟﻤﺭﺍﺩ ﻑ‬ ‫ﻟﻤ ﺼﻁﻠ ﺢ ﺍ‬ ‫ﺍ‬ ‫ﻟﻌ ﺭﺒﻲ‬ ‫ﺍ‬ ‫ﺍ ﻹﻨﺠﻠﻴ ﺯ ﻱ‬

‫ﻟﺸ ﺭﺡ‬ ‫ﺍ‬

‫ﺍﻟﺒﻴﺎﻨﺎ ﺕﺍﻟﺘﻲ ﺘﻌﻤل ﻓﻲ ﺇ ﻁﺎﺭ‬ ‫ﺍل ﻭ‬ ‫ﻫﻭ ﻤﺠﻤﻭﻋﺔ ﻤ ﻥﺍﻟﺩﻭ‬ ‫ﻜﺎﺌ ﻥ‬ ‫‪Object‬‬ ‫ﻤﻭ ﺤﺩ ﻤﺸﻜﻠﺔ ﺸﻴﺌﺎ ﻤﺘﻨﺎﺴﻘﺎ‪.‬‬ ‫ﻫﻭ ﺼﻭﺭﺓ ﻤﻨﻔ ﺼﻠﺔ ﻤ ﻥﺍﻟ ﺼﻭﺭﺍﻟﺘﻲ ﺘﻡ ﺘﺸﻜﻴﻠﻬﺎ ﻤ ﻥ‬ ‫ﻤﺜﻴل‬ ‫‪Instance‬‬ ‫ﺼﻨ ﻑ ﻤﺎ‪.‬‬ ‫ﻋﻤﻠﻴﺔ ﺘﺸﻜﻴل ﻜﺎﺌ ﻥﺃﻭ ﻜﺎﺌﻨﺎ ﺕ ﻋﺩﻴﺩﺓ ﻤ ﻥ ﻨﻔ ﺱ‬ ‫ﺨﻠﻕ ﻤﺜﻴل‬ ‫‪Instanciation‬‬ ‫ﺍﻟ ﺼﻨ ﻑ‪.‬‬ ‫ﻋﻤﻠﻴﺔﺍﺸﺘﻘﺎﻕﺃ ﺼﻨﺎ ﻑ ﺠﺩﻴﺩﺓ ﻤ ﻥﺃ ﺼﻨﺎ ﻑﺃﻜﺜﺭ‬ ‫‪ ،‬ﻤﻊﺍﻟﻘﺩﺭﺓ ﻋﻠﻰ‬ ‫ﺍﺘﻬﺎ‬ ‫ﻋﻤﻭﻤﻴﺔﻟﺘ ﺤﻭ ﻱ ﺒﺫﻟ ﻙ ﻋﻠﻰ ﻤﻤﻴ ﺯ‬ ‫ﺍﺜﺔ‬ ‫ﻭﺭ‬ ‫‪Heritage‬‬ ‫ﺍ ﺕ ﺠﺩﻴﺩﺓ ﻭﻋﻼﻗﺘﻬﺎ ﻫﻲ‪:‬‬ ‫ﺇ ﻀﺎﻓﺔ ﻤﻤﻴ ﺯ‬ ‫اﻟ ﺼﻨ ﻒاﻟﻤﺸﺘﻖﻫﻮإ ﺻﺪار ﺧﺎ ص ﻣﻦاﻟ ﺼﻨ ﻒاﻟﻘﺎ ﻋﺪي‬ ‫ﺇﺨﻔﺎﺀ ﺒﻌ ﺽﺍﻟﺒﻴﺎﻨﺎ ﺕ ﻋ ﻥﺍﻟﻤﺴﺘﺨﺩﻡﻟ ﺤﻤﺎﻴﺔﺍﻟﻜﺎﺌ ﻥ ﻤ ﻥ‬ ‫‪ Encapsulation‬ﻜﺒﺴﻠﺔ‬ ‫ﺘﻌﺩﻴﻼ ﺕ ﻏﻴﺭ ﻤﺭ ﻏﻭﺒﺔ‪.‬‬ ‫ﻫﻭﺃﺴﻠﻭ ﺏ ﻴﺴﻤﺢ ﺒﺘ ﺤﺩﻴﺩ ﻤﺭﻜﺒﺎ ﺕ ﻜل ﺼﻨ ﻑ )ﺃﻭ‬ ‫ﺘﺭﻜﻴ ﺏ‬ ‫‪،‬ﺍﻟﻌﻼﻗﺔ ﺒﻴ ﻥ‬ ‫‪،‬ﺃﻭ ﺒﻤﻌﻨﻰ ﺁﺨﺭ‬ ‫ﻜﺎﺌ ﻥ( ﻭﻋﺩﺩ ﻫﺎ‬ ‫‪Aggregation‬‬ ‫‪،‬ﻟﺘﺭﻜﻴ ﺏ ﺼﻨ ﻑ ﺠﺎﻤﻊ‪.‬‬ ‫ﺍﻷ ﺼﻨﺎ ﻑ‬ ‫‪،‬‬ ‫ﻫﻭﺃﺴﻠﻭ ﺏ ﻴﺴﻤﺢﻟ ﺼﻨ ﻑ ﻤﺎ ﻤ ﻥﺃ ﻥ ﻴﺘﺨﺫ ﻋﺩﺓﺃﺸﻜﺎل‬ ‫‪ Polymorphism‬ﺘﻌﺩﺩﺍﻟ ﺼﻔﺎ ﺕ ﻭﻤﻊ ﻨﻔ ﺱﺍﻷﺴﻤﺎﺀ ﻴﻤﻜ ﻥ ﻁﻠ ﺏ ﻤﻨﺎ ﻫﺞ ﻤﺨﺘﻠﻔﺔ ﺘ ﺤﻤل‬ ‫‪ ،‬ﻭﻟﻜ ﻥ ﺘﺨﺘﻠ ﻑ ﻓﻲ ﺘﺭﻜﻴﺒﻬﺎ‪.‬‬ ‫ﻨﻔ ﺱﺍﻹﺴﻡ‬ ‫ﻫﻭ ﻗﺎﻟ ﺏ ﻴﺘﻡ ﻤ ﻥ ﺨﻼﻟﻪ ﺨﻠﻕ ﻜﺎﺌﻨﺎ ﺕ ﻤﺘﺸﺎﺒﻬﺔﺃﻭ‬ ‫ﺼﻨ ﻑ‬ ‫‪Class‬‬ ‫ﻤﺨﺘﻠﻔﺔ‪.‬‬ ‫‪ ،‬ﻭﻤ ﻥ ﺒﻴﻨﻬﺎﺍﻟﻤﺸﻴﺩ‬ ‫ﺍلﺍﻟﺘﺎﺒﻌﺔﻟﻜﺎﺌ ﻥ ﻤﺎ‬ ‫ﺍﻟﺔ ﻤ ﻥﺍﻟﺩﻭ‬ ‫ﻫﻭ ﺩ‬ ‫ﻤﻨﻬﺎﺝ‬ ‫‪Method‬‬ ‫ﺍﻟﻤﻬﺩﻡ‪.‬‬ ‫ﻭ‬ ‫ﺍﺀﺍﻟﻤ ﺤﻤﻴﺔﺃﻭ‬ ‫‪ ،‬ﺴﻭ‬ ‫ﻤﺨﺘﻠ ﻑﺍﻟﺒﻴﺎﻨﺎ ﺕﺍﻟﺘﺎﺒﻌﺔﻟﻜﺎﺌ ﻥ ﻤﺎ‬ ‫ﺨ ﺼﺎﺌ ﺹ‬ ‫‪Attributes‬‬ ‫ﺍﻟﻌﺎﻤﺔﺃﻭﺍﻟﺨﺎ ﺼﺔ‪.‬‬ ‫ﺍﻟﺒﻴﺎﻨﺎ ﺕ‬ ‫ﻫﻭﺍﻟﻤﻨﻬﺎﺝﺍﻟﺫ ﻱ ﻴﻘﻭﻡ ﺒﺘﻬﻴﺌﺔﺍﻟﺨ ﺼﺎﺌ ﺹ ﻭ‬ ‫‪‬ﺩ‬ ‫ﻤﺸﻴ‬ ‫‪Constructor‬‬ ‫ﺍﻟﺘﺎﺒﻌﺔﻟﻠﻜﺎﺌ ﻥ ﻋﻨﺩﺃﻭل ﻋﻤﻠﻴﺔﻟﺨﻠﻕﺍﻟﻜﺎﺌ ﻥ‪.‬‬ ‫‪،‬‬ ‫ﻫﻭﺍﻟﻤﻨﻬﺎﺝﺍﻟﺫ ﻱ ﻴﻘﻭﻡ ﺒﺘ ﺤ ﻁﻴﻡﺍﻟﻜﺎﺌ ﻥﺒﻌﺩ ﻨﻬﺎﻴﺔﺍﻟﻌﻤل‬ ‫‪‬ﻡ‬ ‫ﻤﻬ ﺩ‬ ‫‪Destructor‬‬ ‫ﺍﻜﺭﺓﺍﻟﻤ ﺤﺠﻭﺯﺓ‪.‬‬ ‫ﻟﺘ ﺤﺭﻴﺭﺍﻟﺫ‬ ‫‪،‬‬ ‫ﺍلﺃ ﻥ ﺘﻜﻭ ﻥﻟﻬﺎﺃﺴﻤﺎﺀ ﻤﺘﺸﺎﺒﻬﺔ‬ ‫ﻴﺴﻤﺢﻟﻠﻤﻨﺎ ﻫﺞﺃﻭﺍﻟﺩﻭ‬ ‫ﺍﺌﺩ‬ ‫ﺍﻟﺘ ﺤﻤﻴلﺍﻟ ﺯ‬ ‫‪Overload‬‬ ‫ﺍ ﺕ ﻤﺨﺘﻠﻔﺔ‪.‬‬ ‫ﺍﻤﺘﺭ‬ ‫ﻭﻟﻜ ﻥ ﺒﺒﺎﺭ‬ ‫‪،‬‬ ‫‪ ،‬ﻤ ﺤﻤﻲ‬ ‫‪ ،‬ﺨﺎ ﺹ‬ ‫ﺘﻤﺜل ﻤﺨﺘﻠ ﻑﺃﻗﺴﺎﻡﺍﻟ ﺼﻨ ﻑ )ﻋﺎﻡ‬ ‫ﺍﺠﻬﺔ‬ ‫ﺍﻟﻭ‬ ‫‪Interface‬‬ ‫ﺍ ﻀﻲ‪(...‬ﺃﻭ ﺒﻤﻔﻬﻭﻡ ﺁﺨﺭ ﻗﺎﺌﻤﺔ ﻤﻨﺎ ﻫﺞﺍﻟ ﺼﻨ ﻑ‪.‬‬ ‫ﺍﻓﺘﺭ‬ ‫ﺍﺀ ﺘ ﺼﻨﻴ ﻑﻟﻠﻜﺎﺌﻨﺎ ﺕﺍﻟﻤﺘﺸﺎﺒﻬﺔ )ﻓﻲﺃ ﻱ ﺼﻔﺔ(‬ ‫ﺇﺠﺭ‬ ‫ﻗﻭﻟﺒﺔ‬ ‫‪Modeling‬‬ ‫ﺍﻟ ﺏ ﺠﺎﻤﻌﺔ ﻭﻤﺘﺴﻠﺴﻠﺔ‪.‬‬ ‫ﻻﺴﺘﺨﻼ ﺹ ﻋﺩﺓ ﻗﻭ‬ ‫ﻫﻭﺍﻟ ﺼﻨ ﻑﺍﻟﺫ ﻱ ﻻ ﻴﻤﺘﻠ ﻙ ﻤﺸﺘﻘﺎ ﺕ‬ ‫ﻭﺭﻗﺔ‬ ‫‪Page‬‬ ‫ﻋﻼﻗﺔ ﺘﺭﺒ ﻁ ﺒﻴ ﻥﺍﻷ ﺼﻨﺎ ﻑ ﻭﻻ ﺘﻜﻭ ﻥ ﻤ ﺤﺩﺩﺓ ﻜﺎﻟﺘﺭﻜﻴ ﺏ‬ ‫ﺍﻜﺔ‬ ‫‪ Association‬ﺍﻟﺸﺭ‬ ‫‪aggregation.‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

‫ﻟﻜﺎﺌﻨﺎ‬ ‫ﻟ ﻰﺍ‬ ‫ﻤﺩﺨ ل ﺇ‬

‫ﺕ‪2 ......................................................................................................‬‬

‫ﻟﻜﺎﺌﻥ‪2 ............................................................................................................ :‬‬ ‫‪ 1‬ﻤﻔﻬﻭﻡﺍ‬ ‫ﻟﻜﺒﺴﻠﺔ‪5 ........................................................................ : ENCAPSULATION‬‬ ‫‪ 2‬ﻤﻔﻬﻭﻡﺍ‬ ‫ﻟﻭﺭﺍﺜﺔ‪6 .............................................................................................. HERITAGE:‬‬ ‫‪3‬ﺍ‬ ‫ﻟﺒﻴﺎﻨﻴﺔ ‪7 .................................................. GRAPHIC OBJECTS‬‬ ‫ﻟﻜﺎﺌﻨﺎ ﺕﺍ‬ ‫ﻟﻤﺜﺎ لﺍﻷﻭ ل‪:‬ﺍ‬ ‫‪3. 1.‬ﺍ‬ ‫ﻟﺒﺔ ﺤﻅﻴ ﺭﺓﻟﻠﻌ ﺭﺒﺎ ﺕ‪11 .......................................................................‬‬ ‫ﻟﺜﺎﻨﻲ‪ :‬ﻗﻭ‬ ‫ﻟﻤﺜﺎ لﺍ‬ ‫‪3. 2.‬ﺍ‬ ‫ﻟﻤﺠ ﺭﺩﺓ‪13 ............................................................................ABSTRACT :‬‬ ‫‪3. 3.‬ﺍﻷ ﺼﻨﺎ ﻑﺍ‬ ‫ﻟﻭﺭﺍﺜﺔ‪14 ................................................................... :‬‬ ‫ﻟﻤ ﺭﺘﺒﻁﺔ ﺒﺎﺴﺘﺨﺩﺍﻡﺍ‬ ‫ﻟ ﺼﻌﻭﺒﺎ ﺕﺍ‬ ‫‪3. 4.‬ﺍ‬ ‫ﻠ ﺴﻞ ﻣﻜﺜ ﻒ ﺟﺪا‪14 .......................................................................................:‬‬ ‫‪3. 4. 01.‬ﺗ ﺴ‬ ‫‪3. 4. 02.‬وراﺛ ﺔ اﻟﺘﺸﻴﻴﺪ‪15 .............................................. CONSTRUCTION INHERITANCE :‬‬ ‫ﺎﺳﻘ ﺔ‪15 ............................ THE CONCEPTUAL INCOHERENCE :‬‬ ‫‪3. 4. 03.‬اﻟﺘ ﺼﻮرا ت اﻟﻐﻴﺮ ﻣﺘﻨ‬ ‫ﻟﻤﺘﻌﺩﺩﺓ ‪16 ............................................... THE MULTIPLE INHERITANCE:‬‬ ‫ﻟﻭﺭﺍﺜﺔﺍ‬ ‫‪3. 5.‬ﺍ‬ ‫ﻟﻭﺍﺠﻬﺎ ﺕ‪17 ............................................................................. THE INTERFACES :‬‬ ‫‪3. 6.‬ﺍ‬ ‫ﻟﺘ ﺭﻜﻴﺏ ‪17 .................................................................................. AGGREGATION:‬‬ ‫‪4‬ﺍ‬ ‫‪4. 1.‬ﺘﻌ ﺭﻴ ﻑ‪17 ............................................................................................................ :‬‬ ‫ﻟﻭﺍﺠﻬﺎ ﺕ‪18 ........................................................:‬‬ ‫ﻟﻤﺘﻌﺩﺩﺓﺃﻭﺍ‬ ‫ﻟﺘ ﺭﻜﻴﺏ ﻜﺘﻨﺎﻭﺏﻟﻠﻭﺭﺍﺜﺔﺍ‬ ‫‪4. 2.‬ﺍ‬ ‫ﻟ ﺼﻔﺎ ﺕ ‪21 ..................................................................... POLYMORPHISME :‬‬ ‫‪5‬ﺘﻌﺩﺩﺍ‬ ‫‪5. 1.‬ﺘﻌ ﺭﻴ ﻑ‪21 ............................................................................................................ :‬‬ ‫ﻟ ﺼﻔﺎ ﺕ‪21 .............................................................................................. :‬‬ ‫‪5. 2.‬ﻗﻭﺓﺘﻌﺩﺩﺍ‬ ‫ﻟﺯﺍﺌﺩ ‪22 ........................................OVERLOADING‬‬ ‫ﻟﺘﺤﻤﻴ لﺍ‬ ‫ﻟ ﺼﻔﺎ ﺕ‪:‬ﺍ‬ ‫‪ 5. 3.‬ﺸﻜ ل ﻨﺎﺠﻊﻟﺘﻌﺩﺩﺍ‬ ‫‪ 6‬ﻋﻼﻗﺔاﻟﺸﺮاﻛﺔ ‪22 .......................................THE RELATION OF ASSOCIATION :‬‬ ‫ﻜﺎﺋﻦ‪25 ................................................................................................... :‬‬ ‫‪7‬ﺧﺘﺎمﻧﻤﻮذجاﻟ‬ ‫‪8‬ﻗﺎﻣﻮ ساﻟﻤﻔﺮدات‪27 ..................................................................................................... :‬‬

‫‪PDF created with FinePrint pdfFactory Pro trial version http://www.fineprint.com‬‬

Related Documents

Oop
November 2019 35
Oop Exercise
June 2020 16
Introduction Oop
November 2019 33
Oop Programs
June 2020 5
Upgrading Oop
June 2020 8
Oop Inheritance
May 2020 13