{"id":25,"date":"2025-07-22T02:52:44","date_gmt":"2025-07-22T02:52:44","guid":{"rendered":"https:\/\/kienthucmo.com\/?p=25"},"modified":"2025-12-07T15:15:47","modified_gmt":"2025-12-07T08:15:47","slug":"lap-trinh-huong-doi-tuong-oop-tu-duy-cot-loi-trong-phat-trien-phan-mem-hien-dai","status":"publish","type":"post","link":"https:\/\/kienthucmo.com\/vi\/lap-trinh-huong-doi-tuong-oop-tu-duy-cot-loi-trong-phat-trien-phan-mem-hien-dai\/","title":{"rendered":"L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP): T\u01b0 duy c\u1ed1t l\u00f5i trong ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m hi\u1ec7n \u0111\u1ea1i"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP) l\u00e0 m\u1ed9t ph\u01b0\u01a1ng ph\u00e1p l\u1eadp tr\u00ecnh \u0111\u00e3 tr\u1edf n\u00ean quen thu\u1ed9c v\u1edbi nhi\u1ec1u l\u1eadp tr\u00ecnh vi\u00ean. Tuy nhi\u00ean, OOP kh\u00f4ng ph\u1ea3i l\u00fac n\u00e0o c\u0169ng \u201clung linh\u201d nh\u01b0 nh\u1eefng g\u00ec ch\u00fang ta th\u01b0\u1eddng th\u1ea5y trong s\u00e1ch gi\u00e1o khoa hay b\u00e0i gi\u1ea3ng. Tr\u00ean th\u1ef1c t\u1ebf, khi \u00e1p d\u1ee5ng v\u00e0o d\u1ef1 \u00e1n th\u1eadt, OOP c\u00f3 th\u1ec3 kh\u00e1 th\u00e1ch th\u1ee9c v\u00e0 kh\u00f4ng ho\u00e0n to\u00e0n d\u1ec5 d\u00e0ng.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">D\u1eabu v\u1eady, vi\u1ec7c hi\u1ec3u v\u00e0 s\u1eed d\u1ee5ng \u0111\u00fang c\u00e1c kh\u00e1i ni\u1ec7m c\u01a1 b\u1ea3n c\u1ee7a OOP v\u1eabn l\u00e0 b\u01b0\u1edbc n\u1ec1n t\u1ea3ng quan tr\u1ecdng gi\u00fap b\u1ea1n vi\u1ebft code r\u00f5 r\u00e0ng, d\u1ec5 qu\u1ea3n l\u00fd v\u00e0 ph\u00e1t tri\u1ec3n h\u01a1n v\u1ec1 l\u00e2u d\u00e0i. Trong b\u00e0i vi\u1ebft n\u00e0y, ch\u00fang ta s\u1ebd c\u00f9ng nhau t\u00ecm hi\u1ec3u nh\u1eefng \u0111i\u1ec1u c\u1ed1t l\u00f5i nh\u1ea5t c\u1ee7a l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP) l\u00e0 g\u00ec? L\u1ecbch s\u1eed h\u00ecnh th\u00e0nh v\u00e0 ph\u00e1t tri\u1ec3n c\u1ee7a OOP<\/h2>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"993\" height=\"1000\" data-id=\"1381\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/oop.jpg\" alt=\"\" class=\"wp-image-1381\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/oop.jpg 993w, https:\/\/kienthucmo.com\/wp-content\/uploads\/oop-298x300.jpg 298w, https:\/\/kienthucmo.com\/wp-content\/uploads\/oop-150x150.jpg 150w, https:\/\/kienthucmo.com\/wp-content\/uploads\/oop-768x773.jpg 768w\" sizes=\"(max-width: 993px) 100vw, 993px\" \/><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a href=\"https:\/\/kienthucmo.com\/en\/object-oriented-programming-oop-the-core-mindset-in-modern-software-development\/\" data-type=\"link\" data-id=\"https:\/\/kienthucmo.com\/en\/object-oriented-programming-oop-the-core-mindset-in-modern-software-development\/\">L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (Object-Oriented Programming &#8211; OOP)<\/a><\/strong> l\u00e0 m\u1ed9t ph\u01b0\u01a1ng ph\u00e1p l\u1eadp tr\u00ecnh d\u1ef1a tr\u00ean kh\u00e1i ni\u1ec7m \u201c\u0111\u1ed1i t\u01b0\u1ee3ng\u201d \u2013 nh\u1eefng th\u1ef1c th\u1ec3 \u0111\u1ea1i di\u1ec7n cho c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng trong th\u1ebf gi\u1edbi th\u1ef1c ho\u1eb7c c\u00e1c kh\u00e1i ni\u1ec7m tr\u1eebu t\u01b0\u1ee3ng. M\u1ed7i \u0111\u1ed1i t\u01b0\u1ee3ng c\u00f3 th\u1ec3 ch\u1ee9a d\u1eef li\u1ec7u (g\u1ecdi l\u00e0 thu\u1ed9c t\u00ednh) v\u00e0 c\u00e1c h\u00e0nh vi (g\u1ecdi l\u00e0 ph\u01b0\u01a1ng th\u1ee9c). M\u1ee5c ti\u00eau ch\u00ednh c\u1ee7a OOP l\u00e0 gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean m\u00f4 h\u00ecnh h\u00f3a c\u00e1c v\u1ea5n \u0111\u1ec1 ph\u1ee9c t\u1ea1p th\u00e0nh c\u00e1c th\u00e0nh ph\u1ea7n nh\u1ecf, \u0111\u1ed9c l\u1eadp nh\u01b0ng c\u00f3 th\u1ec3 t\u01b0\u01a1ng t\u00e1c v\u1edbi nhau th\u00f4ng qua c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng, t\u1eeb \u0111\u00f3 l\u00e0m cho m\u00e3 ngu\u1ed3n d\u1ec5 hi\u1ec3u, d\u1ec5 qu\u1ea3n l\u00fd v\u00e0 t\u00e1i s\u1eed d\u1ee5ng h\u01a1n.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">L\u1ecbch s\u1eed ph\u00e1t tri\u1ec3n c\u1ee7a OOP b\u1eaft \u0111\u1ea7u t\u1eeb nh\u1eefng n\u0103m 1960 v\u1edbi ng\u00f4n ng\u1eef Simula, \u0111\u01b0\u1ee3c coi l\u00e0 ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u1ea7u ti\u00ean. \u00dd t\u01b0\u1edfng n\u00e0y sau \u0111\u00f3 \u0111\u01b0\u1ee3c ho\u00e0n thi\u1ec7n v\u00e0 ph\u1ed5 bi\u1ebfn r\u1ed9ng r\u00e3i h\u01a1n qua c\u00e1c ng\u00f4n ng\u1eef nh\u01b0 Smalltalk v\u00e0o nh\u1eefng n\u0103m 1970 v\u00e0 \u0111\u1eb7c bi\u1ec7t l\u00e0 C++ t\u1eeb th\u1eadp ni\u00ean 1980. T\u1eeb \u0111\u00f3, OOP tr\u1edf th\u00e0nh m\u1ed9t trong nh\u1eefng ph\u01b0\u01a1ng ph\u00e1p ch\u1ee7 \u0111\u1ea1o trong l\u1eadp tr\u00ecnh ph\u1ea7n m\u1ec1m, \u0111\u1eb7c bi\u1ec7t l\u00e0 v\u1edbi s\u1ef1 b\u00f9ng n\u1ed5 c\u1ee7a c\u00e1c ng\u00f4n ng\u1eef nh\u01b0 Java, C#, Python\u2026 h\u1ed7 tr\u1ee3 m\u1ea1nh m\u1ebd cho m\u00f4 h\u00ecnh n\u00e0y.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So v\u1edbi l\u1eadp tr\u00ecnh th\u1ee7 t\u1ee5c (Procedural Programming), OOP c\u00f3 nhi\u1ec1u \u0111i\u1ec3m kh\u00e1c bi\u1ec7t c\u0103n b\u1ea3n. L\u1eadp tr\u00ecnh th\u1ee7 t\u1ee5c t\u1eadp trung v\u00e0o vi\u1ec7c vi\u1ebft c\u00e1c h\u00e0m v\u00e0 c\u00e1c b\u01b0\u1edbc x\u1eed l\u00fd d\u1eef li\u1ec7u tu\u1ea7n t\u1ef1, trong khi OOP t\u1eadp trung v\u00e0o vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng ch\u1ee9a c\u1ea3 d\u1eef li\u1ec7u v\u00e0 h\u00e0nh vi li\u00ean quan. \u0110i\u1ec1u n\u00e0y gi\u00fap OOP th\u1ec3 hi\u1ec7n \u0111\u01b0\u1ee3c c\u00e1c m\u1ed1i quan h\u1ec7 ph\u1ee9c t\u1ea1p trong th\u1ef1c t\u1ebf m\u1ed9t c\u00e1ch tr\u1ef1c quan h\u01a1n v\u00e0 t\u0103ng kh\u1ea3 n\u0103ng t\u00e1i s\u1eed d\u1ee5ng m\u00e3 ngu\u1ed3n. \u0110\u1ed3ng th\u1eddi, OOP c\u0169ng h\u1ed7 tr\u1ee3 t\u1ed1t h\u01a1n cho vi\u1ec7c b\u1ea3o tr\u00ec v\u00e0 m\u1edf r\u1ed9ng ph\u1ea7n m\u1ec1m khi d\u1ef1 \u00e1n ph\u00e1t tri\u1ec3n l\u1edbn v\u00e0 ph\u1ee9c t\u1ea1p.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. C\u00e1c th\u00e0nh ph\u1ea7n ch\u00ednh trong l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP)<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-1024x576.png\" alt=\"\" class=\"wp-image-572\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-1024x576.png 1024w, https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-300x169.png 300w, https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-768x432.png 768w, https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-1536x864.png 1536w, https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-1300x731.png 1300w, https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP.png 1921w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2.1 L\u1edbp (Class)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Kh\u00e1i ni\u1ec7m l\u1edbp <strong>(Class)<\/strong> l\u00e0 g\u00ec?<\/strong><br>L\u1edbp (Class) l\u00e0 khu\u00f4n m\u1eabu, b\u1ea3n thi\u1ebft k\u1ebf ho\u1eb7c b\u1ea3n v\u1ebd \u0111\u1ec3 t\u1ea1o ra c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng (Object). N\u00f3 \u0111\u1ecbnh ngh\u0129a c\u1ea5u tr\u00fac v\u00e0 h\u00e0nh vi chung cho m\u1ed9t nh\u00f3m c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng c\u00f9ng lo\u1ea1i. M\u1ed9t l\u1edbp bao g\u1ed3m c\u00e1c thu\u1ed9c t\u00ednh (d\u1eef li\u1ec7u) v\u00e0 ph\u01b0\u01a1ng th\u1ee9c (h\u00e0nh vi) m\u00e0 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng thu\u1ed9c l\u1edbp \u0111\u00f3 s\u1ebd c\u00f3.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Vai tr\u00f2 c\u1ee7a l\u1edbp (Class) trong OOP<\/strong><br>L\u1edbp<strong>(Class)<\/strong> gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean \u0111\u00f3ng g\u00f3i d\u1eef li\u1ec7u v\u00e0 c\u00e1c ch\u1ee9c n\u0103ng li\u00ean quan th\u00e0nh m\u1ed9t \u0111\u01a1n v\u1ecb logic duy nh\u1ea5t. Nh\u1edd \u0111\u00f3, vi\u1ec7c qu\u1ea3n l\u00fd, b\u1ea3o tr\u00ec v\u00e0 m\u1edf r\u1ed9ng ch\u01b0\u01a1ng tr\u00ecnh tr\u1edf n\u00ean d\u1ec5 d\u00e0ng h\u01a1n. Ngo\u00e0i ra, l\u1edbp c\u00f2n cho ph\u00e9p t\u1ea1o ra nhi\u1ec1u \u0111\u1ed1i t\u01b0\u1ee3ng ri\u00eang bi\u1ec7t m\u00e0 v\u1eabn d\u00f9ng chung c\u1ea5u tr\u00fac v\u00e0 h\u00e0nh vi, gi\u00fap ti\u1ebft ki\u1ec7m th\u1eddi gian v\u00e0 c\u00f4ng s\u1ee9c.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>V\u00ed d\u1ee5:<\/em><br>H\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng b\u1ea1n mu\u1ed1n l\u1eadp tr\u00ecnh m\u1ed9t h\u1ec7 th\u1ed1ng qu\u1ea3n l\u00fd xe \u00f4 t\u00f4. L\u1edbp \u201cCar\u201d s\u1ebd l\u00e0 khu\u00f4n m\u1eabu chung \u0111\u1ecbnh ngh\u0129a c\u00e1c thu\u1ed9c t\u00ednh nh\u01b0 m\u00e0u s\u1eafc, h\u00e3ng s\u1ea3n xu\u1ea5t, n\u0103m s\u1ea3n xu\u1ea5t, c\u00f9ng c\u00e1c ph\u01b0\u01a1ng th\u1ee9c nh\u01b0 kh\u1edfi \u0111\u1ed9ng, d\u1eebng xe, t\u0103ng t\u1ed1c.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class Car:\n    def __init__(self, brand, color, year):\n        self.brand = brand\n        self.color = color\n        self.year = year\n    \n    def start_engine(self):\n        print(f\"{self.brand} engine started.\")\n    \n    def stop_engine(self):\n        print(f\"{self.brand} engine stopped.\")\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Car<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">brand<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">color<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">year<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> brand<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">color <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> color<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">year <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> year<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">start_engine<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> engine started.&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">stop_engine<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> engine stopped.&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2.2 \u0110\u1ed1i t\u01b0\u1ee3ng (Object)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0110\u1ecbnh ngh\u0129a \u0111\u1ed1i t\u01b0\u1ee3ng<\/strong><br>\u0110\u1ed1i t\u01b0\u1ee3ng l\u00e0 th\u1ef1c th\u1ec3 c\u1ee5 th\u1ec3 \u0111\u01b0\u1ee3c t\u1ea1o ra t\u1eeb m\u1ed9t l\u1edbp. M\u1ed7i \u0111\u1ed1i t\u01b0\u1ee3ng s\u1ebd c\u00f3 c\u00e1c thu\u1ed9c t\u00ednh v\u00e0 ph\u01b0\u01a1ng th\u1ee9c \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a trong l\u1edbp nh\u01b0ng c\u00f3 gi\u00e1 tr\u1ecb d\u1eef li\u1ec7u ri\u00eang bi\u1ec7t. N\u00f3i c\u00e1ch kh\u00e1c, \u0111\u1ed1i t\u01b0\u1ee3ng l\u00e0 m\u1ed9t b\u1ea3n th\u1ec3 c\u1ee5 th\u1ec3 c\u1ee7a l\u1edbp v\u1edbi tr\u1ea1ng th\u00e1i v\u00e0 h\u00e0nh vi ri\u00eang.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>M\u1ed1i quan h\u1ec7 gi\u1eefa l\u1edbp v\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng<\/strong><br>L\u1edbp gi\u1ed1ng nh\u01b0 m\u1ed9t khu\u00f4n m\u1eabu, c\u00f2n \u0111\u1ed1i t\u01b0\u1ee3ng l\u00e0 \u201cs\u1ea3n ph\u1ea9m\u201d \u0111\u01b0\u1ee3c t\u1ea1o ra d\u1ef1a tr\u00ean khu\u00f4n m\u1eabu \u0111\u00f3. C\u00f3 th\u1ec3 t\u1ea1o ra nhi\u1ec1u \u0111\u1ed1i t\u01b0\u1ee3ng t\u1eeb c\u00f9ng m\u1ed9t l\u1edbp, m\u1ed7i \u0111\u1ed1i t\u01b0\u1ee3ng s\u1ebd mang d\u1eef li\u1ec7u kh\u00e1c nhau nh\u01b0ng c\u00f9ng chia s\u1ebb c\u00e1c ph\u01b0\u01a1ng th\u1ee9c gi\u1ed1ng nhau.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>V\u00ed d\u1ee5:<\/em><br>D\u1ef1a tr\u00ean l\u1edbp Car \u1edf tr\u00ean, ta c\u00f3 th\u1ec3 t\u1ea1o ra c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00e1c nhau \u0111\u1ea1i di\u1ec7n cho t\u1eebng chi\u1ebfc xe c\u1ee5 th\u1ec3:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class Car:\n    def __init__(self, brand, color, year):\n        self.brand = brand\n        self.color = color\n        self.year = year\n\n    def start_engine(self):\n        print(f\"{self.brand} engine started.\")\n\n\n# T\u1ea1o c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng Car\ncar1 = Car(\"Toyota\", \"Red\", 2020)\ncar2 = Car(\"Honda\", \"Blue\", 2018)\n\n# G\u1ecdi ph\u01b0\u01a1ng th\u1ee9c start_engine\ncar1.start_engine()  # Output: Toyota engine started.\ncar2.start_engine()  # Output: Honda engine started.\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Car<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">brand<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">color<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">year<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> brand<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">color <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> color<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">year <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> year<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">start_engine<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> engine started.&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># T\u1ea1o c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng Car<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">car1 <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">Car<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Toyota<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Red<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">2020<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">car2 <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">Car<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Honda<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Blue<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">2018<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># G\u1ecdi ph\u01b0\u01a1ng th\u1ee9c start_engine<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">car1<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">start_engine<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># Output: Toyota engine started.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">car2<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">start_engine<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># Output: Honda engine started.<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">M\u1ed7i chi\u1ebfc xe (car1, car2) l\u00e0 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng ri\u00eang bi\u1ec7t v\u1edbi thu\u1ed9c t\u00ednh v\u00e0 h\u00e0nh vi gi\u1ed1ng nhau nh\u01b0ng c\u00f3 gi\u00e1 tr\u1ecb c\u1ee5 th\u1ec3 kh\u00e1c nhau.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.3 Thu\u1ed9c t\u00ednh (Attributes) v\u00e0 Ph\u01b0\u01a1ng th\u1ee9c (Methods)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Thu\u1ed9c t\u00ednh (Attributes)<\/strong><br>Thu\u1ed9c t\u00ednh l\u00e0 c\u00e1c bi\u1ebfn b\u00ean trong l\u1edbp d\u00f9ng \u0111\u1ec3 l\u01b0u tr\u1eef tr\u1ea1ng th\u00e1i ho\u1eb7c d\u1eef li\u1ec7u c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng. M\u1ed7i \u0111\u1ed1i t\u01b0\u1ee3ng c\u00f3 th\u1ec3 c\u00f3 c\u00e1c gi\u00e1 tr\u1ecb thu\u1ed9c t\u00ednh kh\u00e1c nhau, ph\u1ea3n \u00e1nh tr\u1ea1ng th\u00e1i hi\u1ec7n t\u1ea1i c\u1ee7a n\u00f3.<\/li>\n\n\n\n<li><strong>Ph\u01b0\u01a1ng th\u1ee9c (Methods)<\/strong><br>Ph\u01b0\u01a1ng th\u1ee9c l\u00e0 c\u00e1c h\u00e0m b\u00ean trong l\u1edbp m\u00f4 t\u1ea3 h\u00e0nh vi ho\u1eb7c c\u00e1c ch\u1ee9c n\u0103ng m\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n. Ph\u01b0\u01a1ng th\u1ee9c th\u01b0\u1eddng thao t\u00e1c v\u1edbi thu\u1ed9c t\u00ednh ho\u1eb7c th\u1ef1c hi\u1ec7n m\u1ed9t nhi\u1ec7m v\u1ee5 c\u1ee5 th\u1ec3 li\u00ean quan \u0111\u1ebfn \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u00f3.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><em>V\u00ed d\u1ee5:<\/em><br>Ti\u1ebfp t\u1ee5c v\u1edbi l\u1edbp Car, c\u00e1c thu\u1ed9c t\u00ednh nh\u01b0 <code>brand<\/code>, <code>color<\/code>, <code>year<\/code> l\u00e0 d\u1eef li\u1ec7u \u0111\u1eb7c tr\u01b0ng cho m\u1ed7i chi\u1ebfc xe, c\u00f2n c\u00e1c ph\u01b0\u01a1ng th\u1ee9c nh\u01b0 <code>start_engine()<\/code> v\u00e0 <code>stop_engine()<\/code> l\u00e0 h\u00e0nh vi c\u1ee7a xe.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class Car:\n    def __init__(self, brand, color, year):\n        self.brand = brand        # Thu\u1ed9c t\u00ednh\n        self.color = color        # Thu\u1ed9c t\u00ednh\n        self.year = year          # Thu\u1ed9c t\u00ednh\n    \n    def start_engine(self):       # Ph\u01b0\u01a1ng th\u1ee9c\n        print(f\"{self.brand} engine started.\")\n    \n    def stop_engine(self):        # Ph\u01b0\u01a1ng th\u1ee9c\n        print(f\"{self.brand} engine stopped.\")\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Car<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">brand<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">color<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">year<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> brand        <\/span><span style=\"color: #616E88\"># Thu\u1ed9c t\u00ednh<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">color <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> color        <\/span><span style=\"color: #616E88\"># Thu\u1ed9c t\u00ednh<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">year <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> year          <\/span><span style=\"color: #616E88\"># Thu\u1ed9c t\u00ednh<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">start_engine<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><span style=\"color: #D8DEE9FF\">       <\/span><span style=\"color: #616E88\"># Ph\u01b0\u01a1ng th\u1ee9c<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> engine started.&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">stop_engine<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #616E88\"># Ph\u01b0\u01a1ng th\u1ee9c<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> engine stopped.&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">T\u00f3m l\u1ea1i:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>L\u1edbp(Class) <\/strong>l\u00e0 b\u1ea3n thi\u1ebft k\u1ebf chung, \u0111\u1ecbnh ngh\u0129a c\u00e1c thu\u1ed9c t\u00ednh v\u00e0 ph\u01b0\u01a1ng th\u1ee9c.<\/li>\n\n\n\n<li><strong>\u0110\u1ed1i t\u01b0\u1ee3ng(Object)<\/strong> l\u00e0 th\u1ef1c th\u1ec3 c\u1ee5 th\u1ec3 \u0111\u01b0\u1ee3c t\u1ea1o ra t\u1eeb l\u1edbp, mang d\u1eef li\u1ec7u ri\u00eang bi\u1ec7t.<\/li>\n\n\n\n<li><strong>Thu\u1ed9c t\u00ednh(Attributes)<\/strong> l\u01b0u tr\u1eef d\u1eef li\u1ec7u, tr\u1ea1ng th\u00e1i c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng.<\/li>\n\n\n\n<li><strong>Ph\u01b0\u01a1ng th\u1ee9c(Methods)<\/strong> th\u1ec3 hi\u1ec7n h\u00e0nh vi, ch\u1ee9c n\u0103ng c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Hi\u1ec3u r\u00f5 c\u00e1c th\u00e0nh ph\u1ea7n n\u00e0y l\u00e0 b\u01b0\u1edbc \u0111\u1ea7u ti\u00ean \u0111\u1ec3 b\u1ea1n l\u00e0m ch\u1ee7 l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng v\u00e0 x\u00e2y d\u1ef1ng c\u00e1c h\u1ec7 th\u1ed1ng ph\u1ea7n m\u1ec1m ph\u1ee9c t\u1ea1p, c\u00f3 c\u1ea5u tr\u00fac r\u00f5 r\u00e0ng v\u00e0 d\u1ec5 d\u00e0ng m\u1edf r\u1ed9ng.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u0110\u1eb7c t\u00ednh c\u1ed1t l\u1ed7i c\u1ee7a l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (4 Pillars of OOP)<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"708\" height=\"480\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-visual-selection-1.png\" alt=\"4 t\u00ednh ch\u1ea5t c\u1ee7a OOP\" class=\"wp-image-575\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-visual-selection-1.png 708w, https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-visual-selection-1-300x203.png 300w, https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/OOP-visual-selection-1-250x170.png 250w\" sizes=\"(max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3.1 \u0110\u00f3ng g\u00f3i (Encapsulation)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u00dd ngh\u0129a v\u00e0 l\u1ee3i \u00edch:<\/strong><br>\u0110\u00f3ng g\u00f3i l\u00e0 nguy\u00ean l\u00fd b\u1ea3o v\u1ec7 d\u1eef li\u1ec7u b\u00ean trong \u0111\u1ed1i t\u01b0\u1ee3ng, gi\u1edbi h\u1ea1n quy\u1ec1n truy c\u1eadp tr\u1ef1c ti\u1ebfp t\u1eeb b\u00ean ngo\u00e0i v\u00e0 ch\u1ec9 cho ph\u00e9p t\u01b0\u01a1ng t\u00e1c qua c\u00e1c ph\u01b0\u01a1ng th\u1ee9c \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a. \u0110i\u1ec1u n\u00e0y gi\u00fap che gi\u1ea5u c\u00e1c chi ti\u1ebft b\u00ean trong (data hiding), tr\u00e1nh vi\u1ec7c truy c\u1eadp v\u00e0 s\u1eeda \u0111\u1ed5i d\u1eef li\u1ec7u kh\u00f4ng h\u1ee3p l\u1ec7, t\u1eeb \u0111\u00f3 t\u0103ng t\u00ednh an to\u00e0n v\u00e0 gi\u1ea3m thi\u1ec3u l\u1ed7i trong ch\u01b0\u01a1ng tr\u00ecnh.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>V\u00ed d\u1ee5 minh h\u1ecda:<\/strong><br>Gi\u1ea3 s\u1eed b\u1ea1n c\u00f3 m\u1ed9t l\u1edbp <code>BankAccount<\/code> qu\u1ea3n l\u00fd t\u00e0i kho\u1ea3n ng\u00e2n h\u00e0ng. B\u1ea1n kh\u00f4ng mu\u1ed1n ai c\u0169ng c\u00f3 th\u1ec3 thay \u0111\u1ed5i tr\u1ef1c ti\u1ebfp s\u1ed1 d\u01b0 t\u00e0i kho\u1ea3n, v\u00ec c\u00f3 th\u1ec3 g\u00e2y ra l\u1ed7i ho\u1eb7c gian l\u1eadn. Thay v\u00e0o \u0111\u00f3, b\u1ea1n ch\u1ec9 cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng th\u1ef1c hi\u1ec7n n\u1ea1p ti\u1ec1n ho\u1eb7c r\u00fat ti\u1ec1n qua c\u00e1c ph\u01b0\u01a1ng th\u1ee9c \u0111\u01b0\u1ee3c ki\u1ec3m so\u00e1t.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class BankAccount:\n    def __init__(self, owner, balance=0):\n        self.owner = owner\n        self.__balance = balance  \n\n    def deposit(self, amount):\n        if amount > 0:\n            self.__balance += amount\n            print(f\"Deposited {amount}. New balance: {self.__balance}\")\n        else:\n            print(\"Invalid deposit amount\")\n\n    def withdraw(self, amount):\n        if 0 &lt; amount &lt;= self.__balance:\n            self.__balance -= amount\n            print(f\"Withdrawn {amount}. New balance: {self.__balance}\")\n        else:\n            print(\"Invalid withdraw amount or insufficient funds\")\n\n    def get_balance(self):\n        return self.__balance\n\n# S\u1eed d\u1ee5ng\naccount = BankAccount(\"Alice\", 1000)\naccount.deposit(500)\naccount.withdraw(200)\nprint(account.get_balance())\n# Kh\u00f4ng th\u1ec3 truy c\u1eadp tr\u1ef1c ti\u1ebfp thu\u1ed9c t\u00ednh __balance t\u1eeb b\u00ean ngo\u00e0i\n# print(account.__balance)  # s\u1ebd g\u00e2y l\u1ed7i\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">BankAccount<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">owner<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">balance<\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">owner <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> owner<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">__balance <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> balance  <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">deposit<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">amount<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> amount <\/span><span style=\"color: #81A1C1\">&gt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">__balance <\/span><span style=\"color: #81A1C1\">+=<\/span><span style=\"color: #D8DEE9FF\"> amount<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;Deposited <\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #D8DEE9FF\">amount<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\">. New balance: <\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">__balance<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">else<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Invalid deposit amount<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">withdraw<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">amount<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&lt;<\/span><span style=\"color: #D8DEE9FF\"> amount <\/span><span style=\"color: #81A1C1\">&lt;=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">__balance<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">__balance <\/span><span style=\"color: #81A1C1\">-=<\/span><span style=\"color: #D8DEE9FF\"> amount<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;Withdrawn <\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #D8DEE9FF\">amount<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\">. New balance: <\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">__balance<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">else<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Invalid withdraw amount or insufficient funds<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">get_balance<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">__balance<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># S\u1eed d\u1ee5ng<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">account <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">BankAccount<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Alice<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">1000<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">account<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">deposit<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">500<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">account<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">withdraw<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">200<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">account<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">get_balance<\/span><span style=\"color: #ECEFF4\">())<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Kh\u00f4ng th\u1ec3 truy c\u1eadp tr\u1ef1c ti\u1ebfp thu\u1ed9c t\u00ednh __balance t\u1eeb b\u00ean ngo\u00e0i<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># print(account.__balance)  # s\u1ebd g\u00e2y l\u1ed7i<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">3.2. K\u1ebf th\u1eeba (Inheritance)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Kh\u00e1i ni\u1ec7m v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng:<\/strong><br>K\u1ebf th\u1eeba cho ph\u00e9p m\u1ed9t l\u1edbp con th\u1eeba h\u01b0\u1edfng c\u00e1c thu\u1ed9c t\u00ednh v\u00e0 ph\u01b0\u01a1ng th\u1ee9c t\u1eeb l\u1edbp cha, \u0111\u1ed3ng th\u1eddi c\u00f3 th\u1ec3 m\u1edf r\u1ed9ng ho\u1eb7c s\u1eeda \u0111\u1ed5i c\u00e1c th\u00e0nh ph\u1ea7n n\u00e0y. \u0110i\u1ec1u n\u00e0y gi\u00fap t\u00e1i s\u1eed d\u1ee5ng m\u00e3 ngu\u1ed3n v\u00e0 x\u00e2y d\u1ef1ng c\u00e1c c\u1ea5u tr\u00fac l\u1edbp c\u00f3 m\u1ed1i quan h\u1ec7 r\u00f5 r\u00e0ng, gi\u1ea3m thi\u1ec3u s\u1ef1 tr\u00f9ng l\u1eb7p.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>V\u00ed d\u1ee5 th\u1ef1c t\u1ebf:<\/strong><br><\/strong>Trong h\u1ec7 th\u1ed1ng qu\u1ea3n l\u00fd ph\u01b0\u01a1ng ti\u1ec7n, ta c\u00f3 l\u1edbp cha <code>Vehicle<\/code> \u0111\u1ecbnh ngh\u0129a c\u00e1c thu\u1ed9c t\u00ednh v\u00e0 ph\u01b0\u01a1ng th\u1ee9c chung. C\u00e1c l\u1edbp con nh\u01b0 <code>Car<\/code>, <code>Motorcycle<\/code> s\u1ebd k\u1ebf th\u1eeba <code>Vehicle<\/code> v\u00e0 b\u1ed5 sung ho\u1eb7c t\u00f9y ch\u1ec9nh c\u00e1c t\u00ednh n\u0103ng ri\u00eang.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class Vehicle:\n    def __init__(self, brand, speed=0):\n        self.brand = brand\n        self.speed = speed\n\n    def accelerate(self, increment):\n        self.speed += increment\n        print(f\"Speed increased to {self.speed} km\/h\")\n\nclass Car(Vehicle):\n    def __init__(self, brand, speed=0, doors=4):\n        super().__init__(brand, speed)\n        self.doors = doors\n\n    def open_trunk(self):\n        print(\"Trunk is opened\")\n\ncar = Car(\"Toyota\")\ncar.accelerate(50)\ncar.open_trunk()\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Vehicle<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">brand<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">speed<\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">brand <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> brand<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">speed <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> speed<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">accelerate<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">increment<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">speed <\/span><span style=\"color: #81A1C1\">+=<\/span><span style=\"color: #D8DEE9FF\"> increment<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;Speed increased to <\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">speed<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> km\/h&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Car<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #8FBCBB; font-weight: bold\">Vehicle<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">brand<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">speed<\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">doors<\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #B48EAD\">4<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #88C0D0\">super<\/span><span style=\"color: #ECEFF4\">().<\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">brand<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> speed<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">doors <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> doors<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">open_trunk<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Trunk is opened<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">car <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">Car<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Toyota<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">car<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">accelerate<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">50<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">car<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">open_trunk<\/span><span style=\"color: #ECEFF4\">()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">3.3. \u0110a h\u00ecnh (Polymorphism)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0110\u1ecbnh ngh\u0129a v\u00e0 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng:<\/strong><br>\u0110a h\u00ecnh cho ph\u00e9p c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng thu\u1ed9c c\u00e1c l\u1edbp kh\u00e1c nhau c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c x\u1eed l\u00fd th\u00f4ng qua c\u00f9ng m\u1ed9t giao di\u1ec7n chung, nh\u01b0ng h\u00e0nh vi th\u1ef1c t\u1ebf l\u1ea1i kh\u00e1c nhau t\u00f9y theo l\u1edbp c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u00f3. \u0110\u00e2y l\u00e0 c\u01a1 s\u1edf \u0111\u1ec3 th\u1ef1c hi\u1ec7n s\u1ef1 linh ho\u1ea1t trong thi\u1ebft k\u1ebf ph\u1ea7n m\u1ec1m.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Hai d\u1ea1ng \u0111a h\u00ecnh ph\u1ed5 bi\u1ebfn:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Overriding (Ghi \u0111\u00e8 ph\u01b0\u01a1ng th\u1ee9c):<\/strong> L\u1edbp con \u0111\u1ecbnh ngh\u0129a l\u1ea1i ph\u01b0\u01a1ng th\u1ee9c c\u1ee7a l\u1edbp cha \u0111\u1ec3 c\u00f3 h\u00e0nh vi ri\u00eang.<\/li>\n\n\n\n<li><strong>Overloading (N\u1ea1p ch\u1ed3ng ph\u01b0\u01a1ng th\u1ee9c):<\/strong> C\u00f9ng t\u00ean ph\u01b0\u01a1ng th\u1ee9c nh\u01b0ng kh\u00e1c tham s\u1ed1 (kh\u00f4ng \u0111\u01b0\u1ee3c h\u1ed7 tr\u1ee3 tr\u1ef1c ti\u1ebfp trong Python, nh\u01b0ng c\u00f3 th\u1ec3 m\u00f4 ph\u1ecfng).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>V\u00ed d\u1ee5 minh h\u1ecda overriding:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class Animal {\n    void sound() {\n        System.out.println(\"Animal makes a sound\");\n    }\n}\n\nclass Dog extends Animal {\n    @Override\n    void sound() {\n        System.out.println(\"Dog barks\");\n    }\n}\n\npublic class Main {\n    public static void main(String[] args) {\n        Animal myAnimal = new Animal();\n        myAnimal.sound();  \/\/ Output: Animal makes a sound\n\n        Dog myDog = new Dog();\n        myDog.sound();     \/\/ Output: Dog barks\n    }\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> Animal <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    void <\/span><span style=\"color: #88C0D0\">sound<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        System<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">out<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">println<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Animal makes a sound<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> Dog extends Animal <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">@<\/span><span style=\"color: #D8DEE9FF\">Override<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    void <\/span><span style=\"color: #88C0D0\">sound<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        System<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">out<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">println<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">Dog barks<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">public <\/span><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> Main <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    public static void <\/span><span style=\"color: #88C0D0\">main<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">String<\/span><span style=\"color: #ECEFF4\">[]<\/span><span style=\"color: #D8DEE9FF\"> args<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        Animal myAnimal = new <\/span><span style=\"color: #88C0D0\">Animal<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        myAnimal<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">sound<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\">;  <\/span><span style=\"color: #81A1C1\">\/\/<\/span><span style=\"color: #D8DEE9FF\"> Output<\/span><span style=\"color: #ECEFF4\">:<\/span><span style=\"color: #D8DEE9FF\"> Animal makes a sound<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        Dog myDog = new <\/span><span style=\"color: #88C0D0\">Dog<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        myDog<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">sound<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\">;     <\/span><span style=\"color: #81A1C1\">\/\/<\/span><span style=\"color: #D8DEE9FF\"> Output<\/span><span style=\"color: #ECEFF4\">:<\/span><span style=\"color: #D8DEE9FF\"> Dog barks<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>V\u00ed d\u1ee5 minh h\u1ecda Overloading:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class Calculator {\n    int add(int a, int b) {\n        return a + b;\n    }\n\n    int add(int a, int b, int c) {\n        return a + b + c;\n    }\n}\n\npublic class Main {\n    public static void main(String[] args) {\n        Calculator calc = new Calculator();\n\n        System.out.println(calc.add(5, 10));        \/\/ Output: 15\n        System.out.println(calc.add(5, 10, 15));    \/\/ Output: 30\n    }\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> Calculator <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">add<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #D8DEE9FF\"> a<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #D8DEE9FF\"> b<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> a <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> b;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">add<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #D8DEE9FF\"> a<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #D8DEE9FF\"> b<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #D8DEE9FF\"> c<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> a <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> b <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> c;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">public <\/span><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> Main <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    public static void <\/span><span style=\"color: #88C0D0\">main<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">String<\/span><span style=\"color: #ECEFF4\">[]<\/span><span style=\"color: #D8DEE9FF\"> args<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        Calculator calc = new <\/span><span style=\"color: #88C0D0\">Calculator<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #D8DEE9FF\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        System<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">out<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">println<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">calc<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">add<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">5<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">10<\/span><span style=\"color: #ECEFF4\">))<\/span><span style=\"color: #D8DEE9FF\">;        <\/span><span style=\"color: #81A1C1\">\/\/<\/span><span style=\"color: #D8DEE9FF\"> Output<\/span><span style=\"color: #ECEFF4\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">15<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        System<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">out<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">println<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">calc<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">add<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">5<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">10<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">15<\/span><span style=\"color: #ECEFF4\">))<\/span><span style=\"color: #D8DEE9FF\">;    <\/span><span style=\"color: #81A1C1\">\/\/<\/span><span style=\"color: #D8DEE9FF\"> Output<\/span><span style=\"color: #ECEFF4\">:<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">30<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">3.4 Tr\u1eebu t\u01b0\u1ee3ng (Abstraction)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>M\u1ee5c \u0111\u00edch c\u1ee7a tr\u1eebu t\u01b0\u1ee3ng h\u00f3a:<\/strong><br>Tr\u1eebu t\u01b0\u1ee3ng h\u00f3a l\u00e0 vi\u1ec7c \u1ea9n \u0111i c\u00e1c chi ti\u1ebft ph\u1ee9c t\u1ea1p v\u00e0 ch\u1ec9 tr\u00ecnh b\u00e0y nh\u1eefng \u0111\u1eb7c \u0111i\u1ec3m c\u1ea7n thi\u1ebft c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng. Qua \u0111\u00f3, l\u1eadp tr\u00ecnh vi\u00ean t\u1eadp trung v\u00e0o \u201cc\u00e1i g\u00ec\u201d c\u1ea7n l\u00e0m m\u00e0 kh\u00f4ng c\u1ea7n quan t\u00e2m \u201cc\u00e1ch th\u1ee9c\u201d th\u1ef1c hi\u1ec7n.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u1ede m\u1ee9c \u0111\u1ed9 l\u1eadp tr\u00ecnh, tr\u1eebu t\u01b0\u1ee3ng th\u01b0\u1eddng \u0111\u01b0\u1ee3c th\u1ec3 hi\u1ec7n qua c\u00e1c l\u1edbp tr\u1eebu t\u01b0\u1ee3ng (abstract classes) ho\u1eb7c giao di\u1ec7n (interfaces), bu\u1ed9c c\u00e1c l\u1edbp con ph\u1ea3i tri\u1ec3n khai c\u00e1c ph\u01b0\u01a1ng th\u1ee9c nh\u1ea5t \u0111\u1ecbnh.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>V\u00ed d\u1ee5 v\u1ec1 abstract class trong Python:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>from abc import ABC, abstractmethod\n\nclass Shape(ABC):\n    @abstractmethod\n    def area(self):\n        pass\n\nclass Rectangle(Shape):\n    def __init__(self, width, height):\n        self.width = width\n        self.height = height\n\n    def area(self):\n        return self.width * self.height\n\nclass Circle(Shape):\n    def __init__(self, radius):\n        self.radius = radius\n\n    def area(self):\n        import math\n        return math.pi * self.radius ** 2\n\nshapes = &#91;Rectangle(3, 4), Circle(5)&#93;\nfor shape in shapes:\n    print(f\"Area: {shape.area()}\")<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">from<\/span><span style=\"color: #D8DEE9FF\"> abc <\/span><span style=\"color: #81A1C1\">import<\/span><span style=\"color: #D8DEE9FF\"> ABC<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> abstractmethod<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Shape<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">ABC<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">@<\/span><span style=\"color: #D08770\">abstractmethod<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">area<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">pass<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Rectangle<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #8FBCBB; font-weight: bold\">Shape<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">width<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">height<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">width <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> width<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">height <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> height<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">area<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">width <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">height<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">class<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">Circle<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #8FBCBB; font-weight: bold\">Shape<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">__init__<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">radius<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">radius <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> radius<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">area<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">import<\/span><span style=\"color: #D8DEE9FF\"> math<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> math<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">pi <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">self<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">radius <\/span><span style=\"color: #81A1C1\">**<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">2<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">shapes <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #88C0D0\">Rectangle<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">3<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">4<\/span><span style=\"color: #ECEFF4\">),<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">Circle<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">5<\/span><span style=\"color: #ECEFF4\">)&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">for<\/span><span style=\"color: #D8DEE9FF\"> shape <\/span><span style=\"color: #81A1C1\">in<\/span><span style=\"color: #D8DEE9FF\"> shapes<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;Area: <\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #D8DEE9FF\">shape<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">area<\/span><span style=\"color: #ECEFF4\">()<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u1ede v\u00ed d\u1ee5 tr\u00ean, l\u1edbp <code>Shape<\/code> l\u00e0 l\u1edbp tr\u1eebu t\u01b0\u1ee3ng v\u1edbi ph\u01b0\u01a1ng th\u1ee9c <code>area<\/code> ch\u01b0a \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a. C\u00e1c l\u1edbp con nh\u01b0 <code>Rectangle<\/code> v\u00e0 <code>Circle<\/code> b\u1eaft bu\u1ed9c ph\u1ea3i tri\u1ec3n khai ph\u01b0\u01a1ng th\u1ee9c n\u00e0y theo c\u00e1ch ri\u00eang c\u1ee7a ch\u00fang.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Nguy\u00ean l\u00fd<\/th><th>\u00dd ngh\u0129a ch\u00ednh<\/th><\/tr><\/thead><tbody><tr><td>\u0110\u00f3ng g\u00f3i<\/td><td>\u1ea8n d\u1eef li\u1ec7u, ch\u1ec9 cho ph\u00e9p truy c\u1eadp qua ph\u01b0\u01a1ng th\u1ee9c<\/td><\/tr><tr><td>K\u1ebf th\u1eeba<\/td><td>T\u00e1i s\u1eed d\u1ee5ng m\u00e3 v\u00e0 m\u1edf r\u1ed9ng ch\u1ee9c n\u0103ng<\/td><\/tr><tr><td>\u0110a h\u00ecnh<\/td><td>C\u00f9ng m\u1ed9t giao di\u1ec7n, nhi\u1ec1u h\u00e0nh vi kh\u00e1c nhau<\/td><\/tr><tr><td>Tr\u1eebu t\u01b0\u1ee3ng<\/td><td>\u1ea8n chi ti\u1ebft ph\u1ee9c t\u1ea1p, t\u1eadp trung v\u00e0o giao di\u1ec7n<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">4. L\u1ee3i \u00edch c\u1ee7a l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP)<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>L\u1ee3i \u00edch<\/strong><\/th><th><strong>M\u00f4 t\u1ea3 ng\u1eafn g\u1ecdn<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>T\u00e1i s\u1eed d\u1ee5ng m\u00e3 ngu\u1ed3n<\/strong><\/td><td>X\u00e2y d\u1ef1ng l\u1edbp c\u01a1 b\u1ea3n, d\u00f9ng l\u1ea1i qua k\u1ebf th\u1eeba, gi\u1ea3m vi\u1ebft l\u1ea1i code, ti\u1ebft ki\u1ec7m th\u1eddi gian ph\u00e1t tri\u1ec3n.<\/td><\/tr><tr><td><strong>D\u1ec5 b\u1ea3o tr\u00ec, m\u1edf r\u1ed9ng<\/strong><\/td><td>T\u00ednh \u0111\u00f3ng g\u00f3i v\u00e0 c\u1ea5u tr\u00fac r\u00f5 r\u00e0ng gi\u00fap s\u1eeda \u0111\u1ed5i ho\u1eb7c b\u1ed5 sung ch\u1ec9 \u1ea3nh h\u01b0\u1edfng ph\u1ea7n li\u00ean quan, d\u1ec5 n\u00e2ng c\u1ea5p.<\/td><\/tr><tr><td><strong>T\u0103ng t\u00ednh m\u00f4 \u0111un<\/strong><\/td><td>Ph\u1ea7n m\u1ec1m chia th\u00e0nh c\u00e1c module ri\u00eang bi\u1ec7t, thu\u1eadn ti\u1ec7n ph\u00e2n c\u00f4ng, ph\u00e1t tri\u1ec3n song song v\u00e0 qu\u1ea3n l\u00fd.<\/td><\/tr><tr><td><strong>M\u00f4 h\u00ecnh h\u00f3a s\u00e1t th\u1ef1c t\u1ebf<\/strong><\/td><td>M\u00f4 ph\u1ecfng \u0111\u1ed1i t\u01b0\u1ee3ng th\u1ebf gi\u1edbi th\u1ef1c tr\u1ef1c quan, d\u1ec5 hi\u1ec3u, ph\u00f9 h\u1ee3p y\u00eau c\u1ea7u th\u1ef1c t\u1ebf.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"576\" height=\"544\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/Loi-ichMo-ta-ngan-gon-visual-selection.png\" alt=\"L\u1ee3i \u00edch c\u1ee7a l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP)\" class=\"wp-image-578\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/Loi-ichMo-ta-ngan-gon-visual-selection.png 576w, https:\/\/kienthucmo.com\/wp-content\/uploads\/2025\/07\/Loi-ichMo-ta-ngan-gon-visual-selection-300x283.png 300w\" sizes=\"(max-width: 576px) 100vw, 576px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">5. OOP so v\u1edbi c\u00e1c m\u00f4 h\u00ecnh kh\u00e1c<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"648\" height=\"384\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/OOP-la-gi-visual-selection.png\" alt=\"OOP so v\u1edbi c\u00e1c m\u00f4 h\u00ecnh kh\u00e1c\" class=\"wp-image-591\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/OOP-la-gi-visual-selection.png 648w, https:\/\/kienthucmo.com\/wp-content\/uploads\/OOP-la-gi-visual-selection-300x178.png 300w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><\/figure>\n<\/div>\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Ti\u00eau ch\u00ed<\/th><th>H\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP)<\/th><th>H\u01b0\u1edbng th\u1ee7 t\u1ee5c (Procedural)<\/th><\/tr><\/thead><tbody><tr><td>M\u00f4 h\u00ecnh d\u1eef li\u1ec7u<\/td><td>D\u1ef1a tr\u00ean \u0111\u1ed1i t\u01b0\u1ee3ng<\/td><td>D\u1ef1a tr\u00ean h\u00e0m\/th\u1ee7 t\u1ee5c<\/td><\/tr><tr><td>T\u00e1i s\u1eed d\u1ee5ng m\u00e3<\/td><td>R\u1ea5t cao (k\u1ebf th\u1eeba, interface)<\/td><td>Th\u1ea5p h\u01a1n<\/td><\/tr><tr><td>B\u1ea3o tr\u00ec<\/td><td>D\u1ec5 b\u1ea3o tr\u00ec<\/td><td>Ph\u1ee9c t\u1ea1p n\u1ebfu h\u1ec7 th\u1ed1ng l\u1edbn<\/td><\/tr><tr><td>D\u1ec5 m\u1edf r\u1ed9ng<\/td><td>C\u00f3<\/td><td>Kh\u00f3 m\u1edf r\u1ed9ng h\u01a1n<\/td><\/tr><tr><td>Tr\u1eebu t\u01b0\u1ee3ng<\/td><td>C\u00f3<\/td><td>H\u1ea1n ch\u1ebf<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">6. M\u1ed9t s\u1ed1 l\u1ed7i ph\u1ed5 bi\u1ebfn khi s\u1eed d\u1ee5ng OOP v\u00e0 c\u00e1ch kh\u1eafc ph\u1ee5c<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>L\u1ed7i ph\u1ed5 bi\u1ebfn<\/strong><\/th><th><strong>Nguy\u00ean nh\u00e2n<\/strong><\/th><th><strong>C\u00e1ch kh\u1eafc ph\u1ee5c<\/strong><\/th><\/tr><\/thead><tbody><tr><td>L\u1ea1m d\u1ee5ng k\u1ebf th\u1eeba (Inheritance)<\/td><td>K\u1ebf th\u1eeba qu\u00e1 m\u1ee9c, thi\u1ebft k\u1ebf l\u1edbp ph\u1ee9c t\u1ea1p, s\u00e2u, g\u00e2y kh\u00f3 b\u1ea3o tr\u00ec<\/td><td>\u01afu ti\u00ean s\u1eed d\u1ee5ng composition thay v\u00ec k\u1ebf th\u1eeba; d\u00f9ng k\u1ebf th\u1eeba khi c\u00f3 quan h\u1ec7 \u201cl\u00e0 m\u1ed9t\u201d r\u00f5 r\u00e0ng; gi\u1eef c\u1ea5u tr\u00fac \u0111\u01a1n gi\u1ea3n<\/td><\/tr><tr><td>Hi\u1ec3u sai nguy\u00ean l\u00fd \u0111\u00f3ng g\u00f3i (Encapsulation)<\/td><td>\u0110\u1ec3 thu\u1ed9c t\u00ednh l\u1edbp \u1edf ph\u1ea1m vi c\u00f4ng khai, d\u1eef li\u1ec7u d\u1ec5 b\u1ecb thay \u0111\u1ed5i ngo\u00e0i \u00fd mu\u1ed1n<\/td><td>\u0110\u1eb7t thu\u1ed9c t\u00ednh l\u00e0 private\/protected; s\u1eed d\u1ee5ng getter\/setter \u0111\u1ec3 ki\u1ec3m so\u00e1t truy c\u1eadp v\u00e0 s\u1eeda \u0111\u1ed5i d\u1eef li\u1ec7u<\/td><\/tr><tr><td>Vi ph\u1ea1m nguy\u00ean t\u1eafc SOLID<\/td><td>L\u1edbp \u0111a nhi\u1ec7m, code kh\u00f3 b\u1ea3o tr\u00ec, kh\u00f4ng m\u1edf r\u1ed9ng d\u1ec5 d\u00e0ng<\/td><td>\u00c1p d\u1ee5ng c\u00e1c nguy\u00ean t\u1eafc SOLID: SRP, OCP, LSP, ISP, DIP; chia nh\u1ecf l\u1edbp; s\u1eed d\u1ee5ng interface v\u00e0 tr\u1eebu t\u01b0\u1ee3ng<\/td><\/tr><tr><td>L\u1edbp qu\u00e1 l\u1edbn (God Object)<\/td><td>L\u1edbp ch\u1ee9a qu\u00e1 nhi\u1ec1u ch\u1ee9c n\u0103ng, g\u00e2y ph\u1ee9c t\u1ea1p v\u00e0 kh\u00f3 b\u1ea3o tr\u00ec<\/td><td>Chia nh\u1ecf l\u1edbp theo tr\u00e1ch nhi\u1ec7m, thi\u1ebft k\u1ebf module r\u00f5 r\u00e0ng<\/td><\/tr><tr><td>L\u1eb7p l\u1ea1i code (vi ph\u1ea1m DRY)<\/td><td>Vi\u1ebft l\u1ea1i nhi\u1ec1u \u0111o\u1ea1n code t\u01b0\u01a1ng t\u1ef1<\/td><td>T\u00e1i s\u1eed d\u1ee5ng code qua ph\u01b0\u01a1ng th\u1ee9c, l\u1edbp chung<\/td><\/tr><tr><td>\u0110\u1eb7t t\u00ean kh\u00f4ng r\u00f5 r\u00e0ng<\/td><td>T\u00ean l\u1edbp, ph\u01b0\u01a1ng th\u1ee9c kh\u00f3 hi\u1ec3u ho\u1eb7c g\u00e2y nh\u1ea7m l\u1eabn<\/td><td>\u0110\u1eb7t t\u00ean r\u00f5 r\u00e0ng, th\u1ec3 hi\u1ec7n \u0111\u00fang ch\u1ee9c n\u0103ng<\/td><\/tr><tr><td>L\u1ea1m d\u1ee5ng \u0111a k\u1ebf th\u1eeba<\/td><td>\u0110a k\u1ebf th\u1eeba g\u00e2y xung \u0111\u1ed9t v\u00e0 ph\u1ee9c t\u1ea1p<\/td><td>Tr\u00e1nh \u0111a k\u1ebf th\u1eeba n\u1ebfu c\u00f3 th\u1ec3, d\u00f9ng interface thay th\u1ebf<\/td><\/tr><tr><td>Thi\u1ebfu t\u00e0i li\u1ec7u (Documentation)<\/td><td>Code kh\u00f3 hi\u1ec3u, kh\u00f3 b\u1ea3o tr\u00ec v\u00e0 chia s\u1ebb<\/td><td>Vi\u1ebft t\u00e0i li\u1ec7u r\u00f5 r\u00e0ng cho l\u1edbp, ph\u01b0\u01a1ng th\u1ee9c<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">7. C\u00f4ng c\u1ee5, ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh h\u1ed7 tr\u1ee3 OOP<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Lo\u1ea1i<\/strong><\/th><th><strong>T\u00ean c\u00f4ng c\u1ee5\/ng\u00f4n ng\u1eef<\/strong><\/th><th><strong>Ghi ch\u00fa<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh<\/strong><\/td><td>Java, C++, Python, C#, Ruby<\/td><td>H\u1ed7 tr\u1ee3 \u0111\u1ea7y \u0111\u1ee7 c\u00e1c nguy\u00ean l\u00fd OOP<\/td><\/tr><tr><td><strong>IDE<\/strong><\/td><td>IntelliJ IDEA, Visual Studio, PyCharm, Eclipse<\/td><td>H\u1ed7 tr\u1ee3 vi\u1ebft, g\u1ee1 l\u1ed7i v\u00e0 qu\u1ea3n l\u00fd d\u1ef1 \u00e1n OOP<\/td><\/tr><tr><td><strong>Framework<\/strong><\/td><td>Spring (Java), .NET (.NET C#), Django (Python), Ruby on Rails (Ruby)<\/td><td>X\u00e2y d\u1ef1ng tr\u00ean n\u1ec1n t\u1ea3ng OOP, h\u1ed7 tr\u1ee3 ph\u00e1t tri\u1ec3n nhanh v\u00e0 b\u1ea3o tr\u00ec d\u1ec5 d\u00e0ng<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"660\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/7.-Cong-cu-ngon-ngu-lap-trinh-ho-tro-OOP-visual-selection.png\" alt=\"C\u00f4ng c\u1ee5 v\u00e0 Ng\u00f4n ng\u1eef L\u1eadp tr\u00ecnh H\u1ed7 tr\u1ee3 OOP\" class=\"wp-image-592\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/7.-Cong-cu-ngon-ngu-lap-trinh-ho-tro-OOP-visual-selection.png 720w, https:\/\/kienthucmo.com\/wp-content\/uploads\/7.-Cong-cu-ngon-ngu-lap-trinh-ho-tro-OOP-visual-selection-300x275.png 300w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">8. K\u1ebft lu\u1eadn<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00f4ng ch\u1ec9 l\u00e0 m\u1ed9t k\u1ef9 thu\u1eadt l\u1eadp tr\u00ecnh, m\u00e0 c\u00f2n l\u00e0 m\u1ed9t t\u01b0 duy thi\u1ebft k\u1ebf gi\u00fap ch\u00fang ta x\u00e2y d\u1ef1ng ph\u1ea7n m\u1ec1m m\u1ed9t c\u00e1ch b\u00e0i b\u1ea3n, linh ho\u1ea1t v\u00e0 b\u1ec1n v\u1eefng. V\u1edbi kh\u1ea3 n\u0103ng t\u00e1i s\u1eed d\u1ee5ng m\u00e3 ngu\u1ed3n, d\u1ec5 d\u00e0ng b\u1ea3o tr\u00ec v\u00e0 m\u1edf r\u1ed9ng, c\u00f9ng kh\u1ea3 n\u0103ng m\u00f4 h\u00ecnh h\u00f3a s\u00e1t th\u1ef1c t\u1ebf, OOP tr\u1edf th\u00e0nh n\u1ec1n t\u1ea3ng v\u1eefng ch\u1eafc cho m\u1ecdi d\u1ef1 \u00e1n ph\u1ea7n m\u1ec1m t\u1eeb nh\u1ecf \u0111\u1ebfn l\u1edbn.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tuy nhi\u00ean, \u0111\u1ec3 ph\u00e1t huy t\u1ed1i \u0111a s\u1ee9c m\u1ea1nh c\u1ee7a OOP, vi\u1ec7c hi\u1ec3u \u0111\u00fang c\u00e1c nguy\u00ean l\u00fd v\u00e0 \u00e1p d\u1ee5ng m\u1ed9t c\u00e1ch th\u00f4ng minh, c\u00f3 ch\u1ecdn l\u1ecdc l\u00e0 \u0111i\u1ec1u kh\u00f4ng th\u1ec3 thi\u1ebfu. Hy v\u1ecdng qua b\u00e0i vi\u1ebft n\u00e0y, b\u1ea1n \u0111\u00e3 c\u00f3 \u0111\u01b0\u1ee3c c\u00e1i nh\u00ecn t\u1ed5ng quan v\u00e0 nh\u1eefng ki\u1ebfn th\u1ee9c n\u1ec1n t\u1ea3ng \u0111\u1ec3 t\u1ef1 tin h\u01a1n tr\u00ean h\u00e0nh tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">H\u00e3y ti\u1ebfp t\u1ee5c kh\u00e1m ph\u00e1, h\u1ecdc h\u1ecfi v\u00e0 s\u00e1ng t\u1ea1o v\u1edbi OOP \u2013 b\u1edfi \u0111\u00f3 ch\u00ednh l\u00e0 ch\u00eca kh\u00f3a m\u1edf ra nh\u1eefng gi\u1ea3i ph\u00e1p c\u00f4ng ngh\u1ec7 hi\u1ec7n \u0111\u1ea1i v\u00e0 hi\u1ec7u qu\u1ea3!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. T\u00e0i li\u1ec7u tham kh\u1ea3o:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">[1] B. Bruegge and A. H. Dutoit, <em>Object-Oriented Software Engineering: Using UML, Patterns, and Java<\/em>.<br>[2] R. C. Martin, <em>Clean Code: A Handbook of Agile Software Craftsmanship<\/em>.<br>[3] Real Python, \u201cPython OOP Guide,\u201d <em>RealPython.com<\/em>.<br>[4] E. Gamma, R. Helm, R. Johnson, and J. Vlissides, <em>Design Patterns: Elements of Reusable Object-Oriented Software<\/em>.<br>[5] B. McLaughlin, G. Pollice, and D. West, <em>Head First Object-Oriented Analysis and Design<\/em>.<br>[6] J. Bloch, <em>Effective Java<\/em>.<br>[7] M. Fowler, <em>Refactoring: Improving the Design of Existing Code<\/em>.<br>[8] A. J. Riel, <em>Object-Oriented Design Heuristics<\/em>.<br>[9] D. Crockford, <em>JavaScript: The Good Parts<\/em>.<br>[10] D. Phillips, <em>Python 3 Object-Oriented Programming<\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP) l\u00e0 m\u1ed9t ph\u01b0\u01a1ng ph\u00e1p l\u1eadp tr\u00ecnh \u0111\u00e3 tr\u1edf n\u00ean quen thu\u1ed9c v\u1edbi nhi\u1ec1u l\u1eadp tr\u00ecnh vi\u00ean. Tuy nhi\u00ean, OOP kh\u00f4ng ph\u1ea3i l\u00fac n\u00e0o c\u0169ng \u201clung linh\u201d nh\u01b0 nh\u1eefng g\u00ec ch\u00fang ta th\u01b0\u1eddng th\u1ea5y trong s\u00e1ch gi\u00e1o khoa hay b\u00e0i gi\u1ea3ng. Tr\u00ean th\u1ef1c t\u1ebf, khi \u00e1p d\u1ee5ng v\u00e0o d\u1ef1 \u00e1n&#8230;<\/p>\n","protected":false},"author":1,"featured_media":583,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowieHDDA:productID":"","footnotes":""},"categories":[17],"tags":[35],"class_list":["post-25","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cong-nghe-phan-mem","tag-oop"],"_links":{"self":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":13,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":2532,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/posts\/25\/revisions\/2532"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/media\/583"}],"wp:attachment":[{"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kienthucmo.com\/vi\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}