Ô´ÂëÍø,Ô´ÂëÂÛ̳,Ô´ÂëÖ®¼Ò,ÉÌÒµÔ´Âë,ÓÎÏ·Ô´ÂëÏÂÔØ,discuz²å¼þ,ÆåÅÆÔ´ÂëÏÂÔØ,¾«Æ·Ô´ÂëÂÛ̳

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á
²é¿´: 434|»Ø¸´: 28

[PHP±à³Ì] PHP ÔÓ̸¡¶Öع¹-¸ÄÉƼÈÓдúÂëµÄÉè¼Æ¡·Ö®Èý ÖØÐÂ×éÖ¯Êý¾Ý

[¸´ÖÆÁ´½Ó]

7Íò

Ö÷Ìâ

861

»ØÌû

32Íò

»ý·Ö

ÂÛ̳ԪÀÏ

Rank: 8Rank: 8

»ý·Ö
329525
·¢±íÓÚ 2012-4-9 22:25:46 | ÏÔʾȫ²¿Â¥²ã |ÔĶÁģʽ
³Ð½ÓÉÏÎĵÄPHP ÔÓ̸¡¶Öع¹-¸ÄÉƼÈÓдúÂëµÄÉè¼Æ¡·Ö® ÖØÐÂ×éÖ¯ÄãµÄº¯Êý¼ÌÐøÖع¹·½ÃæµÄÄÚÈÝ Ë¼Î¬µ¼Í¼


½éÉÜ

   ³Ð½ÓÉÏÎĵÄPHP ÔÓ̸¡¶Öع¹-¸ÄÉƼÈÓдúÂëµÄÉè¼Æ¡·Ö® ÖØÐÂ×éÖ¯ÄãµÄº¯Êý¼ÌÐøÖع¹·½ÃæµÄÄÚÈÝ¡£   ÕâÕÂÖ÷ÒªÕë¶ÔÊý¾ÝµÄÖع¹¡£   1¡¢ÕùÂÛµÄÉùÒô¡ª¡ªÖ±½Ó·ÃÎÊField»¹ÊÇͨ¹ýº¯Êý£¨Accessor£©·ÃÎÊField

 2.ÐÞ¸ÄArrayΪObject£ºµ±Äã¿´µ½Ò»¸öArrayºÜÏñÒ»¸öÊý¾Ý½á¹¹£¬Äã¿ÉÒÔʹÓÃReplace Array with Object£¬°ÑArray±ä³ÉÒ»¸ö¶ÔÏ󡣡ª¡ªÊý¾Ý½á¹¹¸üÇåÎú¡£

     ×¨ÒµÊõÓï  

accessor£º·ÃÎÊÕߣ¬´æ´¢Æ÷¡ª¡ªÔÚ±¾ÎÄ·­ÒëΪ¡°º¯Êý¡±

dumb:ÑÆ

domain class£ºÓÃÒÔ´¦ÀíÒµÎñÂß¼­

presentation class:ÓÃÒÔ´¦Àí¡±Êý¾Ý±íÏÖÐÎʽ¡°

business logic£ºÒµÎñÂß¼­

unidirectional£ºµ¥ÏòµÄ

bidirectional£ºË«ÏòµÄ

collection£ºÈº¼¯

 Self Encapsulate Field   ×´¿ö£ºÈç¹ûClientÖ±½Ó·ÃÎÊÖµÓò£¬»áÔì³ÉClientÓëÖµÓòÖ®¼äµÄñîºÏ¹ØϵÖð½¥±äµÃ±¿×¾£¬ÄÇôΪÕâ¸öÖµÓò½¨Á¢È¡Öµ/ÉèÖú¯Êý£¬²¢ÇÒÖ»ÒÔÕâЩº¯ÊýÀ´·ÃÎÊ¡£  

 

¶¯»ú£º

¡¡¡¡¡°¼ä½Ó·ÃÎʱäÁ¿¡±£ºÖ§³Ö¸üÁé»îµÄÊý¾Ý»ñÈ¡·½Ê½£¬Èçlazy Initialization£¨Òâ˼ÊÇÖ»ÓÐÓõ½ÖµÊ±£¬²Å¶ÔËü½øÐгõʼ»¯¡££©

