{"id":5941,"date":"2022-02-14T08:45:13","date_gmt":"2022-02-14T08:45:13","guid":{"rendered":"https:\/\/www.cybermedian.com\/cn\/?p=5941"},"modified":"2025-03-07T01:28:53","modified_gmt":"2025-03-07T01:28:53","slug":"%e4%bb%80%e4%b9%88%e6%98%af%e5%bc%80%e9%97%ad%e5%8e%9f%e5%88%99%ef%bc%88ocp%ef%bc%89%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/","title":{"rendered":"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f"},"content":{"rendered":"<section class=\"section section--body section--first\">\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<p id=\"05f0\" class=\"graf graf--p graf-after--h3\"><a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/en.wikipedia.org\/wiki\/Open%E2%80%93closed_principle#:~:text=In%20object%2Doriented%20programming%2C%20the,without%20modifying%20its%20source%20code.\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/en.wikipedia.org\/wiki\/Open%E2%80%93closed_principle#:~:text=In%20object%2Doriented%20programming%2C%20the,without%20modifying%20its%20source%20code.\">\u5f00\u653e\/\u5c01\u95ed\u539f\u5219<\/a>\u00a0\u662f\u8f6f\u4ef6\u5f00\u53d1\u4e16\u754c\u4e2d\u6700\u57fa\u672c\u7684\u8bbe\u8ba1\u539f\u5219\u3002\u00a0\u5b83\u6307\u5bfc\u6211\u4eec\u5982\u4f55\u6784\u5efa\u4e00\u4e2a\u7a33\u5b9a\u800c\u7075\u6d3b\u7684\u7cfb\u7edf\u3002<\/p>\n<h4 id=\"ef13\" class=\"graf graf--h4 graf-after--p\"><span id=\"Definition\"><strong class=\"markup--strong markup--h4-strong\">\u5b9a\u4e49\uff1a<\/strong><\/span><\/h4>\n<blockquote id=\"bc88\" class=\"graf graf--blockquote graf-after--h4\"><p>\u7c7b\u3001\u6a21\u5757\u548c\u51fd\u6570\u7b49\u8f6f\u4ef6\u5b9e\u4f53\u5e94\u8be5\u5bf9\u6269\u5c55\u5f00\u653e\uff0c\u5bf9\u4fee\u6539\u5173\u95ed\u3002<\/p><\/blockquote>\n<p id=\"8516\" class=\"graf graf--p graf-after--blockquote\">\u5f00\u95ed\u539f\u5219\u7684\u542b\u4e49\u662f\u5e94\u8be5\u6269\u5c55\u4e00\u4e2a\u8f6f\u4ef6\u5b9e\u4f53\u6765\u5b9e\u73b0\u6539\u53d8\uff0c\u800c\u4e0d\u662f\u901a\u8fc7\u4fee\u6539\u73b0\u6709\u4ee3\u7801\u6765\u5b9e\u73b0\u6539\u53d8\u3002<\/p>\n<p id=\"aad3\" class=\"graf graf--p graf-after--p\">\u5f00\u95ed\u539f\u5219\u662f\u9650\u5236\u8f6f\u4ef6\u5b9e\u4f53\u672a\u6765\u4e8b\u7269\u5f53\u524d\u5f00\u53d1\u548c\u8bbe\u8ba1\u7684\u539f\u5219\u3002<\/p>\n<p id=\"3cf8\" class=\"graf graf--p graf-after--p\">\u6ce8\uff1a\u5f00\u95ed\u539f\u5219\u662f\u5bf9\u6269\u5c55\u5f00\u653e\uff0c\u5bf9\u4fee\u6539\u5173\u95ed\u3002\u8fd9\u5e76\u4e0d\u610f\u5473\u7740\u4e0d\u4f1a\u8fdb\u884c\u4efb\u4f55\u4fee\u6539\u3002\u4f4e\u7ea7\u6a21\u5757\u7684\u53d8\u5316\u5fc5\u987b\u4e0e\u9ad8\u7ea7\u6a21\u5757\u8026\u5408\uff0c\u5426\u5219\u5c06\u662f\u4e00\u4e2a\u5b64\u7acb\u7684\u3001\u65e0\u610f\u4e49\u7684\u4ee3\u7801\u7247\u6bb5\u3002<\/p>\n<p id=\"adad\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">\u5f00\u95ed\u539f\u5219\u7684\u91cd\u8981\u6027\uff1a<\/strong><\/p>\n<ul class=\"postList\">\n<li id=\"4231\" class=\"graf graf--li graf-after--p\">\u5f00\u95ed\u539f\u5219\u5bf9\u6d4b\u8bd5\u7684\u5f71\u54cd<\/li>\n<\/ul>\n<p id=\"dd2a\" class=\"graf graf--p graf-after--li\">\u5f00\u542f\u548c\u5173\u95ed\u7684\u539f\u5219\u662f\u4fdd\u6301\u539f\u59cb\u6d4b\u8bd5\u4ee3\u7801\u4ecd\u7136\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6d4b\u8bd5\u6269\u5c55\u4ee3\u7801\u3002<\/p>\n<ul class=\"postList\">\n<li id=\"e807\" class=\"graf graf--li graf-after--p\">\u5f00\u95ed\u539f\u7406\u53ef\u4ee5\u63d0\u9ad8\u590d\u7528\u6027<\/li>\n<\/ul>\n<p id=\"1236\" class=\"graf graf--p graf-after--li\">\u5728\u00a0<a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/www.techopedia.com\/definition\/21105\/object-oriented-design-ood#:~:text=Object%2Doriented%20design%20%28OOD%29%20is%20the%20process%20of%20using,%28OOP%29%20process%20or%20lifecycle.\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/www.techopedia.com\/definition\/21105\/object-oriented-design-ood#:~:text=Object%2Doriented%20design%20(OOD)%20is%20the%20process%20of%20using,(OOP)%20process%20or%20lifecycle.\">\u9762\u5411\u5bf9\u8c61\u8bbe\u8ba1<\/a>\u4e2d\uff0c\u6240\u6709\u903b\u8f91\u90fd\u662f\u7531\u539f\u5b50\u903b\u8f91\u7ec4\u5408\u800c\u6210\uff0c\u800c\u4e0d\u662f\u5728\u4e00\u4e2a\u7c7b\u4e2d\u72ec\u7acb\u5b9e\u73b0\u4e00\u4e2a\u4e1a\u52a1\u903b\u8f91\u3002\u53ea\u6709\u8fd9\u6837\uff0c\u4ee3\u7801\u624d\u80fd\u88ab\u91cd\u7528\u3002\u7c92\u5ea6\u8d8a\u5c0f\uff0c\u88ab\u590d\u7528\u7684\u53ef\u80fd\u6027\u5c31\u8d8a\u5927\u3002<\/p>\n<ul class=\"postList\">\n<li id=\"4999\" class=\"graf graf--li graf-after--p\">\u5f00\u95ed\u539f\u5219\u53ef\u4ee5\u63d0\u9ad8\u53ef\u7ef4\u62a4\u6027<\/li>\n<li id=\"0c21\" class=\"graf graf--li graf-after--li\">\u9762\u5411\u5bf9\u8c61\u7684\u5f00\u53d1\u9700\u6c42<\/li>\n<\/ul>\n<p id=\"6c46\" class=\"graf graf--p graf-after--li\"><strong class=\"markup--strong markup--p-strong\">\u5982\u4f55\u4f7f\u7528\u5f00\u5408\u539f\u7406\uff1a<\/strong><\/p>\n<p id=\"3568\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">\u4e00<\/strong>\u3001\u901a\u8fc7\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b\u9650\u5236\u6269\u5c55\uff0c\u9650\u5236\u8fb9\u754c\u7684\u6269\u5c55\uff0c\u4e0d\u5141\u8bb8\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b\u4e2d\u4e0d\u5b58\u5728\u7684\u516c\u5171\u65b9\u6cd5\uff1b<\/p>\n<p id=\"8d58\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">\u5176\u6b21<\/strong>\uff0c\u5c3d\u91cf\u4f7f\u7528\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b\u4f5c\u4e3a\u53c2\u6570\u7c7b\u578b\u548c\u5f15\u7528\u5bf9\u8c61\uff0c\u800c\u4e0d\u662f\u5b9e\u73b0\u7c7b\uff1b<\/p>\n<p id=\"c031\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">\u7b2c\u4e09<\/strong>\uff0c\u62bd\u8c61\u5c42\u8981\u5c3d\u91cf\u4fdd\u6301\u7a33\u5b9a\uff0c\u4e00\u65e6\u786e\u5b9a\uff0c\u5c31\u4e0d\u5141\u8bb8\u4fee\u6539\u3002<\/p>\n<p id=\"22c7\" class=\"graf graf--p graf-after--p\">\u53d8\u5316\u7684\u5c01\u88c5\u6709\u4e24\u5c42\u542b\u4e49\uff1a<\/p>\n<p id=\"cda0\" class=\"graf graf--p graf-after--p\">\u9996\u5148\uff0c\u5c06\u76f8\u540c\u7684\u66f4\u6539\u5c01\u88c5\u5230\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b\u4e2d\uff1b<\/p>\n<p id=\"8a51\" class=\"graf graf--p graf-after--p graf--trailing\">\u5176\u6b21\uff0c\u5c06\u4e0d\u540c\u7684\u53d8\u5316\u5c01\u88c5\u5230\u4e0d\u540c\u7684\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b\u4e2d\u3002\u4e24\u4e2a\u4e0d\u540c\u7684\u53d8\u5316\u4e0d\u5e94\u8be5\u51fa\u73b0\u5728\u540c\u4e00\u4e2a\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b\u4e2d\u3002<\/p>\n<\/div>\n<\/div>\n<\/section>\n<section class=\"section section--body section--last\">\n<div class=\"section-divider\">\n<hr class=\"section-divider\" \/>\n<\/div>\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<h4 id=\"69e6\" class=\"graf graf--h4 graf--leading\"><span id=\"Examples\">\u4f8b\u5b50<\/span><\/h4>\n<p id=\"56bf\" class=\"graf graf--p graf-after--h4\">\u4f8b\u5982\uff0c\u624b\u52a8\u6253\u5f00\u548c\u5173\u95ed\u95e8\u3002<\/p>\n<figure id=\"d3f2\" class=\"graf graf--figure graf-after--p\"><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/0wlXaJtn3Bexx9ev7.png\" data-image-id=\"0*wlXaJtn3Bexx9ev7.png\" data-width=\"453\" data-height=\"148\" \/><\/figure>\n<p id=\"c2c2\" class=\"graf graf--p graf-after--figure\">\u5982\u679c\u6709\u65b0\u7684\u9700\u6c42\uff0c\u5c31\u9700\u8981\u589e\u52a0\u624b\u52a8\u5f00\u5408\u62bd\u5c49\u7684\u529f\u80fd\u3002\u4ee3\u7801\u9700\u8981\u6dfb\u52a0\u4e00\u4e2aDrawer\u7c7b\uff0c\u540c\u65f6\u4fee\u6539Hand\u7c7b\u3002<\/p>\n<figure id=\"1d14\" class=\"graf graf--figure graf-after--p\"><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/1QXaFJLucsecnatWUuuuH6Q.png\" data-image-id=\"1*QXaFJLucsecnatWUuuuH6Q.png\" data-width=\"781\" data-height=\"500\" data-is-featured=\"true\" \/><\/figure>\n<p id=\"ce83\" class=\"graf graf--p graf-after--figure\">\u4ee5OCP\u5f00\u95ed\u539f\u7406\u4e3a\u4f8b\uff0c\u624b\u52a8\u5f00\u95ed\u95e8\u4f9d\u8d56\u4e8e\u4e00\u4e2a\u63a5\u53e3\uff0c\u5177\u4f53\u5b9e\u73b0\u7c7b\u5b9e\u73b0\u8be5\u63a5\u53e3\u3002<\/p>\n<figure id=\"28a1\" class=\"graf graf--figure graf-after--p\"><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/1NVWYY0ZYvgMJbnENhw1QKw.png\" data-image-id=\"1*NVWYY0ZYvgMJbnENhw1QKw.png\" data-width=\"800\" data-height=\"461\" \/><\/figure>\n<p id=\"2372\" class=\"graf graf--p graf-after--figure\">\u5f53\u9700\u8981\u589e\u52a0\u6253\u5f00\u548c\u5173\u95ed\u51b0\u7bb1\u7684\u624b\u6570\u65f6\uff0c\u51b0\u7bb1\u7c7b\u5728\u4e0d\u4fee\u6539\u539f\u6709\u7684Hand\u7c7b\u548c\u63a5\u53e3\u7684\u60c5\u51b5\u4e0b\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3\u3002<\/p>\n<figure id=\"6688\" class=\"graf graf--figure graf-after--p\"><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/1iR6WQOaVLjFUMy1056vL-w.png\" data-image-id=\"1*iR6WQOaVLjFUMy1056vL-w.png\" data-width=\"946\" data-height=\"464\" \/><\/figure>\n<h4 id=\"246b\" class=\"graf graf--h4 graf-after--figure\"><span id=\"More_Object_Oriented_Resources\">\u66f4\u591a\u9762\u5411\u5bf9\u8c61\u7684\u8d44\u6e90<\/span><\/h4>\n<ul class=\"postList\">\n<li id=\"3002\" class=\"graf graf--li graf-after--h4\"><a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/reflectoring.io\/open-closed-principle-explained\/\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/reflectoring.io\/open-closed-principle-explained\/\">\u5f00\u95ed\u539f\u5219\u89e3\u91ca<\/a><\/li>\n<li id=\"be77\" class=\"graf graf--li graf-after--li\"><a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/www.visual-paradigm.com\/guide\/uml-unified-modeling-language\/uml-class-diagram-tutorial\/\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/www.visual-paradigm.com\/guide\/uml-unified-modeling-language\/uml-class-diagram-tutorial\/\">UML \u7c7b\u56fe\u6559\u7a0b<\/a><\/li>\n<li id=\"d80e\" class=\"graf graf--li graf-after--li\"><a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/www.visual-paradigm.com\/guide\/uml-unified-modeling-language\/what-is-class-diagram\/\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/www.visual-paradigm.com\/guide\/uml-unified-modeling-language\/what-is-class-diagram\/\">\u4ec0\u4e48\u662f\u7c7b\u56fe\uff1f<\/a><\/li>\n<li id=\"f4cf\" class=\"graf graf--li graf-after--li\"><a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/online.visual-paradigm.com\/diagrams\/solutions\/free-class-diagram-tool\/\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/online.visual-paradigm.com\/diagrams\/solutions\/free-class-diagram-tool\/\">\u514d\u8d39\u7684\u7c7b\u56fe\u5de5\u5177<\/a><\/li>\n<li id=\"8e66\" class=\"graf graf--li graf-after--li\"><a class=\"markup--anchor markup--li-anchor\" href=\"http:\/\/online%20class%20diagram%20software\/\" target=\"_blank\" rel=\"noopener\" data-href=\"http:\/\/Online Class Diagram Software\">\u5728\u7ebf\u7c7b\u56fe\u8f6f\u4ef6<\/a><\/li>\n<li id=\"1b39\" class=\"graf graf--li graf-after--li graf--trailing\"><a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/www.google.com\/search?q=uml+visaul+paradigm&amp;sxsrf=AOaemvJcREGG3huPXRdERD5w15PnUrAxuQ%3A1632104970304&amp;ei=CvJHYYfpEai9mAW8u67YAg&amp;oq=uml+visaul+paradigm&amp;gs_lcp=Cgdnd3Mtd2l6EAMyBwgjELACECcyBAgAEA0yBggAEBYQHjIGCAAQFhAeMgYIABAWEB4yBggAEBYQHjIGCAAQFhAeMgYIABAWEB4yBggAEBYQHjIGCAAQFhAeOgQIABBDOg0ILhCxAxDHARDRAxBDOggIABCABBCxAzoFCAAQsQM6DgguEIAEELEDEMcBEKMCOgsILhCABBCxAxCDAToECCMQJzoFCAAQkQI6BQgAEIAEOgoIABCABBCHAhAUOgYIABANEB5KBAhBGABQ8fYzWJ-YNGCpmzRoAHACeACAAYUBiAHeDJIBBDE2LjOYAQCgAQHAAQE&amp;sclient=gws-wiz&amp;ved=0ahUKEwiHlvbnwIzzAhWoHqYKHbydCysQ4dUDCA4&amp;uact=5\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/www.google.com\/search?q=uml+visaul+paradigm&amp;sxsrf=AOaemvJcREGG3huPXRdERD5w15PnUrAxuQ%3A1632104970304&amp;ei=CvJHYYfpEai9mAW8u67YAg&amp;oq=uml+visaul+paradigm&amp;gs_lcp=Cgdnd3Mtd2l6EAMyBwgjELACECcyBAgAEA0yBggAEBYQHjIGCAAQFhAeMgYIABAWEB4yBggAEBYQHjIGCAAQFhAeMgYIABAWEB4yBggAEBYQHjIGCAAQFhAeOgQIABBDOg0ILhCxAxDHARDRAxBDOggIABCABBCxAzoFCAAQsQM6DgguEIAEELEDEMcBEKMCOgsILhCABBCxAxCDAToECCMQJzoFCAAQkQI6BQgAEIAEOgoIABCABBCHAhAUOgYIABANEB5KBAhBGABQ8fYzWJ-YNGCpmzRoAHACeACAAYUBiAHeDJIBBDE2LjOYAQCgAQHAAQE&amp;sclient=gws-wiz&amp;ved=0ahUKEwiHlvbnwIzzAhWoHqYKHbydCysQ4dUDCA4&amp;uact=5\"><span class=\"goog-text-highlight\">\u4ec0\u4e48\u662f\u7edf\u4e00\u5efa\u6a21\u8bed\u8a00 (UML)\uff1f<\/span><\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u5f00\u653e\/\u5c01\u95ed\u539f\u5219\u662f\u8f6f\u4ef6\u5f00\u53d1\u9886\u57df\u4e2d\u6700\u57fa\u672c\u7684\u8bbe\u8ba1\u539f\u5219\u3002\u5b83\u6307\u5bfc\u6211\u4eec\u5982\u4f55\u5efa\u7acb\u4e00\u4e2a\u7a33\u5b9a\u800c\u7075\u6d3b\u7684\u7cfb\u7edf\u3002\u4e00\u4e2a\u8f6f\u4ef6\u5b9e\u4f53\uff0c\u5982\u7c7b\u3001\u6a21\u5757\u548c\u51fd\u6570\uff0c\u5e94\u8be5\u662f\u5f00\u653e\u7684\uff0c\u53ef\u4ee5\u6269\u5c55\uff0c\u5c01\u95ed\u7684\uff0c\u53ef\u4ee5\u4fee\u6539\u3002<\/p>\n","protected":false},"author":3,"featured_media":1383,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"","footnotes":""},"categories":[2,5],"tags":[],"class_list":["post-5941","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-agile-project-management","category-software-engineering"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f - IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f - IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2\" \/>\n<meta property=\"og:description\" content=\"\u5f00\u653e\/\u5c01\u95ed\u539f\u5219\u662f\u8f6f\u4ef6\u5f00\u53d1\u9886\u57df\u4e2d\u6700\u57fa\u672c\u7684\u8bbe\u8ba1\u539f\u5219\u3002\u5b83\u6307\u5bfc\u6211\u4eec\u5982\u4f55\u5efa\u7acb\u4e00\u4e2a\u7a33\u5b9a\u800c\u7075\u6d3b\u7684\u7cfb\u7edf\u3002\u4e00\u4e2a\u8f6f\u4ef6\u5b9e\u4f53\uff0c\u5982\u7c7b\u3001\u6a21\u5757\u548c\u51fd\u6570\uff0c\u5e94\u8be5\u662f\u5f00\u653e\u7684\uff0c\u53ef\u4ee5\u6269\u5c55\uff0c\u5c01\u95ed\u7684\uff0c\u53ef\u4ee5\u4fee\u6539\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/\" \/>\n<meta property=\"og:site_name\" content=\"IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-14T08:45:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-07T01:28:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"vpvera\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"vpvera\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/\"},\"author\":{\"name\":\"vpvera\",\"@id\":\"https:\/\/www.cybermedian.com\/cn\/#\/schema\/person\/54a5a46528997d1917d55add9b0de7d5\"},\"headline\":\"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f\",\"datePublished\":\"2022-02-14T08:45:13+00:00\",\"dateModified\":\"2025-03-07T01:28:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/\"},\"wordCount\":7,\"image\":{\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg\",\"articleSection\":[\"Agile Project Management\",\"Software Engineering\"],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/\",\"url\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/\",\"name\":\"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f - IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2\",\"isPartOf\":{\"@id\":\"https:\/\/www.cybermedian.com\/cn\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg\",\"datePublished\":\"2022-02-14T08:45:13+00:00\",\"dateModified\":\"2025-03-07T01:28:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.cybermedian.com\/cn\/#\/schema\/person\/54a5a46528997d1917d55add9b0de7d5\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#primaryimage\",\"url\":\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg\",\"contentUrl\":\"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg\",\"width\":900,\"height\":600,\"caption\":\"Open-Close Principle\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.cybermedian.com\/cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.cybermedian.com\/cn\/#website\",\"url\":\"https:\/\/www.cybermedian.com\/cn\/\",\"name\":\"IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2\",\"description\":\"\u805a\u7126\u8d44\u8baf\u79d1\u6280\u5185\u5bb9\u9886\u57df\u6700\u524d\u6cbf\u8d44\u8baf\uff0c\u7f51\u7edc\u7cbe\u534e\uff0c\u5fc3\u5f97\u4ea4\u6d41\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.cybermedian.com\/cn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.cybermedian.com\/cn\/#\/schema\/person\/54a5a46528997d1917d55add9b0de7d5\",\"name\":\"vpvera\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.cybermedian.com\/cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/308f3b229618b77cd1764bf92dc496296ea49a0db7c1c881fa7c4f063b2b58da?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/308f3b229618b77cd1764bf92dc496296ea49a0db7c1c881fa7c4f063b2b58da?s=96&d=mm&r=g\",\"caption\":\"vpvera\"},\"url\":\"https:\/\/www.cybermedian.com\/cn\/author\/vpvera\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f - IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f - IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2","og_description":"\u5f00\u653e\/\u5c01\u95ed\u539f\u5219\u662f\u8f6f\u4ef6\u5f00\u53d1\u9886\u57df\u4e2d\u6700\u57fa\u672c\u7684\u8bbe\u8ba1\u539f\u5219\u3002\u5b83\u6307\u5bfc\u6211\u4eec\u5982\u4f55\u5efa\u7acb\u4e00\u4e2a\u7a33\u5b9a\u800c\u7075\u6d3b\u7684\u7cfb\u7edf\u3002\u4e00\u4e2a\u8f6f\u4ef6\u5b9e\u4f53\uff0c\u5982\u7c7b\u3001\u6a21\u5757\u548c\u51fd\u6570\uff0c\u5e94\u8be5\u662f\u5f00\u653e\u7684\uff0c\u53ef\u4ee5\u6269\u5c55\uff0c\u5c01\u95ed\u7684\uff0c\u53ef\u4ee5\u4fee\u6539\u3002","og_url":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/","og_site_name":"IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2","article_published_time":"2022-02-14T08:45:13+00:00","article_modified_time":"2025-03-07T01:28:53+00:00","og_image":[{"width":900,"height":600,"url":"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg","type":"image\/jpeg"}],"author":"vpvera","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"vpvera"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#article","isPartOf":{"@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/"},"author":{"name":"vpvera","@id":"https:\/\/www.cybermedian.com\/cn\/#\/schema\/person\/54a5a46528997d1917d55add9b0de7d5"},"headline":"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f","datePublished":"2022-02-14T08:45:13+00:00","dateModified":"2025-03-07T01:28:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/"},"wordCount":7,"image":{"@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg","articleSection":["Agile Project Management","Software Engineering"],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/","url":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/","name":"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f - IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2","isPartOf":{"@id":"https:\/\/www.cybermedian.com\/cn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#primaryimage"},"image":{"@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg","datePublished":"2022-02-14T08:45:13+00:00","dateModified":"2025-03-07T01:28:53+00:00","author":{"@id":"https:\/\/www.cybermedian.com\/cn\/#\/schema\/person\/54a5a46528997d1917d55add9b0de7d5"},"breadcrumb":{"@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#primaryimage","url":"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg","contentUrl":"https:\/\/www.cybermedian.com\/cn\/wp-content\/uploads\/sites\/6\/2022\/01\/open-closed-principle.jpg","width":900,"height":600,"caption":"Open-Close Principle"},{"@type":"BreadcrumbList","@id":"https:\/\/www.cybermedian.com\/cn\/what-is-the-open-closed-principle-ocp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cybermedian.com\/cn\/"},{"@type":"ListItem","position":2,"name":"\u4ec0\u4e48\u662f\u5f00\u95ed\u539f\u5219\uff08OCP\uff09\uff1f"}]},{"@type":"WebSite","@id":"https:\/\/www.cybermedian.com\/cn\/#website","url":"https:\/\/www.cybermedian.com\/cn\/","name":"IT \u89c2\u5bdf\u8005\u968f\u7b14 - \u8d44\u8baf\u79d1\u6280\u535a\u5ba2","description":"\u805a\u7126\u8d44\u8baf\u79d1\u6280\u5185\u5bb9\u9886\u57df\u6700\u524d\u6cbf\u8d44\u8baf\uff0c\u7f51\u7edc\u7cbe\u534e\uff0c\u5fc3\u5f97\u4ea4\u6d41","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cybermedian.com\/cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.cybermedian.com\/cn\/#\/schema\/person\/54a5a46528997d1917d55add9b0de7d5","name":"vpvera","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.cybermedian.com\/cn\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/308f3b229618b77cd1764bf92dc496296ea49a0db7c1c881fa7c4f063b2b58da?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/308f3b229618b77cd1764bf92dc496296ea49a0db7c1c881fa7c4f063b2b58da?s=96&d=mm&r=g","caption":"vpvera"},"url":"https:\/\/www.cybermedian.com\/cn\/author\/vpvera\/"}]}},"_links":{"self":[{"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/posts\/5941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/comments?post=5941"}],"version-history":[{"count":2,"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/posts\/5941\/revisions"}],"predecessor-version":[{"id":5943,"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/posts\/5941\/revisions\/5943"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/media\/1383"}],"wp:attachment":[{"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/media?parent=5941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/categories?post=5941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cybermedian.com\/cn\/wp-json\/wp\/v2\/tags?post=5941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}