¡¡¡¡¡°Ö±½Ó·ÃÎʱäÁ¿¡±£º´úÂë±È½ÏÈÝÒ×ÔĶÁ£¬²»ÐèҪͣÏÂÀ´Ëµ£º¡°°¡£¬ÕâÖ»ÊǸöÈ¡Öµº¯Êý¡±¡£

       Ñ¡Ôñ£º1¡¢´úÂë¹æ·¶£¬°´ÕÕÍŶÓÖдó¶àÊýÈ˵Ä×ö·¨È¥×ö¡£

¡¡¡¡¡¡¡¡¡¡2¡¢¸öÈ˱ȽÏϲ»¶¡°Ö±½Ó·ÃÎʱäÁ¿¡±£¬Ö±µ½ÕâÖÖ·½Ê½´øÀ´Â鷳Ϊֹ¡£

¡¡¡¡¡¡¡¡¡¡¡¡¡¡martin(×÷Õß)µÄÀý×Ó£ºÄãÏë»ñÈ¡superclassÖеÄfield£¬È´ÓÖÏëÔÚsubclassÖн«¸Ãfield¸ÄΪ¼ÆËãºóµÄÖµ£¬Õâ¾Í×î¸ÃʹÓÃSelf Encapsulate Field¡£

                         ÎÒ×Ô¼ºµÄÀý×Ó£ºÎÒÒ»°ã»á°ÑfieldÉèÖóÉprivate£¬Èç¹ûÍⲿ±äÁ¿£¬ÐèÒªÓõ½´ËfieldµÄʱºò£¬ÎҾͻáÓÃSelf Encapsulate Field¡£»òÕßfieldµÄÖµÓб仯µÄʱºò£¬ÓÃSelf Encapsulate Field¡£


 Replace Data Value with Object    ×´¿ö£ºÈç¹ûÄãµÄij¸ö»ù±¾ÀàÐ͵Äfield£¬ÐèÒª¶îÍâµÄÊý¾ÝºÍÐÐΪ£¬ÄÇô½«´Ëfield±ä³É¶ÔÏó¡£  

 

    ¶¯»ú£º  

¿ª·¢³õÆÚ£¬ÎÒÃÇÒ²Ðí»áʹÓûù±¾Êý¾ÝÀàÐͱíʾ¼òµ¥µÄÐÐΪ¡£ÀýÈ磺Äã¿ÉÄÜ»áÓÃÒ»¸ö×Ö·û´®±íʾµç»°ºÅÂ룬µ«ÊÇËæºó¿ÉÄÜ»á³öÏֵ绰ºÅÂëµÄ¡°¸ñʽ»¯¡°£¬¡±ÑéÖ¤¡°£¬¡±³éÈ¡ÇøºÅ¡°Ö®ÀàµÄÌØÊâÐÐΪ¡£¡ª¡ªÕâʱºòÎÒÃǾÍÐèÒªÒ»¸öÐÂÀà¡£

   Replace Array with Object   ×´¿ö£ºÄãÓÐÒ»¸öÊý×飬Êý×éÖеÄÔªËظ÷×Ô´ú±í²»Í¬µÄ¶«Î÷£¬ÄÇôÒÔ¶ÔÏóÌæ»»Êý×飬¶ÔÓÚÊý×éÖеÄÿ¸öÔªËØ£¬ÒÔÒ»¸öÖµÓò±íʾ֮¡£  

 ¶¯»ú£º

Êý×é³£ÓÃÓÚÒ»×éÏàËƶÔÏó¡£Èç¹ûÊý×éÖеÄÔªËز»Í¬£¬ºÜÄÑÃ÷°×Êý×éÖеĵÚÒ»¸öÔªËØÊÇÈËÃûÕâÑùµÄÔ¼¶¨¡£¶ÔÏó¾Í²»Í¬ÁË£¬¿ÉÒÔͨ¹ýÖµÓòÃû³ÆºÍº¯ÊýÃû³Æ´«´ïÕâÑùµÄÐÅÏ¢¡£¡ª¡ªÕâÑùÎÞÐëËÀ¼Ç£¬ÎÞÐë×¢ÊÍ¡£

 Encapsulate Field   ×´¿ö£ºÈç¹ûÄãµÄclassÖÐÓÐÒ»¸öpublicÖµÓò£¬ÄÇô½«ËüÉùÃ÷Ϊpirvate£¬²¢ÌṩÏàÓ¦µÄ·ÃÎʺ¯Êý¡£

 ¶¯»ú£º

ÃæÏò¶ÔÏóµÄÔ­ÔòÖ®Ò»¾ÍÊÇ·â×°£¨Encapsulate£©»òÕß³ÆΪ¡±Êý¾ÝÒþ²Ø¡°¡£°´ÕÕ´ËÔ­²â£¬Äã¾ø²»Ó¦¸Ã°ÑÊý¾ÝÉùÃ÷Ϊpublic¡£ ¡¡¡¡¡ª¡ªpublic Êý¾Ý±»¿´³ÉÊÇÒ»ÖÖ²»ºÃµÄ×ö·¨¡£ ¡¡¡¡¡ª¡ªÈç¹û·â×°ÁË£¬´úÂëµÄÐ޸ľͻá±È½Ï¼òµ¥£¬ÒòΪ¶¼¼¯ÖÐÔÚÒ»¸öµØ·½¡£  Ò»¸öº¯Êý³ýÁË·ÃÎʺ¯Êý(getting/setting)Í⣬²»ÌṩÆäËûÐÐΪ£¬ËüÖÕ¾¿Ö»ÊÇÒ»¸ödumb class£¨ÑÆÀࣩ¡£ÕâÀàclass²»ÄÜ»ñµÃ¶ÔÏó¼¼ÊõµÄÓÅÊÆ¡£¡ª¡ª½â¾öÑÆÀàµÄ·½·¨ÊÇMove MethodÇá¿ìµÄ½«ËüÃÇÒƵ½Ð¶ÔÏóÈ¥¡£    conclusion   ÎÒÏ£ÍûÄÜ°ÑÎÒÀí½âµÄ¶«Î÷Óë´ó¼Ò·ÖÏí£¬»¶Ó­´ó¼ÒÌá³ö±¦¹óÒâ¼û¡£
»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

0

Ö÷Ìâ

1Íò

»ØÌû

0

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
0
·¢±íÓÚ 2022-9-10 02:08:18 | ÏÔʾȫ²¿Â¥²ã
»¹²»´í°¡

0

Ö÷Ìâ

2Íò

»ØÌû

0

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
0
·¢±íÓÚ 2022-10-28 03:51:58 | ÏÔʾȫ²¿Â¥²ã
¹à¹à¹à¹àË®

0

Ö÷Ìâ

2Íò

»ØÌû

115

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
115
·¢±íÓÚ 2022-12-1 01:55:35 | ÏÔʾȫ²¿Â¥²ã
¸ã¸öÃâ·ÑµÄÓÃÓÃ

14

Ö÷Ìâ

1Íò

»ØÌû

75

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
75
·¢±íÓÚ 2023-6-30 17:22:57 | ÏÔʾȫ²¿Â¥²ã
À²À²À²À²À²µÂÂêÎ÷ÑÇ

0

Ö÷Ìâ

1Íò

»ØÌû

0

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
0
·¢±íÓÚ 2023-8-30 00:08:54 | ÏÔʾȫ²¿Â¥²ã
¿ì¸üа¡£¬ÎÒ²Á

0

Ö÷Ìâ

2Íò

»ØÌû

0

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
0
·¢±íÓÚ 2023-9-2 22:31:51 | ÏÔʾȫ²¿Â¥²ã
554411515451555

0

Ö÷Ìâ

1Íò

»ØÌû

0

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
0
·¢±íÓÚ 2023-10-24 05:52:46 | ÏÔʾȫ²¿Â¥²ã
ÂÛ̳ÓÐÄã¸ü¾«²Ê£¡

1

Ö÷Ìâ

2Íò

»ØÌû

362

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
362
·¢±íÓÚ 2023-11-20 07:11:07 | ÏÔʾȫ²¿Â¥²ã
È˶¼²»ÔÚÁË°¡ °¡

0

Ö÷Ìâ

1Íò

»ØÌû

0

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
0
·¢±íÓÚ 2023-12-11 05:44:08 | ÏÔʾȫ²¿Â¥²ã
ÄãÃÇË­¿´ÁËŪÈ÷ÁË¿ÉÄÜ
¸ß¼¶Ä£Ê½
B Color Image Link Quote Code Smilies

±¾°æ»ý·Ö¹æÔò

ÊÖ»ú°æ|СºÚÎÝ|ÍøÕ¾µØͼ|Ô´ÂëÂÛ̳ ( º£Íâ°æ )

GMT+8, 2024-11-23 03:16 , Processed in 0.075871 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí