<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Blog Nguyễn Minh Hải</title>
	<atom:link href="http://nmhblog.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://nmhblog.wordpress.com</link>
	<description>Những ghi chép linh tinh.</description>
	<lastBuildDate>Thu, 26 Jan 2012 06:43:43 +0000</lastBuildDate>
	<language>vi</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='nmhblog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/76f072af584af90406d47d3ab8a05b9b?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Blog Nguyễn Minh Hải</title>
		<link>http://nmhblog.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://nmhblog.wordpress.com/osd.xml" title="Blog Nguyễn Minh Hải" />
	<atom:link rel='hub' href='http://nmhblog.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Business logic, application logic v&#224; domain logic</title>
		<link>http://nmhblog.wordpress.com/2012/01/26/business-logic-application-logic-v-domain-logic/</link>
		<comments>http://nmhblog.wordpress.com/2012/01/26/business-logic-application-logic-v-domain-logic/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 04:18:49 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/?p=602</guid>
		<description><![CDATA[Nếu tìm định nghĩa domain logic trên Wikipedia, bạn sẽ được redirect tới business logic với dòng đầu tiên “Business logic, or domain logic, is a non-technical term…”. Trên thực tế, domain logic chỉ là một phần của business logic. Phân biệt rõ các khái niệm này rất có ích trong việc xây dựng và [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=602&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Nếu tìm định nghĩa domain logic trên Wikipedia, bạn sẽ được redirect tới <a href="http://en.wikipedia.org/wiki/Business_logic" target="_blank">business logic</a> với dòng đầu tiên “<b>Business logic</b>, or <b>domain logic</b>, is a non-technical term…”. Trên thực tế, domain logic chỉ là một phần của business logic. Phân biệt rõ các khái niệm này rất có ích trong việc xây dựng và hiện thực user story cho enterprise application, đặc biệt là khi sử dụng pattern Domain Model.</p>
<p><em>Business logic = domain logic + application logic</em></p>
<p>Về cơ bản, domain logic dùng để chỉ các logic mang tính bản chất, luôn đúng cho một business domain, phản ánh tính chất của các domain object và mối quan hệ giữa chúng với nhau, mà không phụ thuộc vào một application. Trong khi đó, application logic là các logic riêng cho một application cụ thể. Các application khác nhau sẽ có các application logic khác nhau. Việc thay đổi application logic không nên dẫn đến sự thay đổi ở domain logic. Đặt trong ngữ cảnh của một enterprise application dạng client-server với nhiều loại client (web, desktop application, mobile app, v.v), domain logic là thành phần lõi ở server, được chia sẻ giữa các client, còn application logic quy định hành vi của từng client khi tương tác với người dùng.</p>
<p>Chúng ta sẽ xem xét một ví dụ để làm rõ các khái niệm. Trong việc quản lí dự án, ta quy định mối build phải thuộc một và chỉ một release nào đó. Khi đó, để mối quan hệ này luôn được đảm bảo, việc một release bị xóa sẽ dẫn đến các build thuộc về nó bị xóa theo. Thao tác này thuộc về domain logic. Khi được người dùng yêu cầu xóa một release, phần mềm quản lí dự án có thể đáp ứng đúng như domain logic, hoặc bắt buộc người dùng phải tự xóa các build trong release, hoặc có thể đòi hỏi sự xác nhận của quản lí dự án v.v. Những thao tác này phát sinh và thay đổi theo hoàn cảnh sử dụng, và không làm thay đổi ngữ nghĩa của build và release. Đây chính là application logic.</p>
<p>Việc xây dựng user story cho một hệ thống, vốn không liên quan gì đến lập trình, cũng được lợi từ việc phân tách application logic và business logic. Theo kinh nghiệm cá nhân, nó hạn chế sự trùng lặp khi diễn giải các bước trong user story, giúp lập trình viên và tester tra cứu dễ dàng hơn, và có những định hướng tốt hơn khi hiện thực. Ngoài ra, tách biệt các vấn đề (domain logic, workflow, user experience, v.v) sẽ giúp ngữ cảnh của những cuộc thảo luận cụ thể và rõ ràng, và tất nhiên sẽ hiệu quả hơn.</p>
<p>Cần chú ý là không có ranh giới tuyệt đối giữa domain logic và application logic. Việc sắp đặt như thế nào phụ thuộc vào cách nhìn về business domain, yêu cầu của application, v.v. Xét cho cùng, tất cả những việc phân chia này đều nhằm đáp ứng những nguyên tắc cơ bản khi thiết kế phần mềm.</p>
<p>Tham khảo:</p>
<ul>
<li>Patterns of Enterprise Application Architecture, của Martin Fowler và các tác giả khác.</li>
<li>Architecting Microsoft .NET Solutions for the Enterprise, của Dino Esposito và Andrea Saltarello.</li>
<li><a href="http://msdn.microsoft.com/en-us/magazine/ee236638.aspx" target="_blank">Pros and Cons of Data Transfer Objects</a>, MSDN.</li>
</ul>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh/'>lập trình</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/602/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=602&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2012/01/26/business-logic-application-logic-v-domain-logic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>V&#224;i ch&#250; &#253; khi d&#249;ng Dojo</title>
		<link>http://nmhblog.wordpress.com/2011/12/22/vi-ch-khi-dng-dojo/</link>
		<comments>http://nmhblog.wordpress.com/2011/12/22/vi-ch-khi-dng-dojo/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 09:55:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/?p=599</guid>
		<description><![CDATA[Nói chung, Dojo là một framework khá hoàn chỉnh, cung cấp một lớp các tính năng giúp bạn viết JavaScript hiệu quả hơn: Các method tiện ích với DOM (dojo.create, dojo.place, v.v) và với JavaScript (dojo.isArray, dojo.hitch, v.v). Một mô hình OOP kiểu class tương tự như các ngôn ngữ phổ biến Java, C#. Kết [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=599&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Nói chung, Dojo là một framework khá hoàn chỉnh, cung cấp một lớp các tính năng giúp bạn viết JavaScript hiệu quả hơn:</p>
<ul>
<li>Các method tiện ích với DOM (dojo.create, dojo.place, v.v) và với JavaScript (dojo.isArray, dojo.hitch, v.v). </li>
<li>Một mô hình OOP kiểu class tương tự như các ngôn ngữ phổ biến Java, C#. Kết hợp với mô hình OOP kiểu prototype của JavaScript, việc lập trình OOP trên Dojo trở nên cực kì thoải mái và tiện lợi.</li>
<li>Các cơ chế để thao tác với dữ liệu, như lấy dữ liệu từ server, tìm, thêm, xóa dữ liệu. Có thể xem đây là một persistent library rất đơn giản cho JavaScript. Tính năng này cũng giúp tách biệt phần nội dung ra khỏi phần hiển thị của các widget, giúp cho việc thao tác với dữ liệu trên các widget dạng bảng, cây của Dojo khá mạch lạc.</li>
<li>Các widget thường dùng và cơ chế để viết thêm các widget khác. Việc viết thêm widget trong Dojo phải nói là khá đơn giản và được hướng dẫn rất chi tiết.</li>
<li>Cơ chế publish/subscribe các event, theo object và global. Event là một khái niệm quan trọng trong JavaScript, và nó giúp giảm coupling khi thiết kế các ứng dụng web nặng về Ajax. Với Dojo, tất cả các method đều là event. </li>
<li>Cơ chế để quản lí sự phụ thuộc giữa các file JavaScript (tương tự như import trong Java). Dojo giúp đơn giản hóa việc nạp các file JavaScript cần thiết từ server. </li>
<li>Trong thiết kế có tính đến việc hỗ trợ accessiblity. Tùy nhu cầu mà điều này có cần thiết hay không. </li>
</ul>
<p>Tuy nhiên, Dojo cũng có nhiều hạn chế mà bạn phải cân nhắc.</p>
<ul>
<li><a href="http://w3techs.com/technologies/overview/javascript_library/all" target="_blank">Mức độ sử dụng thấp</a>, nghĩa là cộng đồng hỗ trợ sẽ nhỏ hơn so với các library phổ biến hơn. </li>
<li>Widget của Dojo được tập hợp một cách có hệ thống, và mỗi widget luôn cố gắng đáp ứng mọi nhu cầu có thể. Điều này khiến cho một số widget như Tree, DataGrid trở nên cồng kềnh và phức tạp, cả về HTML sinh ra lẫn JavaScript cho hành vi của chúng. Việc chỉnh sửa chúng cho phù hợp với nhu cầu sẽ tiêu tốn nhiều công sức của bạn. </li>
<li>Chất lượng mã nguồn không đồng đều. Một số widget được xây dựng từ nhiều thành phần nhưng lại không thiết kế phù hợp với nguyên tắc Inversion of Control, khiến cho việc mở rộng, chỉnh sửa mỗi thành phần khó khăn hơn. Mặc dù điều này có thể được khắc phục phần nào trong một số trường hợp với prototype. </li>
<li>Việc layout các widget của Dojo phụ thuộc rất nhiều vào kích thước của các widget liên quan, trong khi đó hiện thực các tính toán này không hoàn toàn ổn định, rải rác khắp mọi chỗ trong mã nguồn, có thể ảnh hưởng tới hiệu năng và độ ổn định của ứng dụng. </li>
</ul>
<p>Nói thêm, bởi vì Dojo là một framework hoàn chỉnh nhằm hỗ trợ mọi nhu cầu liên quan đến phát triển ứng dụng web với JavaScript, cho nên sẽ khó mà chọn được framework thay thế với chất lượng hoàn toàn tốt hơn. Tuy nhiên, bạn có thể thử gộp những library nhỏ để có được những tính năng tương tự như Dojo cung cấp. Vì các library nhỏ nhằm giải quyết những vấn đề cụ thể hơn, chúng có thể tiến hóa nhanh hơn và ổn định hơn một framework lớn. Chẳng hạn:</p>
<ul>
<li>JQuery, Prototype.js, MooTools cho những mở rộng đơn giản trên JavaScript.</li>
<li>JQuery cho thao tác với DOM, và JQuery UI cho các widget thường dùng.</li>
<li>Prototype.js để sử dụng mô hình OOP kiểu class trong JavaScript.</li>
<li>v.v</li>
</ul>
<p>Cuối cùng, nếu bạn đã quyết định dùng Dojo, thì có lẽ vài kinh nghiệm nhỏ dưới đây sẽ có ích cho bạn:</p>
<ul>
<li>Học JavaScript. Nó đủ khác các ngôn ngữ phổ biến khác để bạn phải học một cách cẩn thận.</li>
<li>Đọc kĩ tài liệu Dojo cung cấp, và nếu có thể, xem qua mã nguồn của một số thành phần để hiểu rõ.</li>
<li>Mở rộng, chỉnh sửa các thành phần Dojo cung cấp theo ý của mình, thay vì cố gắng tìm một giải pháp “hack” dựa trên những gì Dojo đã có.</li>
<li>Tìm hiểu về những vấn đề liên quan nếu cần, chẳng hạn như <a href="http://www.ibm.com/developerworks/web/library/wa-memleak/" target="_blank">memory leak trong JavaScript và Dojo</a>, <a href="http://addyosmani.com/largescalejavascript/" target="_blank">kiến trúc của một ứng dụng web nặng về JavaScript</a>, v.v</li>
</ul>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/dojo/'>Dojo</a>, <a href='http://nmhblog.wordpress.com/tag/javascript/'>JavaScript</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/599/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=599&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2011/12/22/vi-ch-khi-dng-dojo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>N&#243;i kh&#244;ng</title>
		<link>http://nmhblog.wordpress.com/2011/12/11/n%e1%bb%ada-nam-di-lm/</link>
		<comments>http://nmhblog.wordpress.com/2011/12/11/n%e1%bb%ada-nam-di-lm/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 05:48:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linh tinh]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/?p=595</guid>
		<description><![CDATA[Nói với quản lí rằng không có đủ thời gian để hoàn thành một công việc là một trong những kĩ năng tôi muốn có nhất sau gần một năm đi làm. Hoặc bạn phải lựa chọn giữa trễ hạn và sống trong lo lắng vì chất lượng của những thứ mình tạo ra. Trong [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=595&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Nói với quản lí rằng không có đủ thời gian để hoàn thành một công việc là một trong những kĩ năng tôi muốn có nhất sau gần một năm đi làm. Hoặc bạn phải lựa chọn giữa trễ hạn và sống trong lo lắng vì chất lượng của những thứ mình tạo ra.</p>
<p>Trong ngành này dường như làm kịp thời hạn là một cái gì đó xa xỉ. Tất nhiên mọi thứ cũng có giới hạn của nó, quản lí thì có quản lí ở cao hơn, quản lí ở cao hơn thì có khách hàng, khách hàng thì có thị trường, v.v. Cho nên không phải cứ cái gì cũng nói không kịp là được.</p>
<p>Công bằng mà nói, không cứ gì phát triển phần mềm, mà nói chung bạn không thể có đủ thời gian để làm tất cả mọi việc, nhưng bạn có thể có thời gian để làm những việc quan trọng nhất. Vì vậy làm không kịp cũng là một biểu hiện của tính yếu kém trong việc ước lượng thời gian và đánh giá kế hoạch.</p>
<p>Nói như thế có nghĩa là việc nói không với người quản lí không phải chỉ đơn giản là thu hết can đảm lại mà nói. Chính xác hơn can đảm không có vai trò gì ở đây cả. Bạn phải tính toán được và chấp nhận rằng bạn không có đủ thời gian, phải thấy được việc gì cần làm với chất lượng ở mức độ hợp lí, và phải chọn lấy những giải pháp thỏa hiệp nhất. Càng nhiều thông tin và lựa chọn thì người quản lí sẽ càng dễ tiếp thu ý kiến của bạn. Vậy là kĩ năng nói không phụ thuộc vào khả năng ước lượng, nắm vấn đề và kiến thức và các giải pháp.</p>
<p>Khi biết nói không rồi có lẽ tôi sẽ trở nên chuyên nghiệp hơn rất nhiều.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/linh-tinh/'>linh tinh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/595/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/595/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/595/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=595&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2011/12/11/n%e1%bb%ada-nam-di-lm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>mappedby trong JPA (v&#224; chuyện đọc s&#225;ch)</title>
		<link>http://nmhblog.wordpress.com/2011/05/03/mappedby-trong-jpa/</link>
		<comments>http://nmhblog.wordpress.com/2011/05/03/mappedby-trong-jpa/#comments</comments>
		<pubDate>Tue, 03 May 2011 13:24:11 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[linh tinh]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2011/05/03/mappedby-trong-jpa/</guid>
		<description><![CDATA[Annotation element “mappedby” được dùng trong JPA để chỉ đến field bên phía relationship owner. Khi mới tìm hiểu về mappedby thì thuật ngữ “relationship owner” làm tôi cảm thấy khá mơ hồ. Lí do chủ yếu là sách giải thích rất qua loa thuật ngữ này. Tìm kiếm trên Internet có vẻ không đem [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=589&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Annotation element “mappedby” được dùng trong JPA để chỉ đến field bên phía relationship owner.</p>
<p>Khi mới tìm hiểu về mappedby thì thuật ngữ “relationship owner” làm tôi cảm thấy khá mơ hồ. Lí do chủ yếu là sách giải thích rất qua loa thuật ngữ này. Tìm kiếm trên Internet có vẻ không đem lại kết quả gì đáng kể. Một cấp trên của tôi giải thích rằng việc lựa chọn relationship owner tùy thuộc vào ý nghĩa về mặt business của các entity càng khiến tôi rối loạn hơn.</p>
<p>Hóa ra, chỉ dẫn về “relationship owner” đã được phát biểu rất rõ ràng trong <a href="http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html" target="_blank">JSR 220</a>:</p>
<blockquote><p>Relationships may be bidirectional or unidirectional. A bidirectional relationship has both an owning side and an inverse side. A unidirectional relationship has only an owning side. The owning side of a relationship determines the updates to the relationship in the database, as described in section 3.2.3. </p>
<p>The following rules apply to bidirectional relationships: </p>
<ul>
<li>The inverse side of a bidirectional relationship must refer to its owning side by use of the mappedBy element of the OneToOne, OneToMany, or ManyToMany annotation. The mappedBy element designates the property or field in the entity that is the owner of the relationship. </li>
<li>The many side of one-to-many / many-to-one bidirectional relationships must be the owning side, hence the mappedBy element cannot be specified on the ManyToOne annotation. </li>
<li>For one-to-one bidirectional relationships, the owning side corresponds to the side that contains the corresponding foreign key. </li>
<li>For many-to-many bidirectional relationships either side may be the owning side. </li>
</ul>
</blockquote>
<p>Chứng tỏ trong một số trường hợp đọc specification lại tiết kiệm thời gian hơn tìm kiếm trên Internet <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/jpa/'>JPA</a>, <a href='http://nmhblog.wordpress.com/tag/linh-tinh/'>linh tinh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/589/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=589&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2011/05/03/mappedby-trong-jpa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>C&#224;i PEAR tr&#234;n WAMP</title>
		<link>http://nmhblog.wordpress.com/2011/05/01/ci-pear-trn-wamp/</link>
		<comments>http://nmhblog.wordpress.com/2011/05/01/ci-pear-trn-wamp/#comments</comments>
		<pubDate>Sun, 01 May 2011 12:43:17 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[PEAR]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WAMP]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2011/05/01/ci-pear-trn-wamp/</guid>
		<description><![CDATA[Giả sử WAMP được cài vào C:\wamp. Thêm đường dẫn tới thư mục cài php (C:\wamp\bin\php\php5.3.5) vào biến môi trường PATH. Chuyển tới thư mục C:\wamp\bin\php\php5.3.5, chạy lệnh: php -d phar.require_hash=0 PEAR/go-pear.phar. Đừng chạy file go-pear.bat như thường được chỉ. Sau đó merge file PEAR_ENV.reg vào registry. Khi chạy lệnh trên, nếu có báo lỗi [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=588&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Giả sử WAMP được cài vào C:\wamp.</p>
<p>Thêm đường dẫn tới thư mục cài php (C:\wamp\bin\php\php5.3.5) vào biến môi trường PATH.</p>
<p>Chuyển tới thư mục C:\wamp\bin\php\php5.3.5, chạy lệnh: <code>php -d phar.require_hash=0 PEAR/go-pear.phar</code>. Đừng chạy file go-pear.bat như thường được chỉ. Sau đó merge file PEAR_ENV.reg vào registry.</p>
<p>Khi chạy lệnh trên, nếu có báo lỗi liên quan đến việc giải nén gói Structures_Graph thì xử lí như sau:</p>
<ul>
<li>Tải gói Structures_Graph tử trang <a href="http://pear.php.net">http://pear.php.net</a>. </li>
<li>Giải nén, chép thư mục Structures vào C:\wamp\bin\php\php5.3.5\pear\pear </li>
<li>Tạo biến môi trường PHP_PEAR_PHP_BIN với giá trị C:\wamp\bin\php\php5.3.5\php.exe. </li>
<li>Chuyển tới thư mục C:\wamp\bin\php\php5.3.5\pear\pear, chạy lệnh <code>pear upgrade-all</code>. </li>
</ul>
<p>Xong <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/pear/'>PEAR</a>, <a href='http://nmhblog.wordpress.com/tag/php/'>PHP</a>, <a href='http://nmhblog.wordpress.com/tag/wamp/'>WAMP</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/588/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=588&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2011/05/01/ci-pear-trn-wamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Value type v&#224; reference type trong C#</title>
		<link>http://nmhblog.wordpress.com/2011/02/20/value-type-v-reference-type-trong-c/</link>
		<comments>http://nmhblog.wordpress.com/2011/02/20/value-type-v-reference-type-trong-c/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 12:22:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cpp]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2011/02/20/value-type-v-reference-type-trong-c/</guid>
		<description><![CDATA[(Cập nhật: Trong C# in depth (2nd edition) có một phần thảo luận chi tiết về vấn đề này, nếu bạn quan tâm thì nên tham khảo, đừng đọc phần dưới.) Hôm nọ vào diễn đàn nào đấy thấy giải thích sự khác nhau giữa value type và reference type trong C#. Đại loại là [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=577&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>(Cập nhật: Trong C# in depth (2nd edition) có một phần thảo luận chi tiết về vấn đề này, nếu bạn quan tâm thì nên tham khảo, đừng đọc phần dưới.)</p>
<p>Hôm nọ vào diễn đàn nào đấy thấy giải thích sự khác nhau giữa value type và reference type trong C#. Đại loại là biến value type nằm trên stack, biến reference type nằm trên heap. Có lẽ suy nghĩ này ảnh hưởng từ C/C++ gì đó chăng, nhưng nói chung là không chính xác. Về các đặc điểm của value type và reference type, <a href="http://msdn.microsoft.com/en-us/library/3ewxz6et.aspx" target="_blank">MSDN đã trình bày đầy đủ</a>, nên ở đây không lặp lại nữa. Quay lại chuyện stack và heap. Giả sử như ý trên đúng, tức là object tạo từ class nằm trên heap. Nếu object này có field int là value type, thì field này nằm ở đâu? Theo như ý trên thì nó nằm ở stack. Object nằm trên heap mà field nằm ở stack thì cũng hơi lạ nhỉ. </p>
<p>Thực ra, tôi nghĩ cái ý tưởng về stack và heap không đúng mà cũng chẳng sai. Vấn đề là, nó thuộc về hiện thực của CLR, và chúng ta không thể và cũng không cần biết chuyện nó lưu trữ các giá trị như thế nào. Việc chúng ta cần quan tâm chỉ là các tính chất và hành vi của chúng mà thôi.</p>
<p>Không phải chỉ C#, ngay cả với C++ thì việc sử dụng khái niệm stack và heap cũng là không cần thiết và có vẻ không chuẩn. Cụ thể thế nào thì các bạn có thể tìm hiểu thêm các khái niệm automatic storage, static storage, and dynamic storage (chẳng hạn, trong quyển C++ primer plus, đây cũng là một quyển rất tốt về C++).</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/c/'>C#</a>, <a href='http://nmhblog.wordpress.com/tag/cpp/'>Cpp</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/577/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/577/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/577/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=577&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2011/02/20/value-type-v-reference-type-trong-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>T&#243;m lại polymorphism trong OOP l&#224; g&#236; nhỉ?</title>
		<link>http://nmhblog.wordpress.com/2011/02/17/tm-l%e1%ba%a1i-polymorphism-trong-oop-l-g-nh%e1%bb%89/</link>
		<comments>http://nmhblog.wordpress.com/2011/02/17/tm-l%e1%ba%a1i-polymorphism-trong-oop-l-g-nh%e1%bb%89/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 09:32:28 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình]]></category>
		<category><![CDATA[lập trình hướng đối tượng]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2011/02/17/tm-l%e1%ba%a1i-polymorphism-trong-oop-l-g-nh%e1%bb%89/</guid>
		<description><![CDATA[(Bài này khá linh tinh và có thể chứa thông tin không chính xác. Nếu bạn mới học lập trình thì không nên đọc.) Khi chưa tìm hiểu kĩ về polymorphism, tôi có cảm giác polymorphism là một cái gì đó khá mơ hồ. Nói chung thì các sách khi để cập đến vấn đề [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=562&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>(Bài này khá linh tinh và có thể chứa thông tin không chính xác. Nếu bạn mới học lập trình thì không nên đọc.)</p>
<p>Khi chưa tìm hiểu kĩ về polymorphism, tôi có cảm giác polymorphism là một cái gì đó khá mơ hồ. Nói chung thì các sách khi để cập đến vấn đề này đều dùng ví dụ minh họa hơn là định nghĩa chính xác. Với những tài liệu có định nghĩa, thì có vẻ như đánh đồng polymorphism và overriding. Tuy nhiên, trong khi với những ngôn ngữ như Java các method đều là virtual method thì cũng có những ngôn ngữ như C# trong đó virtual method và overriding phải được phát biểu một cách rõ ràng. Tuy nhiên, như ta đã biết, polymorphism cùng với encapsulation và inheritance thường được giới thiệu như là ba cột trụ (pillar) của OOP. Nếu polymorphism đồng nghĩa với overriding và virtual method thì tại sao những ngôn ngữ như C# lại có vẻ như hạn chế cột trụ này? (Nói ngoài lề là thực ra việc đòi hỏi phát biểu virtual method và overriding một cách rõ ràng trong C# có cái lí của nó, chứ không phải là để hạn chế.)</p>
<p>Thực tế là, khi đọc các tài liệu mang tính lí thuyết hơn, bạn sẽ thấy polymorphism không phải là một khái niệm của riêng OOP, càng không đồng nghĩa với overriding. Mặc dù không phải tất cả các tài liệu đều viết giống nhau, nhưng nhìn chung có thể định nghĩa polymorphism là tính chất cho phép các cấu trúc gồm hàm và kiểu dữ liệu có thể làm việc với nhiều kiểu dữ liệu khác nhau. Có ba dạng polymorphism:</p>
<ul>
<li>Parametric polymorphism: Các type liên quan đến cấu trúc được cung cấp dưới dạng biểu thức trong đó type là các biến. Chẳng hạn, C++ template chính là một cơ chế hỗ trợ parametric polymorphism trong ngôn ngữ này. Tất nhiên, parametric polymorphism có thể có trong các ngôn ngữ không hỗ trợ OOP. </li>
<li>Ad hoc polymorphism: Thuật ngữ này dùng để chỉ overloading. Ví dụ phổ biến là toán tử + có thể là một function dạng int * int –&gt; int, cũng có thể là một function dạng string * string –&gt; string. Một số người không đồng ý xem overloading là một dang polymorphism. </li>
<li>Subtype polymorphism: Đây là dạng polymorphism mà thuật ngữ “polymorphism” trong OOP chỉ tới. Với subtype polymorphism, một method có thể áp dụng cho nhiều type khác nhau thông qua subtyping. Cụ thể, nếu một method áp dụng được cho type T, nó sẽ áp dụng được cho subtype của T. Quan hệ subtype thường được thiết lập thông qua inheritance. Chú ý là, định nghĩa này không đề cập đến overriding hay virtual method gì cả. Một ngôn ngữ OOP có thể không hỗ trợ overriding mà vẫn thỏa mãn subtype polymorphism. </li>
</ul>
<p>Một điểm đáng chú ý là trừ Wikipedia, tôi chưa thấy có nguồn nào coi overriding là một dạng polymorphism cả.</p>
<p>Tóm lại nên định nghĩa polymorphism như thế nào? Về mặt lương tâm mà nói thì có lẽ cần trình bày dựa theo lí thuyết về ngôn ngữ lập trình. Về mặt cảm giác, tôi nghĩ định nghĩa polymorphism trong OOP bằng subtype polymorphism tuy trông thì phức tạp nhưng lại đơn giản, mạch lạc, ít mơ hồ hơn định nghĩa thông qua overriding (đương nhiên kéo theo người học dễ hiểu, dễ nhớ, dễ hệ thống hơn). Về thực tế thì vì định nghĩa về polymorphism trong OOP thông qua overriding (và kéo theo hiểu rằng polymorphism là đặc trưng của OOP) đã quá phổ biến, mà hiểu sao thì tóm lại vẫn là biết lập trình, nên có lẽ cũng không cần bận tâm đến polymorphism thực sự là cái gì nữa <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p>Các bạn có thể tham khảo thêm trong Concepts in programming languages và Programming languages pragmatics.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh/'>lập trình</a>, <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/'>lập trình hướng đối tượng</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/562/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/562/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/562/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/562/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/562/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/562/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/562/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/562/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/562/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/562/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/562/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/562/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/562/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/562/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=562&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2011/02/17/tm-l%e1%ba%a1i-polymorphism-trong-oop-l-g-nh%e1%bb%89/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>C, C++: to&#225;n tử ++ v&#224; sequence point v&#224; side effect</title>
		<link>http://nmhblog.wordpress.com/2011/02/13/c-c-ton-t%e1%bb%ad-v-sequence-point-v-side-effect/</link>
		<comments>http://nmhblog.wordpress.com/2011/02/13/c-c-ton-t%e1%bb%ad-v-sequence-point-v-side-effect/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 03:45:25 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cpp]]></category>
		<category><![CDATA[lập trình]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2011/02/13/c-c-ton-t%e1%bb%ad-v-sequence-point-v-side-effect/</guid>
		<description><![CDATA[Chắc ai cũng biết toán tử ++ trong C++ có hai phiên bản: a++ tăng a thêm 1 (nếu a là int), trả về giá trị hiện tại (trước khi tăng) của a, ++a tăng a thêm 1 (nếu a là int), trả về giá trị sau khi tăng của a. Vậy cho int a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=557&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Chắc ai cũng biết toán tử ++ trong C++ có hai phiên bản:</p>
<ul>
<li>a++ tăng a thêm 1 (nếu a là int), trả về giá trị hiện tại (trước khi tăng) của a,</li>
<li>++a tăng a thêm 1 (nếu a là int), trả về giá trị sau khi tăng của a.</li>
</ul>
<p>Vậy cho int a = 1 thì 1 + a++ + a++; sẽ cho ra giá trị bao nhiêu? Dễ quá nhỉ, cứ áp dụng quy tắc trên là xong. Đây là một dạng câu hỏi phổ biến mà một số sách C, C++, v.v và một số giáo viên vẫn hay đố.</p>
<p>Tuy nhiên, thực tế dù bạn có áp dụng quy tắc trên, hay chạy thử bằng trình dịch thì kết quả mà bạn có vẫn luôn là một câu trả lời sai. Bởi vì theo đặc tả của C++, chỉ tại các <a href="http://en.wikipedia.org/wiki/Sequence_point" target="_blank">sequence point</a>, ta mới có thể đảm bảo là các side effect (hiệu ứng lề) của biểu thức đã được thực thi, và thứ tự thực thi thường không được đảm bảo. Chẳng hạn:</p>
<ul>
<li>f() + g();: + không phải là sequence point, ; là sequence point. Không thể chắc chắn được là f() hay g() được thực thi trước.</li>
<li>f() + g(a++);: Không thể chắc chắn f() hay g(a++) được thực thi trước, nghĩa là không thể chắc chắn f() hay a++ được thực thi trược, nên nếu trong f có thể truy xuất được a thì giá trị của a sẽ là không xác định.</li>
<li>Tình huống ban đầu, 1 + a++ + a++;: Tất cả những gì ta có thể chắc chắn là a sẽ được tăng lên 1 hai lần, việc tăng này có thể xảy ra trước hoặc sau bất kì phép + nào trong biểu thức, nên giá trị của biểu thức này là không xác định, và phụ thuộc vào từng trình dịch cụ thể.</li>
</ul>
<p>Ta kết luận được gì?</p>
<ul>
<li>Đặc tả của các ngôn ngữ lập trình luôn phức tạp hơn ta tưởng rất nhiều, và những người soạn ra nó thực sự là các language lawyer.</li>
<li>Đừng cố lồng ghép các biểu thức như trên, bên cạnh việc không xác định giá trị nó còn làm cho mã nguồn trở nên vô cùng rối rắm.</li>
<li>Hạn chế side effect, trả về kết quả nên là công việc duy nhất mà một function phải làm. Đây cũng là một nguyên tắc mà lập trình hàm cổ vũ.</li>
<li>Đừng đố người khác những biểu thức như thế này <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</li>
</ul>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/cpp/'>Cpp</a>, <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh/'>lập trình</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/557/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/557/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/557/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=557&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2011/02/13/c-c-ton-t%e1%bb%ad-v-sequence-point-v-side-effect/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Hướng dẫn viết b&#225;o c&#225;o luận văn</title>
		<link>http://nmhblog.wordpress.com/2010/12/02/h%c6%b0%e1%bb%9bng-d%e1%ba%abn-vi%e1%ba%bft-bo-co-lu%e1%ba%adn-van/</link>
		<comments>http://nmhblog.wordpress.com/2010/12/02/h%c6%b0%e1%bb%9bng-d%e1%ba%abn-vi%e1%ba%bft-bo-co-lu%e1%ba%adn-van/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 10:02:28 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linh tinh]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/12/01/h%c6%b0%e1%bb%9bng-d%e1%ba%abn-vi%e1%ba%bft-bo-co-lu%e1%ba%adn-van/</guid>
		<description><![CDATA[Đây là hướng dẫn viết báo cáo luận văn do thầy Nguyễn Hứa Phùng phổ biến, nếu bạn học Khoa học máy tính ở BK thì nên tham khảo. Theo như thầy NHP nói, thì chỉ có hai người xem báo cáo của bạn là người hướng dẫn và người phản biện, ba người trong [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=523&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Đây là hướng dẫn viết báo cáo luận văn do thầy Nguyễn Hứa Phùng phổ biến, nếu bạn học Khoa học máy tính ở BK thì nên tham khảo.</p>
<p>Theo như thầy NHP nói, thì chỉ có hai người xem báo cáo của bạn là người hướng dẫn và người phản biện, ba người trong hội đồng chấm sẽ chỉ lướt qua trong lúc bạn bảo vệ. Hơn nữa ngay cả người phản biện cũng sẽ không có nhiều thời gian để xem báo cáo, cho nên bạn phải cố gắng tập trung vào các điểm chính trong luận văn của mình. Đặc biệt cần tránh việc nhồi những thứ vô bổ vào báo cáo để cho nhiều chữ.</p>
<p>Báo cáo:</p>
<ul>
<li>Chương 1: Giới thiệu, nên chiếm 10-20 trang. Đây là phần đặc biệt quan trọng, vì người phản biện sẽ căn cứ vào phần này để xem có nên đọc kĩ phần sau không <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</li>
<ul>
<li>Tầm quan trọng: Chứng tỏ vấn đề mà bạn tìm hiểu có vai trò quan trọng (không quan trọng thì làm làm gì).</li>
<li>Độ phức tạp: Chứng tỏ vấn đề này khó (không khó sao đáng làm luận văn).</li>
<li>Thesis statement: Phát biểu bạn sẽ làm cái gì. Công việc mà bạn hoàn tất phải khớp với phát biểu này.</li>
<li>Đóng góp của luận văn cho vấn đề bạn tìm hiểu.</li>
<li>Cấu trúc của báo cáo.</li>
</ul>
<li>Chương 2: Kiến thức nền tảng, khoảng 20 trang. Trình bày những công nghệ và công việc liên quan (của người khác). Lưu ý không sao chép, và viết thật ngắn gọn, <em>vì đây là những thứ người khác làm</em>. Người phản biện thường sẽ không xem kĩ phần này mà chỉ tham khảo nếu cần thiết cho việc đọc các chương sau.</li>
<li>Chương 3 (và 4, nếu hai người làm hai việc độc lập): Thiết kế và hiện thực, khoảng 60 trang, nói chung phải đảm bảo chiếm tỉ lệ lớn trong báo cáo, <em>vì đây là những thứ do mình làm</em>.</li>
<ul>
<li>Thiết kế: Chú ý phân tích, so sánh các công nghệ, phương án. Phải làm sao thể hiện những thứ mình chọn là tối ưu nhất.</li>
<li>Hiện thực: Chỉ trình bày qua cách tổ chức chương trình, triển khai, v.v. Đừng chép mã nguồn vào báo cáo, vì sẽ không ai đọc.</li>
</ul>
<li>Chương 4: Thử nghiệm.</li>
<li>Chương 5: Kết luận.</li>
<li>Phụ lục: Có thể trình bày kế hoạch thực hiện luận văn, bao gồm dự kiến và thực tế, những việc nảy sinh, v.v</li>
</ul>
<p>Thuyết trình:</p>
<ul>
<li>Thời gian nói khoảng 15-20 phút, số slide khoảng 20-25.</li>
<li>Một số slide quan trọng:</li>
<ul>
<li>Slide 0: Giới thiệu tên, tuổi, v.v</li>
<li>Slide 1: Bố cục của bài thuyết trình.</li>
<li>Slide 2-3: Chương 1 của báo cáo, nói khoảng 2 phút.</li>
<li>Chú ý không nói chương 2 của báo cáo, hoặc chỉ nói trong một slide.</li>
</ul>
</ul>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/linh-tinh/'>linh tinh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/523/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=523&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/12/02/h%c6%b0%e1%bb%9bng-d%e1%ba%abn-vi%e1%ba%bft-bo-co-lu%e1%ba%adn-van/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>M&#244;n Lập tr&#236;nh hướng đối tượng</title>
		<link>http://nmhblog.wordpress.com/2010/12/01/mn-l%e1%ba%adp-trnh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/</link>
		<comments>http://nmhblog.wordpress.com/2010/12/01/mn-l%e1%ba%adp-trnh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 10:06:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình hướng đối tượng]]></category>
		<category><![CDATA[linh tinh]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/12/01/mn-l%e1%ba%adp-trnh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/</guid>
		<description><![CDATA[Không biết vào thời điểm này thì đưa mấy bài kiểu này nên có an toàn không nhỉ . Tháng trước HM có chat với một người bạn và nhận được một câu trong đề thi giữa kì môn Lập trình hướng đối tượng như sau: Trong C++ câu lệnh ClassB CB = new ClassB() [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=563&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Không biết vào thời điểm này thì đưa mấy bài kiểu này nên có an toàn không nhỉ <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p>Tháng trước HM có chat với một người bạn và nhận được một câu trong đề thi giữa kì môn Lập trình hướng đối tượng như sau:</p>
<blockquote><p>Trong C++ câu lệnh ClassB CB = new ClassB() tạo ra đối tượng trong vùng nhớ: a. heap b. stack c. static d. tất cả đều sai</p>
</blockquote>
<p>Và HM nhận ra đã hai năm kể từ khi học xong môn này, nó vẫn chả thay đổi gì cả. Câu hỏi trên thì dính dáng gì đến OOP? Khi xưa thi môn này HM cũng gặp những câu hỏi khiến người ta có cảm giác đây là môn “Lập trình OOP, Java, và C++ cóp nhặt”.</p>
<p>Theo ý kiến của HM (và HM không phải là giáo viên), một môn Lập trình hướng đối tượng nếu được dạy, cần phải thể hiện được:</p>
<ul>
<li>OOP là một <a href="http://nmhblog.wordpress.com/2010/11/17/paradigm-v-ngn-ng%e1%bb%af-l%e1%ba%adp-trnh/" target="_blank">paradigm</a>, các ngôn ngữ chỉ là implementation.</li>
<li>Các khái niệm về <a href="http://nmhblog.wordpress.com/2010/05/09/bao-dng/" target="_blank">encapsulation</a>, inheritance, <a href="http://nmhblog.wordpress.com/2011/02/17/tm-l%e1%ba%a1i-polymorphism-trong-oop-l-g-nh%e1%bb%89/" target="_blank">polymorphism</a>, overriding, v.v</li>
<li>Giới thiệu qua về các implementation khác nhau cho những khái niệm trên.</li>
<li>Các nguyên lí khi thiết kế hướng đối tượng, và một dự án lớn áp dụng được nhiều nguyên lí này thì rất tuyệt. Tuyệt hơn nữa nếu nó sử dụng lại bài tập lớn của môn học trước dành cho sinh viên mới, vì nó sẽ tạo ra sự đối chiếu. Môn Lập trình hướng đối tượng khi HM học không dạy cái này, và cũng chỉ đưa ra các bài thực hành dạng copy-paste, chạy có thể được có thể không, và hoàn toàn không minh họa gì cho các nguyên lí OOP.</li>
</ul>
<p>Thực sự cảm thấy rất tiếc.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/'>lập trình hướng đối tượng</a>, <a href='http://nmhblog.wordpress.com/tag/linh-tinh/'>linh tinh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/563/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/563/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/563/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=563&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/12/01/mn-l%e1%ba%adp-trnh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Cohesion v&#224; Coupling</title>
		<link>http://nmhblog.wordpress.com/2010/11/29/cohesion-v-coupling/</link>
		<comments>http://nmhblog.wordpress.com/2010/11/29/cohesion-v-coupling/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 04:20:46 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/11/29/cohesion-v-coupling/</guid>
		<description><![CDATA[Khi học môn Công nghệ phần mềm, cohesion và coupling là hai khái niệm mà HM đôi khi cảm thấy hơi lẫn lộn. Hi vọng bài viết này sẽ phần nào giúp những người cùng cảnh ngộ phân biệt chúng rõ ràng hơn. Trước hết, hãy nói về nguyên tắc chung khi thiết kế chương [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=512&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Khi học môn Công nghệ phần mềm, cohesion và coupling là hai khái niệm mà HM đôi khi cảm thấy hơi lẫn lộn. Hi vọng bài viết này sẽ phần nào giúp những người cùng cảnh ngộ phân biệt chúng rõ ràng hơn.</p>
<p>Trước hết, hãy nói về nguyên tắc chung khi thiết kế chương trình:</p>
<ol>
<li>Giữ những thứ phải thay đổi cùng nhau ở thật gần nhau. Chẳng hạn khi thay đổi về thiết kế ở class A luôn kéo theo thay đổi ở B, thì nên cho A và B vào cùng một module.</li>
<li>Cho phép những thứ không liên quan thay đổi một cách độc lập với nhau (nói cho có vẻ “chuyên ngành” là orthogonal). Ví dụ không có lí do gì để sửa đổi class Person khi class Money bị sửa đổi.</li>
</ol>
<p>Từ hai nguyên tắc này có thể đẻ ra cả tá nguyên tắc và khái niệm cụ thể hơn, mà trong đó có cohesion và coupling. Tuy nhiên, nếu nắm vững hai nguyên tắc trên thì trong trường hợp không biết về các khái niệm khác, bạn vẫn có thể nhận ra những bất thường trong thiết kế.</p>
<p>Vậy cohesion là gì? Khi nói đến cohesion chúng ta nghĩ đến nhiệm vụ của từng module. Nhiệm vụ của từng module càng rõ ràng và tách biệt thì cohesion càng cao (high cohesion), và đó là mục tiêu cần đạt tới khi thiết kế. Giải thích bằng code có lẽ sẽ không rõ ràng bằng <a href="http://vneconomy.vn/20100519102635734P0C9920/an-toan-thuc-pham-bo-nao-trang-trai-bo-nao-ban-an.htm" target="_blank">bài viết này</a>:</p>
<blockquote><p>Tại kỳ họp Quốc hội thứ năm, khi thảo luận về quản lý chất lượng vệ sinh an toàn thực phẩm có vị đại biểu Quốc hội đã ví việc có tới 5 bộ chịu trách nhiệm chính như vậy cũng giống như “nhiều sãi không ai đóng cửa chùa”.     <br />Bởi thế, làm rõ trách nhiệm của từng cơ quan quản lý Nhà nước về an toàn thực phẩm là một yêu cầu được nhấn mạnh khi xây dựng dự Luật An toàn thực phẩm.</p>
</blockquote>
<p>Thực ra không có một phương pháp tuyệt đối để xác định những nhiệm vụ nào thì được coi là liên quan và nên được xếp vào cũng một module, hay những nhiệm vụ nào là không phù hợp với một module nào đó. Tuy nhiên, có một cách rất hữu dụng, là kiểm tra tên của một class hay method. Nếu bạn không thể kiếm một cái tên phù hợp cho class, bạn nên kiểm tra xem nhiệm vụ của module tương ứng đã được định nghĩa rõ ràng chưa. Cũng vậy, nếu tên của một method có từ and hoặc chứa hai hành động trở lên, thì bạn nên xem xét phân tách method thành nhiều method nhỏ hơn. Về các lời khuyên liên quan đến cách đặt tên, xem thêm Code complete.</p>
<p>Tiếp theo là coupling. Coupling là khái niệm chỉ độ phụ thuộc giữa các module với nhau khi thực hiện một chức năng nào đó. Cũng như cohesion, coupling được chia làm nhiều cấp độ, và một thiết kế tốt sẽ cho coupling thấp (loose coupling). Thế nào là phụ thuộc? Đó là khi một module khi hoạt động phải hiểu biết về chức năng và cách hoạt động của các module khác. Chẳng hạn, khi một class dùng chung một vùng nhớ (một object chẳng hạn) với class khác, thì class này phải hiểu rõ class kia sẽ làm gì với vùng nhớ chung đó, và vậy là có coupling giữa hai class. Có rất nhiều dạng coupling, có dạng chấp nhận được, có dạng nên hạn chế, bạn có thể xem thêm trong Code complete.</p>
<p>Lí do phải giảm coupling là vì nếu nhiều module couple chặt với nhau, thì khi bạn thiết kế lại một module, bạn sẽ phải kiểm tra tất cả các module còn lại, và coupling càng chặt thì khả năng các module còn lại này bị thay đổi càng cao. Ngoài ra, có một số dạng coupling ngầm tương đối khó nhận ra, điều này sẽ làm cho việc thay đổi càng khó khăn hơn. Bạn có thể liên hệ với thủ tục hành chính. Nếu người dân phải đi qua nhiều bước thủ tục thì khi các bước này bị thay đổi, người ta phải tuyên truyền lại cho nhiều chục triệu người dân lẫn nhân viên hành chính. Nếu các bước thủ tục này được encapsulate lại thành một bước duy nhất (“một cửa”) thì người ta chỉ phải đến, đưa hồ sơ (“input”) và lấy kết quả (“output”). Thay đổi về thủ tục bây giờ chỉ đòi hỏi đào tạo lại các nhân viên bên trong.</p>
<p>Bạn có thể thấy cohesion và coupling phần nào phản ánh hai nguyên tắc ban đầu.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh/'>lập trình</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/512/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=512&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/11/29/cohesion-v-coupling/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Khác nhau giữa kiến trúc phân lớp (layered) và kiến trúc n-tier</title>
		<link>http://nmhblog.wordpress.com/2010/11/21/khc-nhau-gi%e1%bb%afa-ki%e1%ba%bfn-trc-phn-l%e1%bb%9bp-layered-v-ki%e1%ba%bfn-trc-n-tier/</link>
		<comments>http://nmhblog.wordpress.com/2010/11/21/khc-nhau-gi%e1%bb%afa-ki%e1%ba%bfn-trc-phn-l%e1%bb%9bp-layered-v-ki%e1%ba%bfn-trc-n-tier/#comments</comments>
		<pubDate>Sun, 21 Nov 2010 04:17:38 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/11/23/khc-nhau-gi%e1%bb%afa-ki%e1%ba%bfn-trc-phn-l%e1%bb%9bp-layered-v-ki%e1%ba%bfn-trc-n-tier/</guid>
		<description><![CDATA[(Cập nhật: Chuyển tới đọc bài này thay vì đọc tiếp phần ở dưới.) HM thấy trên mạng có một số người hỏi về kiến trúc phân lớp (layered) và kiến trúc n-tier. Cũng như nhiều khái niệm khác, nếu tỉ mỉ đi vào chi tiết thì chắc không có định nghĩa thống nhất, tuy [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=444&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>(Cập nhật: Chuyển tới đọc <a href="http://namdh.wordpress.com/2009/12/31/3-tiers-faq/">bài này</a> thay vì đọc tiếp phần ở dưới.)</p>
<p>HM thấy trên mạng có một số người hỏi về kiến trúc phân lớp (layered) và kiến trúc n-tier. Cũng như nhiều khái niệm khác, nếu tỉ mỉ đi vào chi tiết thì chắc không có định nghĩa thống nhất, tuy nhiên nếu để nắm ý tưởng chung, thì có lẽ tốt nhất là xem &quot;Microsoft application architecture guide&quot; (Microsoft viết mà sai thì chịu thôi <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ). Tải miễn phí tại Microsoft, hoặc đọc trong mục patterns &amp; practices của MSDN. Dưới đây tóm lược các ý chính:</p>
<p>Kiến trúc phân lớp nhóm các chức năng liên quan đến nhau trong từng lớp (layer). Các chức năng ở một lớp khi làm nhiệm vụ của mình có thể sử dụng các chức năng mà lớp dưới nó cung cấp. Có hai dạng</p>
<ul>
<li>Strict layering: Lớp trên chỉ liên hệ với lớp ở ngay dưới nó. </li>
<li>Relaxed layering: Lớp trên có thể liên hệ với nhiều lớp dưới nó. </li>
</ul>
<p>Khi nói về kiến trúc phân lớp, chúng ta nói về cách tổ chức luận lí của code, ví dụ thông qua các package, namespace, module, v.v. Không hề có gì gợi ý rằng các lớp phải chạy trên các máy khác nhau, hay thậm chí trong các process khác nhau.</p>
<p>Tier là nơi các lớp chạy. Các tier phải tách biệt với nhau về memory space. Nhưng cũng không có nghĩa là các tier phải chạy trên các máy khác nhau. Trong hệ điều hành, các process tách biệt với nhau về memory space, cho nên nếu bạn có một chương trình với hai lớp Presentation và Business Services chạy trên hai process giao tiếp với nhau dùng Web services thì bạn cũng đã có một hệ thống 2-tier rồi.</p>
<p>Các lớp có thể ở cùng một một tier, hoặc được phân tán trên nhiều tier (n-tier). Vậy một tier có thể có nhiều lớp. Tuy nhiên, thông thường với các hệ thống lớn, các tier sẽ không ở trên cùng một máy vật lí, vì các lí do về performance, scalability, fault tolerance, security v.v.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh/'>lập trình</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/444/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=444&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/11/21/khc-nhau-gi%e1%bb%afa-ki%e1%ba%bfn-trc-phn-l%e1%bb%9bp-layered-v-ki%e1%ba%bfn-trc-n-tier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Khác biệt giữa Parallel.ForEach() và ParallelEnumerable.ForAll() trong .NET framework</title>
		<link>http://nmhblog.wordpress.com/2010/11/19/khc-bi%e1%bb%87t-gi%e1%bb%afa-parallel-foreach-v-parallelenumerable-forall-trong-c/</link>
		<comments>http://nmhblog.wordpress.com/2010/11/19/khc-bi%e1%bb%87t-gi%e1%bb%afa-parallel-foreach-v-parallelenumerable-forall-trong-c/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 11:40:58 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/11/19/khc-bi%e1%bb%87t-gi%e1%bb%afa-parallel-foreach-v-parallelenumerable-forall-trong-c/</guid>
		<description><![CDATA[Parallel.ForEach() là một static method cho phép thực hiện song song các thao tác trên một Enumerable object. ParallelEnumerable.ForAll() là một extension method cho phép thực hiện song song các thao tác trên một Enumerable object do một câu truy vấn tạo ra (hơi khó giải thích). Tuy nhiên, không chỉ khác biệt về cách [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=443&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Parallel.ForEach() là một static method cho phép thực hiện song song các thao tác trên một Enumerable object. ParallelEnumerable.ForAll() là một extension method cho phép thực hiện song song các thao tác trên một Enumerable object do một câu truy vấn tạo ra (hơi khó giải thích). Tuy nhiên, không chỉ khác biệt về cách sử dụng, chúng cũng có khác biệt về performance nói chung.</p>
<p>Giả sử bạn gặp tình huống xử lí trên một biến data kiểu Enumerable như sau:</p>
<p>var q = from d in data … select d;   <br />foreach (var item in q) { doSomething(item); }</p>
<p>Nếu bạn muốn câu truy vấn q chạy ở chế độ song song (chẳng hạn, khi bạn có nhiều core và muốn tận dụng chúng) bạn dùng ParallelEnumerable.AsParallel():</p>
<p>var q = from d in data.AsParallel() … select d;   <br />foreach (var item in q) { doSomething(item); }</p>
<p>Và nếu hàm doSomething() không quan tâm đến thứ tự xử lí của item (tức là gọi doSomething với item nào trước thì kết quả cũng ra như nhau) thì bạn cũng có thể chạy foreach ở chế độ song song:</p>
<p>var q = from d in data.AsParallel() … select d;   <br />Parallel.ForEach(q, item =&gt; { doSomething(item) });</p>
<p>Nhưng bạn cũng có thể dùng ForAll với câu truy vấn q để đạt hiệu quả tương tự:</p>
<p>var q = (from d in data.AsParallel() … select d);   <br />q.ForAll(item =&gt; { doSomething(item) });</p>
<p>Nhìn hai đoạn code cuối ta có cảm giác performance của chúng giống nhau, nhưng thực ra không phải như vậy. Tạm gọi đoạn code dùng Parallel.ForEach() là đoạn code (1) và đoạn code dùng ParallelEnumerable.ForAll() là đoạn code (2).</p>
<p>Các công việc mà đoạn code (1) thực hiện (không hoàn toàn chính xác trên thực tế, nhưng đủ để cho thấy sự khác biệt) là:</p>
<ul>
<li>Chạy câu truy vấn:</li>
<ul>
<li>Phân hoạch data ra thành nhiều phần (để chạy song song).</li>
<li>Chạy câu truy vấn trên từng data, tạm gọi kết quả là q1, q2, q3, v.v.</li>
<li>Trộn q1, q2, q3, v.v lại thành Enumerable object q.</li>
</ul>
<li>Chạy Parallel.ForEach():</li>
<ul>
<li>Phân hoạch q ra thành nhiều phần (để chạy song song).</li>
<li>Gọi doSomething();</li>
</ul>
</ul>
<p>Sơ đồ minh họa cho đoạn code (1).</p>
<p><a href="http://nmhblog.files.wordpress.com/2010/11/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://nmhblog.files.wordpress.com/2010/11/image_thumb.png?w=516&#038;h=160" width="516" height="160" /></a></p>
<p>Đoạn code (1) lãng phí ở chỗ đầu tiên ta trộn các q1, q2, q3, v.v lại thành q, sau đó lại phân hoạch q ra. Sẽ tốt hơn nếu sau khi phân hoạch data, câu truy vấn được chạy, và các item lấy ra sẽ được cho vào doSomething() luôn. Nói cách khác doSomething() trở thành một phần trong hoạt động của câu truy vấn. Đó chính là cách mà đoạn code (2) thi hành. Dưới đây là sơ đồ minh họa cho đoạn code (2):</p>
<p><a href="http://nmhblog.files.wordpress.com/2010/11/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://nmhblog.files.wordpress.com/2010/11/image_thumb1.png?w=297&#038;h=160" width="297" height="160" /></a></p>
<p>Đó là lí do lại sao đoạn code (2) cho performance tốt hơn, và được khuyên dùng trong những tình huống tương tự.</p>
<p>Nếu muốn tìm hiểu thêm về Parallel trong C#, bạn có thể đọc <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=86b3d32b-ad26-4bb8-a3ae-c1637026c3ee&amp;displaylang=en" target="_blank">Paterns of Parallel Programming</a> (sách miễn phí từ Microsoft).</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/net/'>.NET</a>, <a href='http://nmhblog.wordpress.com/tag/c/'>C#</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/443/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=443&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/11/19/khc-bi%e1%bb%87t-gi%e1%bb%afa-parallel-foreach-v-parallelenumerable-forall-trong-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>

		<media:content url="http://nmhblog.files.wordpress.com/2010/11/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://nmhblog.files.wordpress.com/2010/11/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Paradigm và ngôn ngữ lập trình</title>
		<link>http://nmhblog.wordpress.com/2010/11/17/paradigm-v-ngn-ng%e1%bb%af-l%e1%ba%adp-trnh/</link>
		<comments>http://nmhblog.wordpress.com/2010/11/17/paradigm-v-ngn-ng%e1%bb%af-l%e1%ba%adp-trnh/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 12:24:42 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình]]></category>
		<category><![CDATA[lập trình hàm]]></category>
		<category><![CDATA[lập trình hướng đối tượng]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/11/17/paradigm-v-ngn-ng%e1%bb%af-l%e1%ba%adp-trnh/</guid>
		<description><![CDATA[Trước đây, đa phần lập trình viên bình thường chủ yếu làm việc với lập trình hướng đối tượng, thì sự khác biệt giữa paradigm và ngôn ngữ lập trình không thật quan trọng. Tuy nhiên, khi mà lập trình hàm (functional programming) đang ngày một thu hút nhiều sự chú ý, thì việc hiểu [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=437&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Trước đây, đa phần lập trình viên bình thường chủ yếu làm việc với lập trình hướng đối tượng, thì sự khác biệt giữa paradigm và ngôn ngữ lập trình không thật quan trọng. Tuy nhiên, khi mà lập trình hàm (functional programming) đang ngày một thu hút nhiều sự chú ý, thì việc hiểu rõ sự khác biệt này là khá cần thiết.</p>
<p>Trước hết, bạn thử suy nghĩ, tại sao Java không giống C#, mà người ta lại dạy bạn là hai ngôn ngữ này đều là lập trình hướng đối tượng? Nếu bạn gặp thêm một ngôn ngữ X nào đó, làm sao bạn biết nó có hướng đối tượng? Hay nếu bạn vô tình đọc phải một cuốn như <a href="http://www.planetpdf.com/codecuts/pdfs/ooc.pdf" target="_blank">Object Oriented Programming With ANSI-C</a>, bạn có dám nói C là một ngôn ngữ lập trình hướng đối tượng không?</p>
<p>Để trả lời những câu hỏi này, bạn phải hiểu lập trình hướng đối tượng là một paradigm. Paradigm định nghĩa các khái niệm mà chúng ta sẽ dùng để suy nghĩ về một vấn đề nào đó. Một số ngôn ngữ nào đó có thể cung cấp các tính năng cho phép chúng ta ứng dụng paradigm đó để hiện thực một cách dễ dàng, nhưng paradigm không bao giờ quy định cụ thể tính năng đó là gì, cú pháp ra sao, v.v. Chẳng hạn, paradigm cho lập trình hướng đối tượng nêu lên khái niệm encapsulation. Java dùng các modifier như public, private. Những người phát triển C# cho rằng <a href="http://en.wikipedia.org/wiki/Property_(programming)" target="_blank">property</a> giúp tăng cường tính encapsulation, và họ đưa property vào những ngôn ngữ này. Những người phát triển Python lại lập luận rằng encapsulation không phải nhiệm vụ của trình dịch, nên trong Python không có cơ chế tạo private method, người ta ngầm quy ước method bắt đầu với “__” là private. Và cả Java, C#, Python đều được người phát triển chúng tuyên bố là có hỗ trợ lập trình hướng đối tượng. Nếu bạn hiểu encapsulation, bạn sẽ việc được code thỏa mãn tương đối tính chất này ở cả ba ngôn ngữ, nhưng nếu bạn chỉ học ngôn ngữ thôi, <a href="http://nmhblog.wordpress.com/2010/05/09/bao-dng/" target="_blank">có thể code của bạn sẽ không có tính encapsulation</a>. Hiểu một paradigm không chỉ giúp bạn khi sử dụng một ngôn ngữ được cho là hỗ trợ nó, mà bạn có thể áp dụng những khái niệm hay từ nó cho các ngôn ngữ khác, để làm cho code của bạn có chất lượng cao hơn (bạn thử nghĩ làm thể nào để tăng encapsulation trong C).</p>
<p>Cần chú ý là trong khi một ngôn ngữ có thể tốt hơn một ngôn ngữ khác, như C# 3.0 so với C# 2.0 (mặc dù so sánh này chỉ là tương đối), bạn không thể so sánh paradigm này có tốt hơn paradigm khác không. Mỗi paradigm đều thích hợp trong một số tình huống, và không thích hợp trong những tình huống khác. Ví dụ, paradigm lập trình hàm cổ vũ cho việc sử dụng immutable object, nhưng không phải mọi bài toán đều giải quyết được chỉ dùng immutable object. Hiểu rõ các paradigm sẽ giúp bạn không áp dụng chúng một cách cứng nhắc, nhờ đó lời giải của bạn cho các vấn đề sẽ trở nên uyển chuyển, hiệu quả hơn (<a href="http://www.objectmentor.com/resources/articles/xpepisode.htm" target="_blank">ví dụ này</a> có vẻ hợp). Cũng bởi vì không có paradigm nào là tốt nhất, các ngôn ngữ lập trình hiện đại thường đều ở dạng multiparadigm, trong đó có thể có một paradigm là chủ đạo. Muốn tận dụng tốt nhất các tính năng mà những ngôn ngữ này cung cấp, bạn phải hiểu thế mạnh của các paradigm và nhìn ra những tình huống ứng dụng chúng.</p>
<p>Cuối cùng, cũng như nhiều khái niệm khác như khoa học máy tính và kĩ thuật máy tính, <a href="http://nmhblog.wordpress.com/2010/08/04/staticdynamic-typing-v-strongweak-typing/" target="_blank">strong typing và weak typing</a>, các paradigm nói chung cũng được định nghĩa một cách tương đối hoặc trừu tượng. Cho nên có thể đôi khi bạn sẽ băn khoăn liệu paradigm này có phải là hệ quả hay là một cách phát biểu khác của paradigm kia, v.v. Trong trường hợp này có lẽ tốt nhất là khỏi phải suy nghĩ nhiều làm gì cho mệt <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> , thế giới định nghĩa sao ta chấp nhận thế. Điều quan trọng khi tìm hiểu một paradigm là phải ghi nhớ những khái niệm quan trọng nhất mà nó cổ vũ, và nếu có thể thì học một ngôn ngữ được cho là đại diện cho nó. Như thế, khi đã thành thạo, cho dù bạn không thể định nghĩa paradigm này, bạn vẫn có thể rút ra được những phương pháp và kinh nghiệm hay cho việc lập trình. Có thể xem như paradigm tác động tới thiết kế của các ngôn ngữ, và ngược lại các ngôn ngữ góp phần định nghĩa nên paradigm.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh/'>lập trình</a>, <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh-ham/'>lập trình hàm</a>, <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/'>lập trình hướng đối tượng</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/437/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=437&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/11/17/paradigm-v-ngn-ng%e1%bb%af-l%e1%ba%adp-trnh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Dùng Maven với project nhiều module</title>
		<link>http://nmhblog.wordpress.com/2010/10/18/dng-maven-v%e1%bb%9bi-project-nhi%e1%bb%81u-module/</link>
		<comments>http://nmhblog.wordpress.com/2010/10/18/dng-maven-v%e1%bb%9bi-project-nhi%e1%bb%81u-module/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 16:41:52 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/10/18/dng-maven-v%e1%bb%9bi-project-nhi%e1%bb%81u-module/</guid>
		<description><![CDATA[Nếu bạn đã dùng m2eclípe (Maven plugin cho Eclipse) thì sẽ thấy nó khá bất tiện khi làm việc với project nhiều module. Vì vậy, trong trường hợp này, chạy Maven từ dòng lệnh là hợp lí hơn cả. Bài viết này sẽ giới thiệu một số lệnh Maven phù hợp cho tình huống này [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=384&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Nếu bạn đã dùng m2eclípe (Maven plugin cho Eclipse) thì sẽ thấy nó khá bất tiện khi làm việc với project nhiều module. Vì vậy, trong trường hợp này, chạy Maven từ dòng lệnh là hợp lí hơn cả. Bài viết này sẽ giới thiệu một số lệnh Maven phù hợp cho tình huống này (chính xác hơn là các option của lệnh mvn). Những option này được thêm vào từ Maven 2.1, bao gồm:</p>
<ul>
<li>&#8211;projects: Làm việc với một vài module nhất định, chứ không phải toàn bộ project </li>
<li>&#8211;also-make: Build các project mà module cần build (được chỉ ra bằng –projects) phụ thuộc </li>
<li>&#8211;also-make-dependents: Build các project phụ thuộc vào module cần build (được chỉ ra bằng –projects). </li>
</ul>
<p>Điểm tiện dụng của các option này là ta sẽ làm việc từ thư mục gốc của project, không cần phải chuyển vào từng module.</p>
<p>Giả sử ta có project A với các module như sau:</p>
<pre>A
|_B
|_C -&gt; B</pre>
<p>(module C phụ thuộc module B).</p>
<p>Nếu bạn chưa install module B, các lệnh compile, test với C sẽ báo lỗi. Để test (hoặc compile) C một cách suôn sẻ, bạn dùng lệnh sau:</p>
<p>mvn –projects C test –also-make</p>
<p>Tất nhiên nếu module B đã ổn định, thì bạn nên install nó trước, bởi vì lệnh trên sẽ chạy test với cả module B. Để install module B, bạn dùng lệnh sau:</p>
<p>mvn –projects B install</p>
<p>Bây giờ khi làm việc với C, bạn không cần –also-make nữa. Không rõ vì sao mà ngay cả khi install B, thì HM vẫn không thể compile C được, vì java không resolve được các dependency(!). Thêm một lí do để dùng Maven từ dòng lệnh.</p>
<p>Và nếu bạn chính sửa gì đó ở module B, và muốn install lại, cùng với module C (để test, để kiểm tra xem bạn có break API của B không, v.v), bạn dùng lệnh sau:</p>
<p>mvn –project B install –also-make-dependents</p>
<p>Cuối cùng, nếu bạn muốn làm việc với nhiều module, chỉ cần phân tách giữa các module với dấu “,”:</p>
<p>mvn –project B,C</p>
<p>Gọn đẹp hơn dùng Eclipse, đúng không nào <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/maven/'>Maven</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/384/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=384&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/10/18/dng-maven-v%e1%bb%9bi-project-nhi%e1%bb%81u-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Event trong C#</title>
		<link>http://nmhblog.wordpress.com/2010/10/04/linh-tinh-v%e1%bb%81-event-trong-c/</link>
		<comments>http://nmhblog.wordpress.com/2010/10/04/linh-tinh-v%e1%bb%81-event-trong-c/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 10:23:48 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/10/04/linh-tinh-v%e1%bb%81-event-trong-c/</guid>
		<description><![CDATA[Khai báo Dưới đây là các bước tạo một event. Xem thêm chi tiết ở đây. Nếu bạn dùng Generics, bạn không cần phải tự tạo delegate: Nếu bạn không cần một class EventArgs riêng, bạn không phải tạo CustomEventArgs: Raise event Cần chú ý là bạn nên tách phần code để raise event ra [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=382&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Khai báo</strong></p>
<p>Dưới đây là các bước tạo một event. Xem thêm chi tiết <a href="http://msdn.microsoft.com/en-us/library/w369ty8x.aspx" target="_blank">ở đây</a></a>.</p>
<p><pre class="brush: csharp;">public class CustomEventArgs: EventArgs {…} 
public delegate void CustomEventHandler(object sender, CustomEventArgs a); 
public event CustomEventHandler RaiseCustomEvent;</pre></p>
<p>Nếu bạn dùng Generics, bạn không cần phải tự tạo delegate:</p>
<p><pre class="brush: csharp;">public class CustomEventArgs: EventArgs {…} 
public event EventHandler&lt;CustomEventArgs&gt; RaiseCustomEvent;</pre></p>
<p>Nếu bạn không cần một class EventArgs riêng, bạn không phải tạo CustomEventArgs:</p>
<p><pre class="brush: csharp;">public event EventHandler&lt;EventArgs&gt; RaiseCustomEvent;</pre></p>
<p><strong>Raise event</strong></p>
<p>Cần chú ý là bạn nên tách phần code để raise event ra khỏi phần code kiểm tra điều kiện và tạo EventArgs, vì bạn sẽ thấy tiếp theo đây, raise event đòi hỏi một số thao tác linh tinh có thể làm code của bạn rối rắm hơn:</p>
<p><pre class="brush: csharp;">void OnRaiseCustomEvent(CustomEventArgs e) { 
  if (RaiseCustomEvent != null) { 
    RaiseCustomEvent(this, e); 
  } 
}</pre></p>
<p>Tại sao phải kiểm tra null? Vì nếu RaiseCustomEvent là null, tức là chưa có ai subscribe, lệnh raise event sẽ throw Exception.</p>
<p>Vẫn còn một vấn đề nữa. Trong một chương trình multithread, rất có khả năng một object nào đó sẽ hủy subscribe trước khi raise event, nhưng sau khi phép kiểm tra null xảy ra. Nếu việc hủy subscribe này làm cho event thành null, bạn hiểu điều gì sẽ xảy ra. Do đó, bạn phải tạo một bản copy cho event cần raise:</p>
<p><pre class="brush: csharp;">var handler = RaiseCustomEvent; 
if (handler != null) …</pre></p>
<p>Bây giờ thì dù RaiseCustomEvent có thay đổi thế nào, handler event cũng không bị ảnh hưởng. Tại sao một phép copy lại làm được điều đó? C# copy reference chứ không copy value mà? Nếu bạn quan tâm, xin mời đọc tiếp. Nếu không, hãy an tâm như thế là đủ.</p>
<p>Rườm rà? Bạn không thích lặp lại đoạn mã này với tất cả các event, chẳng hạn khi bạn có quá nhiều event (Custom1, Custom2, v.v)? Có thể dùng extension method để làm cho code gọn đẹp hơn nữa, nhưng hẹn bài khác <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p><strong>Vì sao vừa có event, vừa có delegate</strong></p>
<p>Để ý rằng, với delegate, chúng ta cũng có các toán tử +=, –=, và cũng invoke được các delegate đã add, tương tự như event. Vậy tại sao chúng ta lại phải tạo event mà không dùng luôn delegate? Bởi vì nếu dùng delegate, sẽ có hai tình huống không mong đợi sau:</p>
<ul>
<li>Subscriber override các subscriber khác bằng toán tử =. Chẳng hạn, một cách vô tình, lệnh subscribe được viết là … = … Kết quả là tất cả các delegate đã add vào CustomEventHandler trước đó sẽ bị xóa. </li>
<li>Subscriber có thể raise event bằng cách gọi delegate. Trong khi việc này lẽ ra chỉ nên được thực hiện bởi publisher. </li>
</ul>
<p>Event thực chất được xây dựng dựa trên delegate, nhưng không cho phép các tình huống trên xảy ra. Khi khai báo một event, trình dịch sẽ ngầm tạo cho chúng ta một biến delegate private trong chính class chứa event. Lưu ý là event là một khái niệm ở mức CIL, vì vậy nó không đơn thuần chỉ là một wrapper cho delegate. Bạn có thể tham khảo đoạn mã dưới đây (từ quyển Essential C# 4.0), mô tả một cách sơ lược những gì trình dịch sẽ làm.</p>
<p><pre class="brush: csharp;">public delegate void CustomEventHandler(object sender, CustomEventArgs a);

private CustomEventHandler customEventHandler;

public void add_CustomEventHandler(CustomEventHandler handler) { 
  System.Delegate.Combine(customEventHandler, handler); 
}

public void remove_CustomEventHandler(CustomEventHandler handler) { 
  System.Delegate.Remove(customEventHandler, handler); 
}

public event CustomEventHandler customEventHandler { 
  add { add_customEventHandler(value) } 
  remove { remove_customEventHandler(value) } 
}</pre></p>
<p><strong>Và delegate là một immutable type</strong></p>
<p>Để dễ hiểu, hãy xét kiểu string, cũng immutable, và cũng hỗ trợ toán tử += như delegate:</p>
<p><pre class="brush: csharp;">string s1 = &quot;old&quot;; 
string s2 = s1; 
s1 += “new”;</pre></p>
<p>s2 vẫn sẽ là “old”, vì khi gán s1 += “new”, một chuỗi mới sẽ được tạo ra với giá trị là “oldnew”, và s1 sẽ trỏ sang chuỗi mới đó. Chuỗi s2, tất nhiên vẫn trỏ tới chuỗi cũ. Bây giờ xem lại phần copy trong raise event, bạn sẽ thấy vấn đề hoàn toàn sáng tỏ.</p>
<p>(Xóa phần immutable object, vì HM muốn viết nó thành một bài riêng)</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/c/'>C#</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/382/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=382&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/10/04/linh-tinh-v%e1%bb%81-event-trong-c/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Linh tinh về dynamic trong C#</title>
		<link>http://nmhblog.wordpress.com/2010/10/02/linh-tinh-v%e1%bb%81-dynamic-trong-c/</link>
		<comments>http://nmhblog.wordpress.com/2010/10/02/linh-tinh-v%e1%bb%81-dynamic-trong-c/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 10:09:50 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/10/02/linh-tinh-v%e1%bb%81-dynamic-trong-c/</guid>
		<description><![CDATA[Dưới đây là vài điểm đáng chú ý liên quan đến kiểu dynamic trong C# được trình bày trong buổi thảo luận với hai developer của Microsoft, theo trình tự thời gian. Ở đây không nói đến hiện thực bên trong, vì HM không nắm rõ. Lí do khiến dynamic được đưa vào C# là [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=381&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Dưới đây là vài điểm đáng chú ý liên quan đến kiểu dynamic trong C# được trình bày trong <a href="http://channel9.msdn.com/blogs/charliecalvert/csharp-4-dynamic-with-chris-burrows-and-sam-ng" target="_blank">buổi thảo luận với hai developer của Microsoft</a>, theo trình tự thời gian. Ở đây không nói đến hiện thực bên trong, vì HM không nắm rõ.</p>
<ul>
<li>Lí do khiến dynamic được đưa vào C# là để làm việc với COM (chú ý là cả COM cũng phải được “tân trang” thì mới tận dụng được dynamic), và các ngôn ngữ dynamic như Ruby, Python được đơn giản hơn. Các ứng dụng phát sinh thêm như <a href="http://nmhblog.wordpress.com/2010/09/28/c-nn-dng-dynamicxml-lm-v-d%e1%bb%a5-cho-dynamic-trong-c/" target="_blank">ở đây</a> không phải là lí do chính thức. </li>
<li>dynamic là một built-in type như int và float, chứ không phải một syntax mới. Các biến dynamic cũng là object. Với các biến kiểu dynamic, trình biên dịch C# sẽ không thực hiện kiểm tra kiểu lúc biên dịch mà chỉ đóng gói các thông tin cần thiết để phân giải lúc runtime lời gọi các method của dynamic object. Lí do đằng sau thiết kế này là Microsoft không muốn thay đổi tính chất static typing của C#, và cũng không muốn lập trình viên dùng dynamic một cách không có chủ ý. </li>
<li>dynamic là một <a href="http://msdn.microsoft.com/en-us/library/x53a06bb.aspx">contextual keyword</a> (bạn thử khai báo int dynamic = 1; xem). </li>
<li>dynamic dùng các dịch vụ của Dynamic Language Runtime (DLR). DLR là thư viện (chứ không phải runtime như CLR, mặc dù tên gọi có từ “runtime”) cung cấp các dịch vụ cần thiết khi xây dựng các ngôn ngữ dynamic trên nền .NET. Có thể coi dynamic là syntactic sugar để sử dụng DLR trong C#. Khi các ngôn ngữ dynamic trên nền .NET sử dụng DLR, việc cộng tác với nhau sẽ đơn giản hơn. </li>
<li>Dynamic object expose các method, property vào lúc runtime, nói cách khác, nó có thể tự dispatch thông điệp gửi đến nó. Khi gán một object cho biến kiểu dynamic, trình dịch wrap các object này vào các dynamic object. </li>
<li>Lập trình viên C# có thể lựa chọn dùng hoặc không dùng dynamic khi làm việc với COM và các ngôn ngữ dynamic. Điều này phụ thuộc vào sở thích. </li>
</ul>
<p>Tham khảo blog của hai lập trình viên này <a href="http://blogs.msdn.com/b/cburrows/archive/tags/dynamic/">ở đây</a> và <a href="http://blogs.msdn.com/b/samng/archive/tags/dynamic/">ở đây</a> nếu muốn biết sâu hơn về dynamic (có thể dùng thay thuốc ngủ <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ).</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/c/'>C#</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/381/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=381&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/10/02/linh-tinh-v%e1%bb%81-dynamic-trong-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Một ứng dụng của dynamic trong C#</title>
		<link>http://nmhblog.wordpress.com/2010/09/28/c-nn-dng-dynamicxml-lm-v-d%e1%bb%a5-cho-dynamic-trong-c/</link>
		<comments>http://nmhblog.wordpress.com/2010/09/28/c-nn-dng-dynamicxml-lm-v-d%e1%bb%a5-cho-dynamic-trong-c/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 03:21:05 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/09/28/c-nn-dng-dynamicxml-lm-v-d%e1%bb%a5-cho-dynamic-trong-c/</guid>
		<description><![CDATA[Với dynamic type được giới thiệu ở phiên bản 4.0, C# giờ đây đã hỗ trợ dynamic typing. Các bạn có thể xem một số ví dụ tại MSDN. Cách dùng thì đơn giản rồi, điều quan trọng là khi nào thì dùng dynamic? Xem bài này nếu bạn quan tâm đến lí do chính [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=380&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Với dynamic type được giới thiệu ở phiên bản 4.0, C# giờ đây đã hỗ trợ <a href="http://nmhblog.wordpress.com/2010/08/04/staticdynamic-typing-v-strongweak-typing/" target="_blank">dynamic typing</a>. Các bạn có thể xem một số ví dụ <a href="http://msdn.microsoft.com/en-us/library/dd264741.aspx" target="_blank">tại MSDN</a>.</p>
<p>Cách dùng thì đơn giản rồi, điều quan trọng là khi nào thì dùng dynamic? Xem <a href="http://nmhblog.wordpress.com/2010/10/02/linh-tinh-v%e1%bb%81-dynamic-trong-c/">bài này</a> nếu bạn quan tâm đến lí do chính thức mà Microsoft đưa dynamic vào C#. Ở đây chỉ nói về một ví dụ rất đơn giản mà các sách hay dùng.</p>
<p>Static typing giúp phát hiện các lỗi về method signature (ví dụ, trình dịch sẽ bắt lỗi khi bạn truyền thiếu tham số), type compability (ví dụ, bạn không thể gán object kiểu Book cho biến kiểu Car được). Hơn nữa, Intellisense (chức năng nhắc mã trong IDE) chỉ hoạt động được với các biến static (vì biến dynamic không có thông tin về kiểu). Như vậy có vẻ static typing là một lựa chọn quá an toàn, quá tiện lợi, và không có lí do gì để dùng dynamic trong C#.</p>
<p>Tuy nhiên, theo như một số sách và trang web, thì có những tình huống mà static typing cũng không giúp phát hiện lỗi cho chúng ta, chẳng hạn như khi parse XML:</p>
<p><pre class="brush: csharp;">
string bookDef = &quot;&lt;Book&gt;&lt;Title&gt;The wedding singer&lt;/Title&gt;&lt;/Book&gt;&quot; 
XElement book = XElement.Parse(bookDef); 
Console.WriteLine(book.Descendants(&quot;Title&quot;).FirstOrDefault().Value);</pre></p>
<p>bookDef có thể là string được tạo sẵn, cũng có thể do người dùng nhập vào, hay đọc từ tập tin, v.v. Dù thế nào đi nữa, trình dịch không thể (và không quan tâm) giá trị của nó khi dịch lệnh XElement book… Điều đó nghĩa là nếu bạn lỡ viết nhầm “Title” thành “Tittle” trong lệnh Console.WriteLine, trình dịch cũng không thể phát hiện được, và bạn sẽ nhận Exception vào lúc runtime.</p>
<p><pre class="brush: csharp;">
string bookDef = &quot;&lt;Book&gt;&lt;Title&gt;The wedding singer&lt;/Title&gt;&lt;/Book&gt;&quot; 
dynamic book = DynamicXml.Parse(bookDef); 
Console.WriteLine(book.Title);</pre></p>
<p>XML được parse lúc runtime thành một object, với property là các element. Object này được gán cho book, và chúng ta có thể lấy thông tin từ XML một cách rất… OOP. Điều này có thể thực hiện được với static typing sử dụng Reflection, nhưng dynamic giúp cho công việc trở nên đơn giản hơn rất nhiều. Và chúng ta cũng không mất gì cả, vì đằng nào thì static typing cũng không giúp bắt những lỗi như “Tittle” khi biên dịch.</p>
<p>Để xây dựng DynamicXml, tham khảo <a href="http://msdn.microsoft.com/en-us/library/ee461504.aspx" target="_blank">hướng dẫn của MSDN</a>.</p>
<p>Chú ý là có những thứ trong XML khó có thể diễn tả trong C#, như namespace, quy tắc đặt tên, v.v, cho nên ví dụ này chỉ ở mức ứng dụng là làm ví dụ <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . HM nghĩ nếu xây dựng được một DynamicXml hỗ trợ đầy đủ XML, thì việc sử dụng nó cũng chả đơn giản hơn XElement là mấy (chưa nói đến chúng ta đã có LINQ2XML).</p>
<p>Dĩ nhiên là dynamic có những lí do hợp lí để tồn tại, nhưng đó là chuyện khác.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/c/'>C#</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/380/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=380&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/09/28/c-nn-dng-dynamicxml-lm-v-d%e1%bb%a5-cho-dynamic-trong-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Covariance và contravariance trong C# Generics</title>
		<link>http://nmhblog.wordpress.com/2010/09/08/covariance-v-contravariance-trong-c-generics/</link>
		<comments>http://nmhblog.wordpress.com/2010/09/08/covariance-v-contravariance-trong-c-generics/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 06:37:30 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/09/08/covariance-v-contravariance-trong-c-generics/</guid>
		<description><![CDATA[Xét interface IList&#60;T&#62; với hai method là void Add(T item) và T Get(int index), và List&#60;T&#62; là class implement IList&#60;T&#62;. Ngoài ra ta có các kiểu cha con Mammal, Elephant. Bây giờ ta có lệnh gán IList&#60;Mammal&#62; a = new List&#60;Elephant&#62;(). Vì a có kiểu khai báo là IList&#60;Mammal&#62;, nó có thể gọi method void [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=365&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Xét interface IList&lt;T&gt; với hai method là void Add(T item) và T Get(int index), và List&lt;T&gt; là class implement IList&lt;T&gt;. Ngoài ra ta có các kiểu cha con Mammal, Elephant.</p>
<p>Bây giờ ta có lệnh gán IList&lt;Mammal&gt; a = new List&lt;Elephant&gt;(). Vì a có kiểu khai báo là IList&lt;Mammal&gt;, nó có thể gọi method void Add(Mammal item). Tuy nhiên, List&lt;Elephant&gt;() lại chỉ hiện thực method void Add(Elephant item), nên ta không thể gọi a.Add(tiger). Do đó có hai phương án. Phương án thứ nhất là trình biên dịch chấp nhận lệnh gán trên, các tình huống gây lỗi sẽ được bắt lúc runtime. Phương án thứ hai là không cho biên dịch lệnh gán này. C# chọn phương án thứ hai. Lí do có lẽ là để phù hợp với quan điểm về <a href="http://nmhblog.wordpress.com/2010/08/04/staticdynamic-typing-v-strongweak-typing/" target="_blank">static typing</a>.</p>
<p>Còn method Mammal Get(int index)? Giả sử ta gọi Mammal b = a.Get(0). Bởi vì List&lt;Elephant&gt; hiện thực method Elephant Get(int index), và Elephant là con của Mammal, nên lệnh gọi này hoàn toàn hợp lệ cả lúc biên dịch lẫn runtime.</p>
<p>Như vậy, nếu chúng ta chỉ sử dụng type T (trong IList&lt;T&gt;) cho các giá trị output, thì sẽ không bao giờ xảy ra chuyện rắc rối như với a.Add(Elephant item). Chính vì lí do này, C# 4.0 giới thiệu thêm kí hiệu out cho phép ta chú thích với trình biên dịch rằng, type T chỉ dùng cho output. Nói cách khác, nếu IList&lt;T&gt; chỉ có method Get, ta có thể khai báo interface này là IList&lt;out T&gt;, và khi đó IList&lt;Mammal&gt; a = new List&lt;Elephant&gt;() là một phép gán hợp lệ.</p>
<p>Trong tình huống ngược lại, IList&lt;Elephant&gt; a = new List&lt;Mammal&gt;(), thì method Get mới lại là kẻ gây rắc rối. Vì method này trong IList&lt;Elephant&gt; trả về Elephant, còn hiện thực của List&lt;Mammal&gt; lại trả về Mammal, và tất nhiên không phải tất cả các Mammal đều là Elephant. Tương tự như trường hợp ban đầu, nếu ở đây, IList&lt;T&gt; không có Get, tức là T không được dùng cho giá trị output mà chỉ cho input, thì phép gán sẽ hoàn toàn hợp lệ. Để chú thích cho trình duyệt điều này, ta dùng từ khóa in, tương tự như out.</p>
<p>Còn hai thuật ngữ covariance và contravariance liên quan gì đến in và out? Dựa vào <a href="http://blogs.msdn.com/b/ericlippert/archive/2007/10/16/covariance-and-contravariance-in-c-part-one.aspx" target="_blank">bài viết này</a>, có thể liên hệ như sau: IList&lt;out T&gt; cho phép bảo toàn chiều “lớn hơn” giữa Mammal và Elephant, còn IList&lt;in T&gt; đảo chiều “lớn hơn” giữa Elephant và Mammal.</p>
<p>Nãy giờ bạn có thắc mắc tại sao lại là IList&lt;…&gt; a = new List&lt;…&gt; chứ không phải List&lt;…&gt; a = new List&lt;…&gt; không? Đó là vì CLR chỉ hỗ trợ tính năng này cho interface và delegate (theo &quot;C# in depth”). Vậy tại sao CLR lại chỉ hỗ trợ như vậy. Câu trả lời dễ hiểu nhất mà HM từng thấy là <a href="http://stackoverflow.com/questions/2541467/why-does-c-4-0-not-allow-co-and-contravariance-in-generic-class-types" target="_blank">ở đây</a>, do một thành viên trong nhóm Visual C# đưa ra:</p>
<blockquote><p>Sure, that&#8217;s a reasonable example but you haven&#8217;t shown anything that couldn&#8217;t also be done with interfaces. Just make interface ILookup&lt;out T&gt; and have Lookup&lt;T&gt; implement it. What compelling additional benefit over interface variance does your scenario for class variance add?</p>
<p><em>We don&#8217;t have to provide a justification for <i>not</i> implementing a feature. Not implementing a feature is free. Rather, we have to provide a justification for implementing a feature &#8212; features can cost millions of dollars to Microsoft, and impose an even larger burden upon our customers who must then spend time and money learning about the feature.</em></p>
</blockquote>
<p>Đoạn comment thứ hai cho chúng ta thêm một câu hỏi: vậy tính năng vừa bàn ở trên trong C# 4.0 dùng để làm gì? Khi nào thì dùng? Cái này thì phải suy nghĩ đã <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/c/'>C#</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/365/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=365&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/09/08/covariance-v-contravariance-trong-c-generics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Ví dụ về Test-Driven Development</title>
		<link>http://nmhblog.wordpress.com/2010/08/29/v-d%e1%bb%a5-v%e1%bb%81-test-driven-development/</link>
		<comments>http://nmhblog.wordpress.com/2010/08/29/v-d%e1%bb%a5-v%e1%bb%81-test-driven-development/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 16:11:45 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/08/29/v-d%e1%bb%a5-v%e1%bb%81-test-driven-development/</guid>
		<description><![CDATA[Đây là một số ví dụ về Test-Driven Development mà mình đã tập hợp được. Ngắn: Chapter 6 – Agile principles, patterns, and practices in C# – by Martin C. Robert, Martin Micah. Khá thú vị. Xem online tại đây. Phần 3, 4, 5 của Craftsman. Trung bình: Part I – Test-Driven Development by example [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=354&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Đây là một số ví dụ về Test-Driven Development mà mình đã tập hợp được.</p>
<p>Ngắn:</p>
<ul>
<li>Chapter 6 – Agile principles, patterns, and practices in C# – by Martin C. Robert, Martin Micah. Khá thú vị. Xem online tại <a href="http://www.objectmentor.com/resources/articles/xpepisode.htm" target="_blank">đây</a>. </li>
<li>Phần 3, 4, 5 của <a href="http://www.objectmentor.com/resources/publishedArticles.html" target="_blank">Craftsman</a>. </li>
</ul>
<p>Trung bình:</p>
<ul>
<li>Part I – Test-Driven Development by example – Kent Beck. </li>
<li>Part III &#8211; Test-Driven Development: A practical guide – David Astels. </li>
<li>Phần 6, 7, 8, 9, 10 của <a href="http://www.objectmentor.com/resources/publishedArticles.html" target="_blank">Craftsman</a>. </li>
</ul>
<p>Dài:</p>
<ul>
<li>Part II – Test-Driven Development in Microsoft .NET – James W. Newkirk, Alexei A. Vorontsov. </li>
<li>Part III – Growing object-oriented software, guided by test – Steve Freeman, Nat Pryce. </li>
</ul>
<p>Đặc biệt, nếu bạn có thời gian, không thể bỏ qua bộ <a href="http://www.objectmentor.com/resources/publishedArticles.html" target="_blank">Craftsman</a>.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/tdd/'>TDD</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=354&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/08/29/v-d%e1%bb%a5-v%e1%bb%81-test-driven-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Đọc t&#224;i liệu tiếng Anh</title>
		<link>http://nmhblog.wordpress.com/2010/08/23/d%e1%bb%8dc-ti-li%e1%bb%87u-ti%e1%ba%bfng-anh/</link>
		<comments>http://nmhblog.wordpress.com/2010/08/23/d%e1%bb%8dc-ti-li%e1%bb%87u-ti%e1%ba%bfng-anh/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 11:48:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tiếng Anh]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/08/23/d%e1%bb%8dc-ti-li%e1%bb%87u-ti%e1%ba%bfng-anh/</guid>
		<description><![CDATA[HM viết bài này bởi vì có nhiều từ khóa tìm kiếm bằng tiếng Việt vào blog này quá, và hầu hết là về các vấn đề đơn giản, và ít bám theo liên kết trong blog để đến các bài viết tiếng Anh chi tiết hơn. Đây là một việc rất không tốt, bởi [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=526&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>HM viết bài này bởi vì có nhiều từ khóa tìm kiếm bằng tiếng Việt vào blog này quá, và hầu hết là về các vấn đề đơn giản, và ít bám theo liên kết trong blog để đến các bài viết tiếng Anh chi tiết hơn. Đây là một việc rất không tốt, bởi vì là lập trình viên thì càng cần phải biết dùng tiếng Anh để đọc và tra cứu tài liệu.</p>
<p>Trước hết phải dạo qua bước thủ tục đã. Tại sao lập trình viên nên dùng tài liệu tiếng Anh (chứ không phải là tiếng Việt)?</p>
<ul>
<li>Sách tiếng Anh (tất nhiên là những quyển hay nhất) có chất lượng tốt hơn sách tiếng Việt. Nói chính xác hơn, sách lập trình tiếng Việt đa phần rất tệ (và rất mỏng), chỉ lướt qua các kiến thức bề mặt chứ ít khi đi sâu vào cốt lõi của vấn đề. Ngoại lệ có lẽ là các sách dịch. </li>
<li>Phần lớn các công nghệ phổ biến đều được phát triển bởi các công ti Mĩ. Tài liệu hỗ trợ vì thế sẽ viết bằng tiếng Anh là chủ yếu. Nếu có dịch sang tiếng khác thì cũng còn lâu tiếng Việt mới tới lượt. </li>
<li><a href="http://stackoverflow.com/">Stack Overflow</a>. Đây là trang web hỏi đáp nổi tiếng nhất cho lập trình viên. Ngay cả những vấn đề chưa được tài liệu hóa thì bạn cũng có cơ hội tìm được câu trả lời ở đây. Thậm chí cỗ máy tìm kiếm của MSDN cũng lấy các kết quả từ Stack Overflow. Tiếng Anh là ngôn ngữ duy nhất được dùng trên trang này. </li>
<li>Sách điện tử tiếng Anh rất dễ kiếm, đủ đề tài từ lập trình đến dạy hẹn hò <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  (tất nhiên, tải sách điện tử “lậu” là không hợp pháp).</li>
</ul>
<p>Vậy làm sao để đọc tài liệu tiếng Anh? Thứ nhất là phải học tiếng Anh. Nếu học nghiêm túc thì chắc bằng A là đủ rồi. Thứ hai, phải luyện tập. Bạn cần phải:</p>
<ul>
<li>Bớt thời gian tìm kiếm sách học tiếng Anh, rồi lời khuyên học tiếng Anh, v.v đi. Chỉ có luyện tập mới tạo nên sự hoàn thiện.</li>
<li>Tập đọc tài liệu. Tất nhiên HM không thể có dẫn chứng xác thực, nhưng có rất nhiều sinh viên mắc bệnh lười đọc, hiếm khi đọc trọn vẹn giáo trình cho môn học, mà chỉ phụ thuộc vào bài giảng của giáo viên. Nếu thi trắc nghiệm thì có khi chỉ cần giải đề năm trước và học thuộc là đã có thể qua (và qua với điểm khá) <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Chỉ nhìn cái gì nhiều chữ đã nản thì còn tính gì đến tiếng Anh tiếng Việt, hơn nữa tài liệu tiếng Anh lúc nào cũng dài, chi tiết, dày đặc chữ. Tập càng sớm càng tốt, ngay từ môn học đầu tiên. Đừng sợ hãi những bài báo 8-9 trang, hay những quyển sách dày 400-500 trang, nếu nội dung của nó thật sự có ích. Đừng trông chờ một ai đó (kể cả Google) lúc nào cũng có thể trả lời cho bạn những câu hỏi kiểu như làm sao hiện thực thuật toán tìm đường ngắn nhất, thuật toán Euclid mở rộng là gì. Đừng phụ thuộc vào những bài giảng trên lớp. Hãy đọc sách và động não.</li>
<li>Đừng sợ tiếng Anh. Bạn sẽ không bao giờ đọc tốt tiếng Anh nếu bạn không đủ kiên nhẫn và quyết tâm đọc nó. Nhiều người mặc dù đã được học tiếng Anh khá bài bản nhưng vấn có tâm lí này. Chỉ cần cấu trúc của câu phức tạp một chút, chỉ cần đoạn văn dài một chút, là họ đã bỏ qua rồi. Đừng làm thế. Hãy kiên nhẫn đọc cho hiểu từ những câu thông báo ngắn trên màn hình đến những bài báo dài từ Wikipedia tiếng Anh. Cố gắng đừng đóng lại một trang web chỉ vì nó viết bằng tiếng Anh, hãy đóng nó chỉ khi nó không hữu ích. </li>
<li>Đọc tiếng Anh thật nhiều. Bạn có tin là thậm chí một quyển sách tiếng Anh cấp hai cũng giúp bạn cải thiện khả năng đọc tiếng Anh không? Khi đọc một câu tiếng Anh, đừng dịch nó qua tiếng Việt rồi mới hiểu nó, mà hãy cố gắng hiểu trực tiếp bằng tiếng Anh. Coi như những từ tiếng Anh đó chẳng qua là từ tiếng Việt. Chẳng hạn, apple là táo. Vậy táo là gì? Nếu bạn không định nghĩa được táo là gì, mà chỉ nghĩ táo là táo, thì cũng hãy nghĩ apple là apple thôi. </li>
<li>Đừng đọc cà nhắc. Tập trung vào cấu trúc của câu, xem câu đó nói gì, hơn là tập trung vào nghĩa của từng từ. Nếu nghĩa của từ đó không cần thiết cho việc hiểu cả câu thì lơ nó đi cũng được, khi gặp nhiều lần hãy tra. Nếu bạn phải dừng lại tra từ quá nhiều, bạn sẽ không tóm gọn được ý nghĩa của cả đoạn, và hơn nữa bạn cũng sẽ chóng chán đọc tiếng Anh. </li>
<li>Đừng xấu hổ. Nếu bạn chưa thạo thì bạn đọc chậm. Nếu không hiểu thì nói là không hiểu. Nhất là lúc đầu khi tập đọc tiếng Anh mà không dịch trung gian qua tiếng Việt mọi thứ sẽ rất khó khăn và mất nhiều thời gian. Cũng giống như tập gõ bàn phím mười ngón vậy, lúc đầu chắc chắn người tập sẽ gõ chậm hơn gõ “mổ cò”, nhưng sau cùng họ sẽ gõ nhanh hơn hẳn những người “mổ cò” (cộng với việc không cần nhìn bàn phím).</li>
<li>Đừng dừng lại. Ngay cả khi bạn đọc tiếng Anh như tiếng Việt, thì cũng không có nghĩa là bạn có thể dừng lại. Hãy đọc thêm tiếng Anh ở nhiều lĩnh vực khác, mở rộng vốn từ của mình, tập viết tiếng Anh nhiều hơn để tăng cường trình độ tiếng Anh của mình. Tại sao? HM không thể trả lời được, nhưng HM nghĩ sự tự mãn, dù nhỏ hay lớn, khi đã xuất hiện sẽ làm con người ta tiêu tan ý chí phấn đấu, trở nên sợ hãi và dừng bước trước những thử thách vượt quá khả năng.</li>
</ul>
<p>Một số công cụ rất hữu ích:</p>
<ul>
<li><a href="http://simple.wikipedia.org/wiki/Main_Page" target="_blank">Simple English Wikipedia</a>. Wikipedia phiên bản chỉ dùng tiếng Anh đơn giản. Vì là Wikipedia chắc chắn sẽ có chủ đề thú vị với bạn.</li>
<li><a href="http://www.englishforums.com/">Englishforums.com</a>. Ở đây lúc nào cũng có giáo viên hoặc người bản xứ trả lời câu hỏi của bạn.</li>
<li><a href="http://www.lingoes.net/">Lingoes</a>. Từ điển, giống Babylon, nhưng miễn phí.</li>
</ul>
<p>Mong là một ngày nào đó blog này sẽ không còn lượt truy cập nào nữa <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/ti%e1%ba%bfng-anh/'>tiếng Anh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/526/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=526&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/08/23/d%e1%bb%8dc-ti-li%e1%bb%87u-ti%e1%ba%bfng-anh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>SLF4J và logback</title>
		<link>http://nmhblog.wordpress.com/2010/08/21/java-logging/</link>
		<comments>http://nmhblog.wordpress.com/2010/08/21/java-logging/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 16:18:39 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/08/21/java-logging/</guid>
		<description><![CDATA[Mặc dù unit test có thể giúp hạn chế lỗi khi phát triển phần mềm, với những chương trình phức tạp, sự cố là không thể tránh khỏi, nghĩa là vẫn phải có debug. Và việc này sẽ đơn giản hơn rất nhiều nếu trạng thái của chương trình tại các thời điểm khác nhau [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=260&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Mặc dù <a href="http://nmhblog.wordpress.com/2010/08/19/unit-test/" target="_blank">unit test</a> có thể giúp hạn chế lỗi khi phát triển phần mềm, với những chương trình phức tạp, sự cố là không thể tránh khỏi, nghĩa là vẫn phải có debug. Và việc này sẽ đơn giản hơn rất nhiều nếu trạng thái của chương trình tại các thời điểm khác nhau được ghi lại. Ngoài ra, các thông tin này có thể giúp cải tiến chương trình về giao diện sử dụng, tốc độ, v.v. Đó là lí do chúng ta có các logging framework.</p>
<p>Tại sao không dùng println cho việc logging? Bởi vì chúng quá thô sơ. Một giải pháp logging, có lẽ phải đáp ứng các yêu cầu sau:</p>
<ul>
<li>Tùy biến:
<ul>
<li>Bật, tắt logging (toàn bộ hoặc theo loại thông điệp. </li>
<li>Vị trí xuất log (màn hình, tập tin, database, v.v) </li>
<li>Định dạng, lượng thông tin cần log </li>
</ul>
</li>
<li>Thông tin có thể log:
<ul>
<li>Vị trí gọi log </li>
<li>Thời gian </li>
<li>Thông điệp, stack trace, v.v </li>
</ul>
</li>
</ul>
<p>Có nhiều logging framework trong Java, trong đó nổi tiếng nhất là Log4J. Để thuận tiện khi chuyển đổi giữa các logging framework, người ta phát triển facade chung cho chúng. Không may là cũng lại có hơn một facade <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (Java là thế). Hiện nay, các dự án có vẻ đang ưa chuộng facade <a href="http://www.slf4j.org/" target="_blank">SLF4J</a>. API của SLF4J được framework <a href="http://logback.qos.ch/" target="_blank">logback</a> hiện thực trực tiếp (native implementation). Ngoài tính dễ sử dụng, SLF4J còn có một lợi thế là được phát triển bởi tác giả của Log4J—tất nhiên là người hiểu rõ các hạn chế của Log4J.</p>
<p>Dưới đây là một ví dụ nhỏ về SLF4J. Tài liệu hướng dẫn và cả javadoc của SLF4J và logback đã rất cụ thể và đầy đủ, nên nếu bạn muốn tìm hiểu sâu hơn thì đó là nơi tốt nhất để bắt đầu.</p>
<p>Mặc định của logback là log ra console:</p>
<p><pre class="brush: java;">
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 
public class HelloWorld { 
  public static void main(String[] args) { 
    Logger logger = LoggerFactory.getLogger(&quot;HelloWorld&quot;); 
    logger.debug(&quot;Hello world.&quot;); 
  } 
}</pre></p>
<p>Kết quả (console):</p>
<p><pre class="brush: plain;">22:12:35.261 [main] DEBUG HelloWorld - Hello world.</pre></p>
<p>Sửa đổi tập tin cấu hình (thường là logback.xml) và ta sẽ log được ra tập tin:</p>
<p><pre class="brush: xml;">&lt;configuration&gt; 
  &lt;appender name=&quot;FILE&quot; class=&quot;ch.qos.logback.core.FileAppender&quot;&gt; 
    &lt;file&gt;hw.log&lt;/file&gt; 
    &lt;encoder&gt; 
      &lt;pattern&gt;%date %level [%thread] %logger{10} [%file:%line] %msg%n&lt;/pattern&gt; 
    &lt;/encoder&gt; 
  &lt;/appender&gt; 
  &lt;root level=&quot;debug&quot;&gt; 
    &lt;appender-ref ref=&quot;FILE&quot; /&gt; 
  &lt;/root&gt; 
&lt;/configuration&gt;</pre></p>
<p>Kết quả (trong tập tin hw.log):</p>
<p><pre class="brush: plain;">2010-08-21 21:35:57,583 DEBUG [main] HelloWorld [HelloWorld.java:7] Hello world.</pre></p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/java/'>Java</a>, <a href='http://nmhblog.wordpress.com/tag/logging/'>logging</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/260/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=260&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/08/21/java-logging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>JUnit</title>
		<link>http://nmhblog.wordpress.com/2010/08/19/unit-test/</link>
		<comments>http://nmhblog.wordpress.com/2010/08/19/unit-test/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 16:53:10 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[software testing]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/08/19/unit-test/</guid>
		<description><![CDATA[Có lẽ đa số sinh viên chúng ta đều quen với việc hoàn tất chương trình, chạy thử, thấy sai, tìm và sửa lỗi, chạy thử, v.v. Điều này không có gì là sai trái, tuy nhiên nếu đợi đến khi hoàn tất chương trình rồi mới chạy thử, thì việc tìm và sửa lỗi [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=254&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Có lẽ đa số sinh viên chúng ta đều quen với việc hoàn tất chương trình, chạy thử, thấy sai, tìm và sửa lỗi, chạy thử, v.v. Điều này không có gì là sai trái, tuy nhiên nếu đợi đến khi hoàn tất chương trình rồi mới chạy thử, thì việc tìm và sửa lỗi sẽ tương đối vất vả. Quá trình này sẽ đơn giản hơn, nếu bạn có thể chia chương trình thành từng phần nhỏ, và test chúng một cách riêng rẽ. Đó là ý nghĩa của unit test.</p>
<p>Tuy nhiên, để unit test hiệu quả, chúng ta cần có các công cụ để tiến hành nó một cách tự động. Các công cụ này gọi là unit test framework. Với Java, framework nổi tiếng nhất là JUnit.</p>
<p>Nếu bạn muốn tìm hiểu về JUnit, thì bạn nên đọc “JUnit in action”. Dưới đây là một ví dụ nhỏ về JUnit để bạn tham khảo.</p>
<p><strong>Kiểm tra với một test case</strong></p>
<p>Giả sử chúng ta có một class Number như dưới đây. Mỗi object của class đại diện cho một số nguyên. Method isEven kiểm tra tính chẵn lẻ của số nguyên đó. Mục tiêu của chúng ta là kiểm tra tính đúng đắn của method isEvent.</p>
<p><pre class="brush: java;">public class Number { 
    private int number; 
    public Number(int number) { this.number = number; } 
    public boolean isEven() { return (number % 2 == 0)?true:false; } 
}</pre></p>
<p>Việc đầu tiên là tải tập tin <a href="http://www.junit.org/" target="_blank">junit-4.x.x.jar</a> và cho nó vào CLASSPATH. Đoạn mã dưới đây sẽ kiểm tra isEvent với 2.</p>
<p><pre class="brush: java;">import static org.junit.Assert.*; 
import org.junit.Test; 
public class NumberTest { 
    @Test public void testIsEven() { 
        Number number = new Number(2); 
        assertTrue(number.isEven()); 
    } 
}</pre></p>
<p>Dịch hai đoạn mã trên và chạy lệnh <code>java org.junit.runner.JUnitCore NumberTest</code>. Khi đó JUnit sẽ chạy các method được đánh dấu <code>@Test</code>. Kết quả là:</p>
<p><pre class="brush: plain;">JUnit version 4.8.2 
. 
Time: 0.008 
OK (1 test)</pre></p>
<p><strong>Kiểm tra với nhiều test case</strong></p>
<p>Bây giờ ta muốn kiếm tra với nhiều số hơn. Chúng ta sẽ không chèn thêm assertTrue vào testIsEven (vì như vậy sẽ không thể biết được số nào làm cho test bị sai). Thay vào đó, chúng ta sẽ tham số hóa method testIsEven. Các tham số được lấy từ bộ test tạo ra bởi method getTestParameters.</p>
<p><pre class="brush: java;">import static org.junit.Assert.*; 
import org.junit.Test; 
import org.junit.runner.RunWith; 
import org.junit.runners.Parameterized; 
import org.junit.runners.Parameterized.Parameters; 
import java.util.Arrays; 
import java.util.Collection;  

@RunWith(value=Parameterized.class) 
public class NumberParameterizedTest { 
    private int value; 
    private boolean expected; 
    public NumberParameterizedTest(int value, boolean expected) { 
        this.value = value; 
        this.expected = expected; 
    } 
    @Parameters public static Collection&amp;lt;Object[]&amp;gt; getTestParameters() { 
        return Arrays.asList(new Object[][] { {2, true}, {3, false}, {5, true}, }); 
    } 
    @Test public void testIsEven() { 
        Number number = new Number(value); 
        assertEquals(number.isEven(), expected); 
    } 
}</pre></p>
<p>Lần này, Junit sẽ lần lượt lấy từng mẫu ra để kiểm tra. Kết quả là (trích):</p>
<p><pre class="brush: plain;">JUnit version 4.8.2 
...E 
Time: 0.022 
There was 1 failure: 
1) testIsEven[2](NumberParameterizedTest)...</pre></p>
<p>Như vậy là test sai với mẫu thứ ba (5, true) (vì đếm từ 0).</p>
<p><strong>Kiểm tra Exception</strong></p>
<p>Trong một số trường hợp, một method sẽ throw Exception thay vì trả về kết quả tính toán. Để đảm bảo hành vi của method đúng như mong đợi, chúng ta phải test cả những trường hợp này để xem chúng có throw đúng Exception cần throw không. @Test(expected=YourException.class) là annotation phục vụ cho mục đích này.</p>
<p><strong>Dùng test làm hướng dẫn sử dụng</strong></p>
<p>Hãy nhìn lại đoạn code trên. Khi đọc test (nếu bạn hiểu JUnit), bạn sẽ suy ra ngay cách sử dụng method isEven: đầu tiên tạo một object Number với constructor nhận vào giá trị int, sau đó gọi isEven(). Vậy là, test code còn một tác dụng khác là làm hướng dẫn sử dụng (tương tự như các đoạn code trong tutorial trên mạng). Ưu điểm của việc lấy test làm hướng dẫn sử dụng là nhanh gọn và bám sát theo thay đổi của chương trình.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/java/'>Java</a>, <a href='http://nmhblog.wordpress.com/tag/software-testing/'>software testing</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/254/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=254&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/08/19/unit-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Local class trong Java</title>
		<link>http://nmhblog.wordpress.com/2010/08/08/linh-tinh-v%e1%bb%81-nested-type-trong-java/</link>
		<comments>http://nmhblog.wordpress.com/2010/08/08/linh-tinh-v%e1%bb%81-nested-type-trong-java/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 09:21:19 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/08/08/linh-tinh-v%e1%bb%81-nested-type-trong-java/</guid>
		<description><![CDATA[Local class là class được khai báo bên trong một method. Các object của class này có đặc điểm là chỉ truy xuất được variable của method nếu chúng là final. Để giải thích điều này, hãy xét đoạn mã dưới đây. Ở đây, i và a là các local variable của method OuterMethod. Khi [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=241&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Local class là class được khai báo bên trong một method. Các object của class này có đặc điểm là chỉ truy xuất được variable của method nếu chúng là final. Để giải thích điều này, hãy xét đoạn mã dưới đây.</p>
<p><pre class="brush: java;">class Outer {
	SomeClass o;
	public void OuterMethod() {
		int a;
		class Inner {
			public void InnerMethod() {
				// Do something
			}
		}
		Inner i = new Inner;
		o = new SomeClass(i);
	}
}</pre></p>
<p>Ở đây, i và a là các local variable của method OuterMethod. Khi method này kết thúc, i và a sẽ bị xóa khỏi stack. Thế còn object mà i trỏ tới liệu có bị Garbage Collector xóa? Câu trả lời là tùy từng trường hợp. Vì i đã được pass cho object o, nếu o lưu lại một reference để trỏ tới object mà i đang trỏ tới, thì object này chưa đủ điều kiện để bị thu hồi vùng nhớ. Điều đáng nói ở đây là object mà i trỏ tới có thể tồn tại lâu hơn method OuterMethod. Bây giờ, nếu trong phần mã của InnerMethod có một method nào đó sử dụng i, và method này được chạy khi method OuterMethod đã kết thúc (nghĩa là i đã bị xóa), thì nó sẽ lấy i ở đâu ra? Tất nhiên, nó không thể lấy được i ở đâu cả. Để tránh tình huống này, Java không cho mã của method-local inner class truy xuất variable của method chứa nó, trừ khi variable là final.</p>
<p>Xét tiếp phần “final” của vấn đề. Vì final variable không thể bị thay đổi một khi đã được gán giá trị, cho nên object của inner class có thể copy lại. Vậy tại sao không copy các variable còn lại? Rất đơn giản, nếu biến int i được copy, thì khi đó i của object và i của method không liên hệ gì với nhau, mọi thay đổi của i trong object không ảnh hưởng gì đến i của method, nghĩa là việc copy i cũng chỉ tương đương với việc chúng ta truyền i vào trong object thông qua constructor hoặc method bình thường, không hơn không kém. Hoàn toàn không cần thiết phải đưa thêm một tính năng khi nó không thực sự giúp giải quyết vấn đề gì.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/java/'>Java</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/241/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=241&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/08/08/linh-tinh-v%e1%bb%81-nested-type-trong-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Static/dynamic typing và strong/weak typing</title>
		<link>http://nmhblog.wordpress.com/2010/08/04/staticdynamic-typing-v-strongweak-typing/</link>
		<comments>http://nmhblog.wordpress.com/2010/08/04/staticdynamic-typing-v-strongweak-typing/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 15:51:17 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/08/04/staticdynamic-typing-v-strongweak-typing/</guid>
		<description><![CDATA[Đôi khi người ta hay nhầm lẫn giữa static/dynamic typing và strong/weak typing. Phổ biến nhất là việc mặc nhiên xem các ngôn ngữ static typing là strong typing, và ngôn ngữ dynamic typing là weak typing. Thực tế đây là hai cách phân loại kiểm tra kiểu (type checking) khác nhau. Static/dynamic typing Đây [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=234&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Đôi khi người ta hay nhầm lẫn giữa static/dynamic typing và strong/weak typing. Phổ biến nhất là việc mặc nhiên xem các ngôn ngữ static typing là strong typing, và ngôn ngữ dynamic typing là weak typing. Thực tế đây là hai cách phân loại kiểm tra kiểu (type checking) khác nhau.</p>
<p><strong>Static/dynamic typing</strong></p>
<p>Đây là cách phân loại dựa vào thời điểm thực hiện kiểm tra kiểu.</p>
<p>Một ngôn ngữ lập trình thuộc dạng static typing (định kiểu chặt?) khi phần lớn công việc kiểm tra kiểu được thực hiện lúc biên dịch. Do khi biên dịch ta không thể xác định được giá trị của biến tại vị trí bất kì trong chương trình, trình biên dịch ngôn ngữ static typing phải gán kiểu cho biến ngay từ đầu (nhờ lập trình viên khai báo hoặc tự xác định khi biến được khởi tạo).</p>
<p>Trong khi đó, ngôn ngữ dạng dynamic typing kiểm tra kiểu lúc runtime. Kiểu của biến được xác định dựa vào giá trị của nó lúc sử dụng. Do đó, việc gán kiểu cho biến lúc biên dịch là không cần thiết (gán cũng được, nhưng như thế thì không cần đến dynamic typing nữa).</p>
<p>C là ngôn ngữ static typing, còn Python là ngôn ngữ dynamic typing. Để hiểu thêm, so sánh sự khác nhau giữa var (static typing) và dynamic (dynamic typing) trong C#.</p>
<p><strong>Strong/weak typing</strong></p>
<p>Khi kiểu của tham số trong một biểu thức không phù hợp, trình biên dịch phải chuyển tham số này thành kiểu đúng, rồi mới tính giá trì biểu thức. Tùy thuộc vào khả năng chuyển đổi giữa các kiểu với nhau mà chúng ta coi ngôn ngữ lập trình là strong typing hay weak typing. Ví dụ, C được xem là weak typing so với Java (nhớ là trong C ta có thể viết if (1) {} nhưng trong Java thì không). Python và Perl đều là ngôn ngữ dynamic typing, nhưng Perl được xem là weak typing so với Python (nhớ là biểu thức 1+”1” chỉ có ý nghĩa trong Perl).</p>
<p>Nói chung cách phân chia strong/weak này không có tiêu chuẩn gì, vì vậy ít được dùng một cách nghiêm túc. Tuy nhiên nhầm lẫn giữa hai cách phân loại static/dynamic và strong/weak thì cũng không hay chút nào.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh/'>lập trình</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/234/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=234&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/08/04/staticdynamic-typing-v-strongweak-typing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Overriding trong Java là single dispatch</title>
		<link>http://nmhblog.wordpress.com/2010/07/28/overriding-trong-java/</link>
		<comments>http://nmhblog.wordpress.com/2010/07/28/overriding-trong-java/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 11:37:53 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/07/28/overriding-trong-java/</guid>
		<description><![CDATA[Không có gì đặc biệt, nhưng có lẽ cũng phải ghi lại. Trước hết, cho hai class Animal và Cat: Tiếp theo cho class Hunter và BetterHunter: Bây giờ xét tình huống sau, kết quả in ra là gì? Vì h trỏ đến BetterHunter, JVM phân giải h.Kill thành Kill của BetterHunter. Sau đó, vì [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=227&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Không có gì đặc biệt, nhưng có lẽ cũng phải ghi lại.</p>
<p>Trước hết, cho hai class Animal và Cat:</p>
<p><pre class="brush: java;">
class Animal {} 
class Cat extends Animal {}
</pre></p>
<p>Tiếp theo cho class Hunter và BetterHunter:</p>
<p><pre class="brush: java;">
class Hunter { 
    public void Kill(Animal a) { System.out.println(&quot;Hunter killed Animal&quot;); } 
    public void Kill(Cat c) { System.out.println(&quot;Hunter killed Cat&quot;); } 
} 
class BetterHunter extends Hunter { 
    public void Kill(Animal a) { System.out.println(&quot;BetterHunter killed Animal&quot;); } 
    public void Kill(Cat c) { System.out.println(&quot;BetterHunter killed Cat&quot;); } 
}
</pre></p>
<p>Bây giờ xét tình huống sau, kết quả in ra là gì?</p>
<p><pre class="brush: java;">
Animal a = new Cat(); 
Hunter h = new BetterHunter(); 
h.Kill(a);
</pre></p>
<p>Vì h trỏ đến BetterHunter, JVM phân giải h.Kill thành Kill của BetterHunter. Sau đó, vì a trỏ đến Cat, JVM chọn Kill(Cat). Kết quả là “BetterHunter killed Cat”.</p>
<p>Sai. Java chỉ hỗ trợ <a href="http://en.wikipedia.org/wiki/Single_dispatch" target="_blank">Single dispatch</a>, vì overriding được hiện thực nhờ <a href="http://en.wikipedia.org/wiki/Virtual_method_table" target="_blank">vtable</a>. Nói cách khác JVM chỉ phân giải method dựa vào tham số đầu tiên (this). Bước thứ hai (chọn Kill nào) được thực hiện trong lúc biên dịch (overload). Vì vậy Kill của BetterHunter vẫn được gọi, nhưng là Kill(Animal). Kết quả là “BetterHunter killed Animal”.</p>
<p>Để có Double dispatch, tức là gọi Kill(Cat), xem Thinking in Java, hoặc pattern Visitor.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/java/'>Java</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=227&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/07/28/overriding-trong-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Singleton</title>
		<link>http://nmhblog.wordpress.com/2010/07/25/singleton/</link>
		<comments>http://nmhblog.wordpress.com/2010/07/25/singleton/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 13:56:38 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình hướng đối tượng]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/07/25/singleton/</guid>
		<description><![CDATA[Theo quyển Design Patterns (Gang of Four) thì Singleton là pattern cho phép class chỉ có duy nhất một instance. Đây cũng là một trong những pattern dễ hiểu, dễ hiện thực nhất. Khi nhắc đến Singleton thì mọi người cũng ngầm hiểu là Singleton với hiện thực như trong Gang of Four. Tuy nhiên [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=225&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Theo quyển Design Patterns (Gang of Four) thì <a href="http://en.wikipedia.org/wiki/Singleton_pattern" target="_blank">Singleton</a> là pattern cho phép class chỉ có duy nhất một instance. Đây cũng là một trong những pattern dễ hiểu, dễ hiện thực nhất. Khi nhắc đến Singleton thì mọi người cũng ngầm hiểu là Singleton với hiện thực như trong Gang of Four.</p>
<p>Tuy nhiên theo ý kiến chung là không nên dùng Singleton vì:</p>
<ul>
<li>Khó thay đổi, mở rộng. Singleton dùng method static. Class con có thể hide method static, nhưng không thể override chúng. </li>
<li>Vi phạm nguyên tắc <a href="http://nmhblog.wordpress.com/2010/05/10/vi-quy-t%E1%BA%AFc-thi%E1%BA%BFt-k%E1%BA%BF-h%C6%B0%E1%BB%9Bng-d%E1%BB%91i-t%C6%B0%E1%BB%A3ng/" target="_blank">Explicit interface</a> với các module dùng cùng một Singleton (tuy nhiên, đây không phải là luật). </li>
<li>Gây trở ngại cho unit test. Đây là hệ quả của lí do đầu tiên (<a href="http://www.ibm.com/developerworks/library/j-mocktest.html" target="_blank">xem nhanh</a>). </li>
</ul>
<p>Khi nào thì dùng Singleton? <a href="http://www.richardlord.net/blog/better-without-singletons" target="_blank">Bài viết này</a> đề xuất:</p>
<ul>
<li>Nếu tính chất “Singleton” không phải là bản chất của class, mà là do class dùng nó yêu cầu thế, thì tính duy nhất nên được hiện thực theo một cách độc lập, như Factory Method hay <a href="http://misko.hevery.com/2008/10/21/dependency-injection-myth-reference-passing/" target="_blank">Dependency Injection</a>. </li>
<li>Nếu tính chất “Singleton” là bản chất của class, xem xét việc dùng biến static để lưu trạng thái của instance (vẫn đem lại tính “duy nhất”), trước khi dùng đến phương pháp trong Gang of Four (vốn dùng cả method static). </li>
</ul>
<p>Xem thêm <a href="http://www.ibm.com/developerworks/webservices/library/co-single.html" target="_blank">Use your singletons wisely</a>.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/'>lập trình hướng đối tượng</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=225&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/07/25/singleton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Memory leak trong Java</title>
		<link>http://nmhblog.wordpress.com/2010/07/23/memory-leak-trong-java/</link>
		<comments>http://nmhblog.wordpress.com/2010/07/23/memory-leak-trong-java/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 16:39:40 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/07/23/memory-leak-trong-java/</guid>
		<description><![CDATA[Có hai lỗi quản lí bộ nhớ mà ai học C/C++ cũng từng mắc phải là memory leak và dangling pointer. Memory leak xảy ra khi chương trình không thể thu hồi (hay truy cập) một vùng nhớ đã cấp phát mặc dù không còn sử dụng. Nó xảy ra khi tất cả con trỏ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=222&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Có hai lỗi quản lí bộ nhớ mà ai học C/C++ cũng từng mắc phải là memory leak và dangling pointer. Memory leak xảy ra khi chương trình không thể thu hồi (hay truy cập) một vùng nhớ đã cấp phát mặc dù không còn sử dụng. Nó xảy ra khi tất cả con trỏ trỏ đến vùng nhớ đó bị thay đổi giá trị trước khi vùng nhớ được giải phóng. Dangling pointer xảy ra khi tồn tại con trỏ trỏ tới một vùng nhớ chưa được cấp phát, hoặc đã bị thu hồi.</p>
<p>Khác với C/C++, việc thu hồi vùng nhớ trong Java được thực hiện bởi Gabage Collector (GC). Các vùng nhớ không còn được trỏ tới sẽ có khả năng bị thu hồi (mặc dù ta không thể đảm bảo được thời điểm mà GC sẽ thực hiện điều đó) (không còn memory leak). Và tất nhiên, các vùng nhớ vẫn còn được trỏ tới bởi ít nhất một reference sẽ không bị thu hồi (không còn dangling pointer).</p>
<p>Vùng nhớ chỉ thỏa mãn tiêu chuẩn thu hồi khi không còn reference nào trỏ tới. Điều này nghĩa là ta phải <em>nhớ </em>xóa tất cả các reference tới vùng nhớ không còn dùng. Và thông thường, chuyện này không có gì phức tạp, chỉ cần trỏ reference tới vùng nhớ khác, tới null, hoặc để reference tự biến mất khi ra khỏi block chứa nó (chẳng hạn, khi method khai báo reference đó kết thúc). Nói chung là đa số được thực hiện một cách “vô tình”, tức là ta thậm chí không để ý là mình đang làm điều đó.</p>
<p>Nhưng có những tình huống mà chúng ta phải <em>chủ động</em> xóa reference, ví dụ như khi làm việc với Listener. Để A có thể nhận thông báo về các event mới trong B, nó phải được thêm vào danh sách Listener của B, giả sử bằng method addActionListener. Khi muốn kết thúc sự tồn tại của A, ta cần để đưa A ra khỏi danh sách, giả sử bằng removeActionListener. Đây là điều bắt buộc khi chúng ta muốn vùng nhớ của A có thể được thu hồi, vì chừng nào A còn nằm trong danh sách Listener thì vẫn còn reference trỏ đến nó. Tất nhiên, triển vọng là ta sẽ quên làm việc đó, như cái cách chúng ta quên giải phóng bộ nhớ trong C/C++. Chưa kể đến các tình huống đau đầu như có vài vị trí (ví dụ như vài nhánh if) có thể kết thúc A, đồng nghĩa với việc có vài vị trí cần gọi removeActionListener <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Như vậy, mặc dù phần mềm viết bằng Java không có kiểu memory leak như C/C++, nhưng vẫn có thể có những vùng nhớ không còn sử dụng, song cũng không thể bị thu hồi, đó chính là memory leak “kiểu Java”.</p>
<p>Chính vì lí do trên, Java cho chúng ta thêm một số dạng reference đặc biệt trong package java.lang.ref, là WeakReference (WR) và SoftReference (SR). Các reference này cũng được dùng để trỏ tới các vùng nhớ, như reference mà chúng ta vẫn quen dùng (giờ gọi là strong reference). Tuy nhiên, nếu vùng nhớ được trỏ tới bởi cả strong reference lẫn WR, thì khi strong reference cuối cùng bị xóa bỏ, vùng nhớ này có thể được thu hồi bởi GC, và WR không có khả năng ngăn cản điều đó. SR “strong” hơn WR một chút, nghĩa là vùng nhớ được trỏ tới bởi WR sẽ được GC ưu tiên thu hồi hơn (ưu tiên tới đâu thì phụ thuộc vào hiện thực của từng máy ảo Java). Bây giờ, nếu ta đưa A vào danh sách Listener qua một WR chứ không phải là strong reference, ta sẽ không cần bận tâm tới việc gọi removeActionListener khi muốn kết thúc A nữa. Chi tiết cách sử dụng WR và SR, tham khảo JDK documentation và Thinking in Java (ví dụ khá rõ, dù không nói nhiều về ý nghĩa của WR và SR).</p>
<p>Chú ý là với các ứng dụng thông thường, thì hiện tượng này nếu có cũng không làm máy cạn bộ nhớ được, vì vậy cũng không nhất thiết phải dùng đến SR và WR.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/java/'>Java</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/222/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=222&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/07/23/memory-leak-trong-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Những việc nhỏ gi&#250;p bảo vệ m&#244;i trường</title>
		<link>http://nmhblog.wordpress.com/2010/06/16/nh%e1%bb%afng-vi%e1%bb%87c-nh%e1%bb%8f-gip-b%e1%ba%a3o-v%e1%bb%87-mi-tr%c6%b0%e1%bb%9dng-2/</link>
		<comments>http://nmhblog.wordpress.com/2010/06/16/nh%e1%bb%afng-vi%e1%bb%87c-nh%e1%bb%8f-gip-b%e1%ba%a3o-v%e1%bb%87-mi-tr%c6%b0%e1%bb%9dng-2/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 12:09:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linh tinh]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/06/16/nh%e1%bb%afng-vi%e1%bb%87c-nh%e1%bb%8f-gip-b%e1%ba%a3o-v%e1%bb%87-mi-tr%c6%b0%e1%bb%9dng-2/</guid>
		<description><![CDATA[Có những việc nhỏ có thể giúp bảo vệ môi trường mà những người bình thường như chúng ta có thể làm được. Tác dụng của chúng khá hiển nhiên, vấn đề chỉ là ta không để ý thực hiện thôi. Và cách duy nhất để tạo ra thói quen gìn giữ môi trường là [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=530&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Có những việc nhỏ có thể giúp bảo vệ môi trường mà những người bình thường như chúng ta có thể làm được. Tác dụng của chúng khá hiển nhiên, vấn đề chỉ là ta không để ý thực hiện thôi. Và cách duy nhất để tạo ra thói quen gìn giữ môi trường là hành động, luôn ghi nhớ những việc nên làm và thực hiện nó ngay khi có thể.</p>
<ol>
<li>Giữ lại túi nylon sau khi mua hàng (ở siêu thị, nhà sách, v.v). Lần mua sắm sau hãy đem túi ấy đi để đựng đồ, góp phần (tuy rất rất nhỏ) giảm bớt nhu cầu dùng túi nylon. Việc dùng túi giấy ở Việt Nam còn xa mới phổ biến. Đơn giản nhưng khó nhớ.</li>
<li>Ngủ sớm. Đừng mất thời gian suy nghĩ làm việc sáng hay làm việc khuya hiệu quả hơn. Hãy suy nghĩ về việc làm việc sáng hay làm việc khuya dùng nhiều điện hơn.</li>
<li>Dùng giấy vệ sinh thật tiết kiệm. Bạn không cần cả mét khăn để lau một vết bẩn nhỏ. Bạn không cần phải lau miệng liên tục trong khi ăn. Dùng khăn vải thay cho giấy vệ sinh khi có thể, chẳng hạn như để lau các vết bẩn dạng khô, và việc giặt khăn thêm một cái khăn vải không đòi hỏi thêm xà bông so với hàng ngày. </li>
<li>Hạn chế bật đèn. Nhiều khi ta không cần ánh sáng nhưng cứ bật theo thói quen. Tận dụng ánh sáng mặt trời khi làm việc. Nếu nhà tắm có cửa sổ, đừng tắm quá muộn để có thể tận dụng ánh sáng mặt trời. </li>
<li>Hạn chế bật quạt. Cũng là một thói quen tương tự như bật đèn. Nếu không nóng và không có muỗi thì không nên mở quạt. Muốn thoáng? Mở cửa sổ ra. Cũng đừng mở máy lạnh quá to. HM thấy nhiều công ti nhân viên có hành động rất là kì quặc: mở máy lạnh to rồi mặc áo ấm, giữa mùa hè.</li>
<li>Tiết kiệm điện khi dùng máy tính. Tắt máy (hoặc hibernate, sleep) khi không dùng trong một thời gian dài, tắt màn hình nếu không dùng trong một thời gian ngắn. Giảm độ sáng màn hình và đừng vặn loa máy tính quá lớn, không những tiết kiệm điện mà còn bảo vệ đôi tai, đôi mắt quý giá của bạn.</li>
<li>Nếu hay dùng bút bi, xem xét chuyển sang dùng bút chì bấm nếu có thể. Đằng nào thì học sinh, sinh viên cũng đã có sẵn bút chì rồi. Bút bi thường làm bằng nhựa, và khi dùng xong thì chỉ có vất vào thùng rác, không sử dụng lại được bộ phận nào. Trong khi đó, việc phân loại rác thải ở Việt Nam còn rất hạn chế.</li>
</ol>
<p>Hành động nhỏ cho một thay đổi lớn.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/linh-tinh/'>linh tinh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/530/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/530/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/530/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=530&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/06/16/nh%e1%bb%afng-vi%e1%bb%87c-nh%e1%bb%8f-gip-b%e1%ba%a3o-v%e1%bb%87-mi-tr%c6%b0%e1%bb%9dng-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Bao đóng trong lập trình hướng đối tượng</title>
		<link>http://nmhblog.wordpress.com/2010/05/09/bao-dng/</link>
		<comments>http://nmhblog.wordpress.com/2010/05/09/bao-dng/#comments</comments>
		<pubDate>Sun, 09 May 2010 07:50:34 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình hướng đối tượng]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/05/08/bao-dng/</guid>
		<description><![CDATA[Bao đóng là che đi phần hiện thực của module, và chỉ cung cấp cho bên ngoài các chức năng của module. Mục đích là làm cho việc thay đổi trong hiện thực của một module (supplier) không ảnh hưởng tới các module đã sử dụng nó (gọi là client). Tuy nhiên, bao đóng thường [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=137&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Bao đóng là che đi phần hiện thực của module, và chỉ cung cấp cho bên ngoài các chức năng của module. Mục đích là làm cho việc thay đổi trong hiện thực của một module (supplier) không ảnh hưởng tới các module đã sử dụng nó (gọi là client).</p>
<p>Tuy nhiên, bao đóng thường bị hiểu sai thành che dấu thông tin một cách vật lý, ngăn cản client truy cập vào phần “bên trong” của supplier. Chính vì vậy mới có quan niệm cứ tạo private field, rồi sau đó tạo thêm các public <a href="http://nmhblog.wordpress.com/2010/03/01/gettersetter/" target="_blank">getter/setter</a> và thế là tính bao đóng vẫn được đảm bảo.</p>
<p>Bertrand Meyer trong Object-oriented software construction đã đưa ra một định nghĩa khác, nhằm tránh sự hiểu lầm trên. Bao đóng nghĩa là tính đúng đắn của các client chỉ có thể chứng minh dựa trên tính đúng đắn của các thuộc tính public của supplier. Nói cách khác, không thể viết được client chỉ có thể vận hành đúng đắn dựa vào các thuộc tính private của supplier.</p>
<p>Ví dụ, xét trường hợp một supplier cung cấp một cơ chế tìm kiếm trong bảng. Client của nó, chẳng hạn như một module trong chương trình bảng tính, sử dụng supplier trên để tìm kiếm các phần tử trong bảng. Bao đóng ở đây có nghĩa rằng, ngay cả khi người xây dựng client biết cụ thể supplier dùng tìm kiếm nhị phân hay bảng băm, họ cũng không thể viết ra một client chỉ chạy đúng với một trong hai phương pháp tìm kiếm, và sai với phương pháp còn lại.</p>
<p>Martin Fowler còn <a href="http://www.artima.com/lejava/articles/designprinciples2.html" target="_blank">đưa thêm thuật ngữ published</a> để tránh sự nhập nhằng này. Các thuộc tính public là các thuộc tính mà ngôn ngữ lập trình cho phép truy cập từ bên ngoài. Các thuộc tính published là các thuộc tính public mà người phát triển sẽ công bố cho cộng đồng. Chính các thuộc tính published sẽ cho thấy module có thỏa tính bao đóng hay không. Và Eclipse là một <a href="Điều n&agrave;y cũng c&oacute; nghĩa, c&aacute;c cơ chế public, private của c&aacute;c ng&ocirc;n ngữ lập tr&igrave;nh hướng đối tượng chỉ l&agrave; c&ocirc;ng cụ để việc bao đ&oacute;ng được thực hiện một c&aacute;ch hiệu quả. C&ograve;n việc một module c&oacute; thỏa m&atilde;n t&iacute;nh chất n&agrave;y kh&ocirc;ng c&ograve;n phụ thuộc v&agrave;o thiết kế của n&oacute;." target="_blank">ví dụ đáng kể</a> cho chính sách này.</p>
<p>Tóm lại, các cơ chế public, private của các ngôn ngữ lập trình chỉ là công cụ để việc bao đóng được thực hiện một cách gọn gàng và an toàn. Còn việc một module có thỏa mãn tính chất này không còn phụ thuộc vào thiết kế của nó.</p>
<p>Để khẳng định điều này, xin được minh họa một tính năng của Java, cho phép lấy giá trị của một private field của một object bên ngoài.</p>
<p><pre class="brush: java;">
import java.lang.reflect.Field;

class Foo { 
    private int bar = 100; 
}

public class EncapsulationExample { 
    public static void main(String[] args) throws Exception { 
        Foo foo = new Foo(); 
        Class c = foo.getClass(); 
        Field f = c.getDeclaredField(&quot;bar&quot;); 
        f.setAccessible(true); 
        Object o = f.get(foo); 
        System.out.println(o.toString()); // 100 
    } 
}
</pre></p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/'>lập trình hướng đối tượng</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=137&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/05/09/bao-dng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Lời giải cho quyển “Cryptography and network security”</title>
		<link>http://nmhblog.wordpress.com/2010/04/27/l%e1%bb%9di-gi%e1%ba%a3i-cho-quy%e1%bb%83n-cryptography-and-network-security/</link>
		<comments>http://nmhblog.wordpress.com/2010/04/27/l%e1%bb%9di-gi%e1%ba%a3i-cho-quy%e1%bb%83n-cryptography-and-network-security/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 01:59:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linh tinh]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/04/27/l%e1%bb%9di-gi%e1%ba%a3i-cho-quy%e1%bb%83n-cryptography-and-network-security/</guid>
		<description><![CDATA[Đây là lời giải của quyển “Cryptography and network security”, dùng trong môn “Mật mã và an ninh mạng” của BK. Mật khẩu là hm. Tagged: linh tinh<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=332&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://ifile.it/u32eahv" target="_blank">Đây</a> là lời giải của quyển “Cryptography and network security”, dùng trong môn “Mật mã và an ninh mạng” của BK. Mật khẩu là hm.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/linh-tinh/'>linh tinh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/332/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=332&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/04/27/l%e1%bb%9di-gi%e1%ba%a3i-cho-quy%e1%bb%83n-cryptography-and-network-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Tìm nghịch đảo theo phép đồng dư</title>
		<link>http://nmhblog.wordpress.com/2010/04/16/tim-ngh%e1%bb%8bch-d%e1%ba%a3o-theo-phep-d%e1%bb%93ng-d%c6%b0-da-ch%e1%bb%89nh-s%e1%bb%ada/</link>
		<comments>http://nmhblog.wordpress.com/2010/04/16/tim-ngh%e1%bb%8bch-d%e1%ba%a3o-theo-phep-d%e1%bb%93ng-d%c6%b0-da-ch%e1%bb%89nh-s%e1%bb%ada/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 04:07:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linh tinh]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/04/16/tim-ngh%e1%bb%8bch-d%e1%ba%a3o-theo-phep-d%e1%bb%93ng-d%c6%b0-da-ch%e1%bb%89nh-s%e1%bb%ada</guid>
		<description><![CDATA[Mình thật có duyên với cái thuật toán Euclide mở rộng để tìm nghịch đảo theo phép đồng dư và giải phương trình Diophantus tuyến tính này. Cứ mỗi lần trước khi thi cử là lại vác quyển Số học ra để gạo nó, mà gạo từ năm lớp 8 đến 12 vẫn không thuộc. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=26&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Mình thật có duyên với cái thuật toán Euclide mở rộng để tìm nghịch đảo theo phép đồng dư và giải phương trình Diophantus tuyến tính này. Cứ mỗi lần trước khi thi cử là lại vác quyển Số học ra để gạo nó, mà gạo từ năm lớp 8 đến 12 vẫn không thuộc. Và bây giờ đến năm thứ tư vẫn lại phải gạo nó T_T.</p>
<p>Vào chủ đề chính. Tình hình là vừa mới kiếm được cách tìm nghịch đảo theo phép đồng dư để chuẩn bị thi mật mã. Mà môn này mình thì cúp, còn hai đồng minh chiến lược thì ngủ, và khả năng là có một số anh em khác vừa ngủ vừa cúp, nên tranh thủ post lại cách giải lên đây.</p>
<p>Cách giải này tìm thấy trong chính quyển sách giáo khoa Cryptography and Network Security Principles and Practices <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (đừng đọc Wiki). Ta giả vờ nghiên cứu thuật toán đã.</p>
<p>Tìm nghịch đảo của b (tức là b<sup>-1</sup>) modulo m. <strong>Bắt buộc đưa về 0 &lt; b &lt; m.</strong></p>
<p>EXTENDED EUCLID(m, b)    <br />1. (A1, A2, A3) (1, 0, m); (B1, B2, B3) (0, 1, b)     <br />2. if B3 = 0 return A3 = gcd(m, b); no inverse     <br />3. if B3 = 1 return B3 = gcd(m, b); B2 = b1 mod m     <br />4. Q = thương của A3 / B3.     <br />5. (T1, T2, T3) &lt;- (A1 &#8211; QB1, A2 &#8211; QB2, A3 &#8211; QB3)     <br />6. (A1, A2, A3) &lt;- (B1, B2, B3)     <br />7. (B1, B2, B3) &lt;- (T1, T2, T3)     <br />8. goto 2</p>
<p>Ta luôn có mT1 + bT2 = T3 mA1 + bA2 = A3 mB1 + bB2 = B3.</p>
<p>Tất nhiên sinh viên BK làm gì có thời gian mà đọc cái này. Ta ví dụ luôn với b = 550, m = 1759 như sách giáo khoa, nhưng mình sửa lại cách kẻ bảng chút ít cho nó nhanh hơn :”&gt;.</p>
<p>Hàng đầu là 1, 0, m. Hàng hai là 0, 1, b. Chú ý hàng đầu là m. Và nhắc lại, <strong>bắt buộc đưa về 0 &lt; b &lt; m.</strong></p>
<table border="1" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="100">Q</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1759</td>
</tr>
<tr>
<td valign="top" width="100">&#160;</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">550</td>
</tr>
</tbody>
</table>
<p>Lấy hàng trên cột cuối chi hàng dưới cột cuối, tức là 1759 / 550. Thương là Q.</p>
<table border="1" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="100">Q</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1759</td>
</tr>
<tr>
<td valign="top" width="100">3</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">550</td>
</tr>
</tbody>
</table>
<p>Lấy Q nhân với hàng dưới (tức là 3 nhân với các số cùng hàng), rồi lấy hàng trên trừ đi kết quả, cột theo cột, được hàng tiếp.</p>
<table border="1" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="100">Q</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1759</td>
</tr>
<tr>
<td valign="top" width="100">3</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">550</td>
</tr>
<tr>
<td valign="top" width="100">&#160;</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">-3</td>
<td valign="top" width="100">109</td>
</tr>
</tbody>
</table>
<p>Và lại tính Q = 550 / 109. Làm thế cho đến khi số ở cột cuối là 1.</p>
<table border="1" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="100">Q</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1759</td>
</tr>
<tr>
<td valign="top" width="100">3</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">550</td>
</tr>
<tr>
<td valign="top" width="100">5</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">-3</td>
<td valign="top" width="100">109</td>
</tr>
<tr>
<td valign="top" width="100">21</td>
<td valign="top" width="100">-5</td>
<td valign="top" width="100">16</td>
<td valign="top" width="100">5</td>
</tr>
<tr>
<td valign="top" width="100">1</td>
<td valign="top" width="100">106</td>
<td valign="top" width="100">-339</td>
<td valign="top" width="100">4</td>
</tr>
<tr>
<td valign="top" width="100">&#160;</td>
<td valign="top" width="100">-111</td>
<td valign="top" width="100"><strong>355</strong></td>
<td valign="top" width="100"><strong>1</strong></td>
</tr>
</tbody>
</table>
<p>Và số cạnh số 1 đó (số 355) là nghịch đảo của 550 modulo 1759, hay 355 * 550 = 1 (mod 1759).</p>
<p>Tất nhiên nếu bạn chưa gặp số 1 mà đã gặp 0 rồi thì tức là không có nghịch đảo.</p>
<table border="1" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="100">Q</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">15</td>
</tr>
<tr>
<td valign="top" width="100">1</td>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">12</td>
</tr>
<tr>
<td valign="top" width="100">4</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">-1</td>
<td valign="top" width="100"><strong>3</strong></td>
</tr>
<tr>
<td valign="top" width="100">&#160;</td>
<td valign="top" width="100">-4</td>
<td valign="top" width="100">5</td>
<td valign="top" width="100"><strong>0</strong></td>
</tr>
</tbody>
</table>
<p>Khi đó số trên số 0 là ước chung lớn nhất (tức là 3), và hai số cùng hàng với 3 là 1 và –1 có tính chất 15 * 1 + 12 * (-1) = 3.</p>
<p>Trường hợp 1759 mà làm tiếp thì cũng sẽ gặp 0, có điều việc làm tiếp là không cần thiết. Dĩ nhiên 1759 * (-111) + 550 * 355 = 1.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/linh-tinh/'>linh tinh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=26&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/04/16/tim-ngh%e1%bb%8bch-d%e1%ba%a3o-theo-phep-d%e1%bb%93ng-d%c6%b0-da-ch%e1%bb%89nh-s%e1%bb%ada/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Word 2007 – bullet, numbering, multilevel list</title>
		<link>http://nmhblog.wordpress.com/2010/04/15/word-2007-%e2%80%93-bullet-numbering-multilevel-list/</link>
		<comments>http://nmhblog.wordpress.com/2010/04/15/word-2007-%e2%80%93-bullet-numbering-multilevel-list/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 03:00:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/04/15/word-2007-%e2%80%93-bullet-numbering-multilevel-list</guid>
		<description><![CDATA[Khỏi cần nói thì ai cũng biết bullet, numbering, và multilevel list (gọi chung là list) là một trong những thứ khá khó chịu trong Word. Hôm nay chỉ nói list dạng bullet. Di chuyển trong list Cái này quá đơn giản. Muốn item trở thành cấp con, dùng Tab. Muốn item trở thành cấp [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=25&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Khỏi cần nói thì ai cũng biết bullet, numbering, và multilevel list (gọi chung là list) là một trong những thứ khá khó chịu trong Word. Hôm nay chỉ nói list dạng bullet.</p>
<p><strong>Di chuyển trong list</strong></p>
<p>Cái này quá đơn giản. Muốn item trở thành cấp con, dùng Tab. Muốn item trở thành cấp cao hơn, khi item trống, ấn Enter (xem hình), đừng dùng nút Decrease. Muốn đưa một item đã có lên cấp cao hơn, dùng Shift + Tab. Cũng dùng Enter để tắt chế độ list, đừng dùng nút Bullets (xem hình).</p>
<p><a href="http://lh6.ggpht.com/__AVcF151eXQ/S8bjhvnlA_I/AAAAAAAAAew/pR61NyaUlW4/s1600-h/image%5B5%5D.png"><img title="image" border="0" alt="image" src="http://lh3.ggpht.com/__AVcF151eXQ/S8bjiZ636YI/AAAAAAAAAe0/CHFna-QkdkE/image_thumb%5B1%5D.png?imgmax=800" width="176" height="89" /></a></p>
<p>Enter liên tục:</p>
<p><a href="http://lh3.ggpht.com/__AVcF151eXQ/S8bjizzdOBI/AAAAAAAAAe4/L2orqBrleDk/s1600-h/image%5B8%5D.png"><img title="image" border="0" alt="image" src="http://lh6.ggpht.com/__AVcF151eXQ/S8bjjRpmZqI/AAAAAAAAAe8/Ijupxjq62r0/image_thumb%5B2%5D.png?imgmax=800" width="179" height="97" /></a>&#160;<a href="http://lh4.ggpht.com/__AVcF151eXQ/S8bjj-DmolI/AAAAAAAAAfA/RRfk8K0a1h0/s1600-h/image%5B11%5D.png"><img title="image" border="0" alt="image" src="http://lh4.ggpht.com/__AVcF151eXQ/S8bjkmbr97I/AAAAAAAAAfE/NgBysNGg2vY/image_thumb%5B3%5D.png?imgmax=800" width="182" height="95" /></a> <a href="http://lh6.ggpht.com/__AVcF151eXQ/S8bjlOCzemI/AAAAAAAAAfI/3ku4nEVRDY4/s1600-h/image%5B17%5D.png"><img title="image" border="0" alt="image" src="http://lh5.ggpht.com/__AVcF151eXQ/S8bjlkoQ8YI/AAAAAAAAAfM/-lrKcGK5Z0Q/image_thumb%5B5%5D.png?imgmax=800" width="203" height="100" /></a></p>
<p><strong>Tạo list</strong></p>
<p>Tạo list bằng nút Bullets. Với list có sẵn, tạo item mới bằng cách Enter (xuống dòng) từ item cũ, đừng dùng Bullets. Chỉ dùng nút Bullets khi tạo list mới.</p>
<p>Tất nhiên, tạo list kiểu này sẽ gây ra một số vấn đề rắc rối. Đó là khi sau này bạn muốn sửa lại bullet thành hình khác, hoặc muốn tăng giảm khoảng cách của bullet với chữ, v.v. Điều này hiếm khi cần thiết, tuy nhiên nếu bạn quan tâm, xin đọc tiếp.</p>
<p><strong>Tạo list (kiểu 2)</strong></p>
<p>Để có thể thay đổi định dạng list dễ dàng trong tương lai, chúng ta sẽ tạo một list style. Mặc định Word không có một list style nào hết (hơi dở).</p>
<p>Bước 1:</p>
<p><a href="http://lh6.ggpht.com/__AVcF151eXQ/S8bjmRjeswI/AAAAAAAAAfQ/WFy3T57SaW8/s1600-h/image%5B25%5D.png"><img title="image" border="0" alt="image" src="http://lh5.ggpht.com/__AVcF151eXQ/S8bjnEa-2WI/AAAAAAAAAfU/7b1s6PkU7AE/image_thumb%5B9%5D.png?imgmax=800" width="288" height="522" /></a></p>
<p>Bước 2: Mục Name đặt tên cho style mới, sau đó bấm vào nút Format chọn Numbering để đổi bullet.</p>
<p><a href="http://lh4.ggpht.com/__AVcF151eXQ/S8bjn-U6kOI/AAAAAAAAAfY/6JZwZMNsrx0/s1600-h/image%5B29%5D.png"><img title="image" border="0" alt="image" src="http://lh5.ggpht.com/__AVcF151eXQ/S8bjojKIp8I/AAAAAAAAAfc/-5iR5izVI0g/image_thumb%5B11%5D.png?imgmax=800" width="417" height="427" /></a></p>
<p>Bước 3: Nếu không ưng ý với bullet có sẵn, chọn New Bullet.</p>
<p><a href="http://lh3.ggpht.com/__AVcF151eXQ/S8bjpZMvsoI/AAAAAAAAAfg/KTwg84fmPXk/s1600-h/image%5B33%5D.png"><img title="image" border="0" alt="image" src="http://lh5.ggpht.com/__AVcF151eXQ/S8bjqXXlzDI/AAAAAAAAAfk/Rk35YkOaqbI/image_thumb%5B13%5D.png?imgmax=800" width="400" height="451" /></a></p>
<p>Nên chọn bullet từ font Symbol:</p>
<p><a href="http://lh3.ggpht.com/__AVcF151eXQ/S8bjrHyAEhI/AAAAAAAAAfo/gGiG5ZCkAc0/s1600-h/image%5B56%5D.png"><img title="image" border="0" alt="image" src="http://lh6.ggpht.com/__AVcF151eXQ/S8bjsEAzYKI/AAAAAAAAAfs/tQoi4XeHZLw/image_thumb%5B24%5D.png?imgmax=800" width="418" height="306" /></a></p>
<p>Sau đó, OK, OK và OK. Bây giờ chọn style mới tạo (My style) và thử thôi:</p>
<p><a href="http://lh5.ggpht.com/__AVcF151eXQ/S8bjtNFuwcI/AAAAAAAAAfw/LGctqqB4Cto/s1600-h/image%5B37%5D.png"><img title="image" border="0" alt="image" src="http://lh6.ggpht.com/__AVcF151eXQ/S8bjt7a01zI/AAAAAAAAAf0/XdPQE7h8jas/image_thumb%5B15%5D.png?imgmax=800" width="319" height="617" /></a></p>
<p>Vì là LaTeX fanboy nên mình sẽ bắt chước bullet trong LaTeX (tròn, gạch, hoa thị). Có vẻ đẹp hơn mặc định của Word <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p><a href="http://lh3.ggpht.com/__AVcF151eXQ/S8bjuXSXAfI/AAAAAAAAAf4/TGW7Du0hc1I/s1600-h/image%5B41%5D.png"><img title="image" border="0" alt="image" src="http://lh5.ggpht.com/__AVcF151eXQ/S8bjvEKSRMI/AAAAAAAAAf8/E1oEXPwJ1z0/image_thumb%5B17%5D.png?imgmax=800" width="96" height="262" /></a></p>
<p>Bây giờ giả sử bạn muốn sửa. Ấn chuột phải vào style của bạn và chọn Modify:</p>
<p><a href="http://lh4.ggpht.com/__AVcF151eXQ/S8bjwLW5nAI/AAAAAAAAAgA/neUcoQODuic/s1600-h/image%5B45%5D.png"><img title="image" border="0" alt="image" src="http://lh5.ggpht.com/__AVcF151eXQ/S8bjxAIujpI/AAAAAAAAAgE/nB7uPW1oK_8/image_thumb%5B19%5D.png?imgmax=800" width="322" height="613" /></a></p>
<p>Cửa sổ này y hệt ở bước 2 thôi, trừ cái tên.</p>
<p><a href="http://lh6.ggpht.com/__AVcF151eXQ/S8bjyORbI_I/AAAAAAAAAgI/78XuzOJcyx4/s1600-h/image%5B49%5D.png"><img title="image" border="0" alt="image" src="http://lh6.ggpht.com/__AVcF151eXQ/S8bjy_c0keI/AAAAAAAAAgM/sf6QfZp5LWc/image_thumb%5B21%5D.png?imgmax=800" width="423" height="433" /></a></p>
<p>Sau khi sửa style, tất cả các list sẽ tự động thay đổi theo:</p>
<p><a href="http://lh4.ggpht.com/__AVcF151eXQ/S8bjzQgM39I/AAAAAAAAAgQ/zaqoM77mj4A/s1600-h/image%5B52%5D.png"><img title="image" border="0" alt="image" src="http://lh6.ggpht.com/__AVcF151eXQ/S8bj0HbvcJI/AAAAAAAAAgU/X8BWMr_bfA8/image_thumb%5B22%5D.png?imgmax=800" width="97" height="225" /></a></p>
<p>Tạo list kiểu này thật đơn giản và tiện dụng. Cái này không thấy sách ghi, phải đào bới trong mục Help và thử nghiệm rất vất vả mới thành công <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> .</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/word/'>Word</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=25&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/04/15/word-2007-%e2%80%93-bullet-numbering-multilevel-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>

		<media:content url="http://lh3.ggpht.com/__AVcF151eXQ/S8bjiZ636YI/AAAAAAAAAe0/CHFna-QkdkE/image_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S8bjjRpmZqI/AAAAAAAAAe8/Ijupxjq62r0/image_thumb%5B2%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/__AVcF151eXQ/S8bjkmbr97I/AAAAAAAAAfE/NgBysNGg2vY/image_thumb%5B3%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/__AVcF151eXQ/S8bjlkoQ8YI/AAAAAAAAAfM/-lrKcGK5Z0Q/image_thumb%5B5%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/__AVcF151eXQ/S8bjnEa-2WI/AAAAAAAAAfU/7b1s6PkU7AE/image_thumb%5B9%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/__AVcF151eXQ/S8bjojKIp8I/AAAAAAAAAfc/-5iR5izVI0g/image_thumb%5B11%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/__AVcF151eXQ/S8bjqXXlzDI/AAAAAAAAAfk/Rk35YkOaqbI/image_thumb%5B13%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S8bjsEAzYKI/AAAAAAAAAfs/tQoi4XeHZLw/image_thumb%5B24%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S8bjt7a01zI/AAAAAAAAAf0/XdPQE7h8jas/image_thumb%5B15%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/__AVcF151eXQ/S8bjvEKSRMI/AAAAAAAAAf8/E1oEXPwJ1z0/image_thumb%5B17%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/__AVcF151eXQ/S8bjxAIujpI/AAAAAAAAAgE/nB7uPW1oK_8/image_thumb%5B19%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S8bjy_c0keI/AAAAAAAAAgM/sf6QfZp5LWc/image_thumb%5B21%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S8bj0HbvcJI/AAAAAAAAAgU/X8BWMr_bfA8/image_thumb%5B22%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Unicode tổ hợp hay dựng sẵn trong Word 2007</title>
		<link>http://nmhblog.wordpress.com/2010/04/10/unicode-t%e1%bb%95-h%e1%bb%a3p-hay-d%e1%bb%b1ng-s%e1%ba%b5n-trong-word-2007/</link>
		<comments>http://nmhblog.wordpress.com/2010/04/10/unicode-t%e1%bb%95-h%e1%bb%a3p-hay-d%e1%bb%b1ng-s%e1%ba%b5n-trong-word-2007/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 01:04:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">https://nmhblog.wordpress.com/2010/04/10/unicode-t%e1%bb%95-h%e1%bb%a3p-hay-d%e1%bb%b1ng-s%e1%ba%b5n-trong-word-2007/</guid>
		<description><![CDATA[Có lẽ bạn chỉ cần Unicode tổ hợp khi bạn muốn xài style có kiểu chữ dạng ? (không biết tên, LaTeX gọi là smallcap, dạng giống như chữ “Dựng sẵn” và “Tổ hợp” trong hình dưới). Word tạo ra chữ smallcap bằng cách thu các chữ in hoa nhỏ lại một chút. Ví dụ, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=328&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Có lẽ bạn chỉ cần Unicode tổ hợp khi bạn muốn xài style có kiểu chữ dạng ? (không biết tên, LaTeX gọi là smallcap, dạng giống như chữ “Dựng sẵn” và “Tổ hợp” trong hình dưới).</p>
<p><a href="http://lh6.ggpht.com/__AVcF151eXQ/S783jNMCucI/AAAAAAAAAeM/R98Cky1qCG8/s1600-h/image%5B8%5D.png"><img title="image" border="0" alt="image" src="http://lh5.ggpht.com/__AVcF151eXQ/S783js3nunI/AAAAAAAAAeQ/GJpbgcoYaEY/image_thumb%5B4%5D.png?imgmax=800" width="99" height="64" /></a></p>
<p>Word tạo ra chữ smallcap bằng cách thu các chữ in hoa nhỏ lại một chút. Ví dụ, chữ “Dựng sẵn” trong style thường là “Dựng sẵn”, khi bạn (theo ý thích) chuyển sang smallcap, Word sẽ lấy chữ viết hoa tương ứng (ví dụ, dạng viết hoa tương ứng của “ự” là “Ự”) thu nhỏ lại, nhưng vì Word không biết chữ “ự” (gồm chữ “ư” và dấu nặng) viết hoa sao, cho nên nó vẫn để “ự” thay vì “Ự”. Với Unicode tổ hợp, Word sẽ viết hoa chữ cái (“ư” thành “Ư”), rồi ghép thêm dấu nặng vào, cho nên smallcap cho tổ hợp chạy tốt.</p>
<p>Nếu bạn thấy rắc rối, thì nên dùng Unicode dựng sẵn và tránh xa các template có kiểu chữ smallcap ra. Hơn nữa, các chương trình gõ tiếng Việt thường mặc định dùng Unicode dựng sẵn, nếu bạn muốn dùng Unicode tổ hợp thì phải lưu ý cả những người cùng soạn thảo.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/word/'>Word</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/328/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=328&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/04/10/unicode-t%e1%bb%95-h%e1%bb%a3p-hay-d%e1%bb%b1ng-s%e1%ba%b5n-trong-word-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/__AVcF151eXQ/S783js3nunI/AAAAAAAAAeQ/GJpbgcoYaEY/image_thumb%5B4%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Vài lưu ý khi soạn thảo với Word 2007</title>
		<link>http://nmhblog.wordpress.com/2010/04/09/word-2007/</link>
		<comments>http://nmhblog.wordpress.com/2010/04/09/word-2007/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 00:54:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/04/09/word-2007-%e2%80%93-linh-tinh</guid>
		<description><![CDATA[Tình hình là thấy có người google “trích nguồn trong word” và nhảy vô trúng bài này. Thật vui khi bài viết của mình hữu ích cho ai đó . Đã vậy thì tiện đây sẽ làm luôn một loạt bài về Word 2007, đằng nào thì cũng phải luyện để làm đồ án cho [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=24&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tình hình là thấy có người google “trích nguồn trong word” và nhảy vô trúng <a href="http://nmhblog.wordpress.com/2010/04/07/cach-trich-nguon-trong-word-2007/" target="_blank">bài này</a>. Thật vui khi bài viết của mình hữu ích cho ai đó <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Đã vậy thì tiện đây sẽ làm luôn một loạt bài về Word 2007, đằng nào thì cũng phải luyện để làm đồ án cho ngon lành. Nội dung là các kinh nghiệm đơn giản để giúp soạn thảo bằng Word vừa nhanh vừa đẹp (đẹp về cấu trúc trước, thẩm mĩ sau). Chú ý ai đó nếu đọc thì phải nhớ đây chỉ là “kinh nghiệm”, tức là có tốt, có xấu, và có thể không cho cùng kết quả với bạn. Để cho an toàn thì các bạn nên có chút gì đó phòng thân, như “Micrsoft Word 2007 bible” và “Special edition using Microsoft Office Word 2007” (chữ “Special edition” đi kèm tên sách chứ không phải mình ghi thừa). Và tất nhiên, không thể bỏ qua chức năng Help của Word.</p>
<p>Trước hết, nếu muốn tạo một văn bản xịn trong Word thì các bạn phải quên mục Font trong tab Home đi đã. Chính xác hơn là đừng có ngứa tay tô đậm, làm nghiêng, gạch chân màu mè hoa lá gì đó. Có hai lí do cho điều này (mà ai đọc về HTML rồi thì cũng hiểu ngay là tại sao). Thứ nhất, định dạng của mình chắc chắn là xấu hơn định dạng có sẵn. Thứ hai, là nếu sau này có hối hận và muốn sửa thì cũng chả sửa được, trừ khi siêng năng soát lại toàn bộ văn bản. Nếu các bạn muốn nhấn mạnh một đoạn văn bản (thường sẽ là in nghiêng), hãy định nghĩa một style “nhấn mạnh” và gán style này cho đoạn văn bản đó. Nếu sau này có đổi ý muốn nhấn mạnh văn bản bằng chứ in đậm thì chỉ cần định nghĩa style là xong. (Nói thêm là Word cũng có sẵn kiểu “nhấn mạnh” rồi, đó là “Emphasis”.)</p>
<p>Vậy, điều đầu tiên là chỉ dùng cái bảng dưới đây để định dạng thôi, và chỉ dùng đến mục Font để định nghĩa style (và tốt hơn hết không nên làm việc này lúc đầu, tập trung vào nội dung đã).</p>
<p><a href="http://lh6.ggpht.com/__AVcF151eXQ/S783ZmHU7CI/AAAAAAAAAd0/Hyc_5r9vaIo/s1600-h/image%5B5%5D.png"><img title="image" border="0" alt="image" src="http://lh3.ggpht.com/__AVcF151eXQ/S783bM3HKtI/AAAAAAAAAd4/bUKxkJu7ZL8/image_thumb%5B3%5D.png?imgmax=800" width="416" height="232" /></a></p>
<p>Tuân thủ điều này 100%, và việc đổi cách trình bày văn bản sẽ chỉ cần một hai cú chuột (để chọn style phù hợp). Toàn style làm sẵn, nên rất đẹp:</p>
<p><a href="http://lh4.ggpht.com/__AVcF151eXQ/S783cwpFKUI/AAAAAAAAAd8/bgWgQoMc2Kk/s1600-h/Untitled1%5B5%5D.png"><img title="Untitled1" border="0" alt="Untitled1" src="http://lh6.ggpht.com/__AVcF151eXQ/S783eVPFNlI/AAAAAAAAAeA/HiB0rgbj0CI/Untitled1_thumb%5B3%5D.png?imgmax=800" width="499" height="442" /></a></p>
<p><a href="http://lh4.ggpht.com/__AVcF151eXQ/S783gor-PwI/AAAAAAAAAeE/PvguqQDlKyY/s1600-h/Untitled2%5B3%5D.png"><img title="Untitled2" border="0" alt="Untitled2" src="http://lh4.ggpht.com/__AVcF151eXQ/S783iXdfTPI/AAAAAAAAAeI/Qk-qBzgLB0Q/Untitled2_thumb%5B1%5D.png?imgmax=800" width="500" height="444" /></a></p>
<p>Điều cần làm thứ hai là vào mục Show/Hide trong tab View và bật Document Map lên. Nó sẽ cho bạn một bảng mục lục tài liệu bên tay trái để nhảy qua nhảy lại trong văn bản rất là tiện lợi. (Nhìn hình ở trên.)</p>
<p>Tiếp theo xuống góc dưới bên phải và chọn Web Layout (biểu tượng quả cầu xanh). Như thế bạn sẽ không phải bận tâm về header, footer, qua trang, lề trái phải, v.v. Như đã nói, tập trung vào nội dung đã. Giờ chỉ còn một băng giấy dài với độ rộng bằng bề ngang cửa sổ thôi. (Cũng có trong hình ở trên.)</p>
<p>Bây giờ chúng ta có thể bắt tay vào soạn thảo được rồi.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/word/'>Word</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=24&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/04/09/word-2007/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>

		<media:content url="http://lh3.ggpht.com/__AVcF151eXQ/S783bM3HKtI/AAAAAAAAAd4/bUKxkJu7ZL8/image_thumb%5B3%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S783eVPFNlI/AAAAAAAAAeA/HiB0rgbj0CI/Untitled1_thumb%5B3%5D.png?imgmax=800" medium="image">
			<media:title type="html">Untitled1</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/__AVcF151eXQ/S783iXdfTPI/AAAAAAAAAeI/Qk-qBzgLB0Q/Untitled2_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">Untitled2</media:title>
		</media:content>
	</item>
		<item>
		<title>Cách trích nguồn trong Word 2007</title>
		<link>http://nmhblog.wordpress.com/2010/04/07/cach-trich-nguon-trong-word-2007/</link>
		<comments>http://nmhblog.wordpress.com/2010/04/07/cach-trich-nguon-trong-word-2007/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 08:43:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/04/07/word-2007-%e2%80%93-cach-trich-ngu%e1%bb%93n</guid>
		<description><![CDATA[Mới tìm ra một bộ style trích nguồn cho Word 2007 cực ngon nên phải chia sẻ ngay cho anh em. Với cái này thì có thể để LaTeX yên nghỉ được rồi. Xem hướng dẫn cài đặt và tải xuống ở đây (chỉ nên tải BibWord styles thôi). Trong này có IEEE là style [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=23&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Mới tìm ra một bộ style trích nguồn cho Word 2007 cực ngon nên phải chia sẻ ngay cho anh em. Với cái này thì có thể để LaTeX yên nghỉ được rồi.</p>
<p>Xem hướng dẫn cài đặt và tải xuống ở <a href="http://bibword.codeplex.com/releases/view/15852" target="_blank">đây</a> (chỉ nên tải BibWord styles thôi). Trong này có IEEE là style thường thấy trong các paper.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Phần này dành cho ai chưa từng xài tính năng citation trong Word 2007. Trước hết xem hình đã.</p>
<p><a href="http://lh5.ggpht.com/__AVcF151eXQ/S8Lh5oCIH4I/AAAAAAAAAeU/43pr6VPioOA/s1600-h/image%5B1%5D.png"><img title="image" border="0" alt="image" src="http://lh6.ggpht.com/__AVcF151eXQ/S7yn08wC9nI/AAAAAAAAAeY/eosOUEaeW6E/image_thumb.png?imgmax=800" width="499" height="263" /></a></p>
<p>Nếu gõ cái đoạn vừa rồi bằng tay thì vừa xấu vừa mất công, mà mỗi lần trích dẫn phải tra lại, còn xóa hoặc chèn thêm thì chắc là không tưởng (ví dụ sửa [4] thành [3] đồng nghĩa với việc phải lục lại toàn bộ tài liệu).</p>
<p><strong>Thêm nguồn tham khảo</strong></p>
<p>Vào References &gt; Manage Sources (trong cụm Citations &amp; Bibliography). Nó ra cái bảng này:</p>
<p><a href="http://lh3.ggpht.com/__AVcF151eXQ/S7yn5cn1COI/AAAAAAAAAeg/6KwJSQqPQJ8/s1600-h/image7%5B1%5D.png"><img title="image" border="0" alt="image" src="http://lh3.ggpht.com/__AVcF151eXQ/S7yn80OzJBI/AAAAAAAAAeo/Az8NvcgtTBo/image7_thumb.png?imgmax=800" width="503" height="345" /></a></p>
<p>Muốn thêm thì chọn New. Dễ tới mức không cần hướng dẫn thêm. Có mấy “Type of Source” hay gặp là “Book”, “Web site”, “Report”, “Conference Proceedings”, v.v</p>
<p>Có một chú ý nhỏ là để nhập tên tác giả nên dùng chức năng “Edit” để nhập riêng tên, họ, chữ lót. Chức năng này cũng cần thiết khi phải nhập nhiều tác giả.</p>
<p><strong>Chèn trích dẫn</strong></p>
<p><a href="http://lh4.ggpht.com/__AVcF151eXQ/S7yn_25UEmI/AAAAAAAAAdk/CG6LwiFQn8I/s1600-h/image%5B16%5D.png"><img title="image" border="0" alt="image" src="http://lh4.ggpht.com/__AVcF151eXQ/S7yoDok1UfI/AAAAAAAAAdo/6Y-0zkICqr0/image_thumb%5B8%5D.png?imgmax=800" width="323" height="484" /></a></p>
<p>Với Style IEEE, có một chú ý nhỏ. Nếu trích dẫn cùng lúc nhiều nguồn, thì thay vì để “[1][2]” thì nên để là “[1, 2]” bằng cách chèn “[1]” rồi để con trỏ vào trong “[1]” chèn “[2]”. Nó sẽ tự chuyển thành “[1, 2]”.</p>
<p><strong>Tạo danh sách</strong></p>
<p><a href="http://lh3.ggpht.com/__AVcF151eXQ/S7yoFLcyg1I/AAAAAAAAAds/9o9jyO080aw/s1600-h/image%5B24%5D.png"><img title="image" border="0" alt="image" src="http://lh6.ggpht.com/__AVcF151eXQ/S7yoH3KS-NI/AAAAAAAAAdw/JrFzQ7NGt6Y/image_thumb%5B14%5D.png?imgmax=800" width="398" height="350" /></a></p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/word/'>Word</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=23&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/04/07/cach-trich-nguon-trong-word-2007/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S7yn08wC9nI/AAAAAAAAAeY/eosOUEaeW6E/image_thumb.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh3.ggpht.com/__AVcF151eXQ/S7yn80OzJBI/AAAAAAAAAeo/Az8NvcgtTBo/image7_thumb.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/__AVcF151eXQ/S7yoDok1UfI/AAAAAAAAAdo/6Y-0zkICqr0/image_thumb%5B8%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S7yoH3KS-NI/AAAAAAAAAdw/JrFzQ7NGt6Y/image_thumb%5B14%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Linux mập</title>
		<link>http://nmhblog.wordpress.com/2010/03/31/linux-m%e1%ba%adp/</link>
		<comments>http://nmhblog.wordpress.com/2010/03/31/linux-m%e1%ba%adp/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 00:37:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/03/31/linux-m%e1%ba%adp</guid>
		<description><![CDATA[Trước hết nói về pipeline, niềm tự hào Unix. Ví dụ về đoạn mã kiểm tra chính tả (chép từ wikipedia): Giải thích ngắn gọn: curl lấy nội dung trang web sed chuyển kí tự không phải chữ cái và khoảng trắng thành khoảng trắng tr chuyển chữ hoa thành chữ thường và khoảng trắng [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=22&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Trước hết nói về pipeline, niềm tự hào Unix. Ví dụ về đoạn mã kiểm tra chính tả (chép từ wikipedia):</p>
<p><pre class="brush: plain;">curl &quot;http://en.wikipedia.org/wiki/Pipeline_(Unix)&quot; | \
sed 's/[^a-zA-Z ]/ /g' | \
tr 'A-Z ' 'a-z\n' | \
grep '[a-z]' | \
sort -u | \
comm -23 - /usr/share/dict/words</pre></p>
<p>Giải thích ngắn gọn:</p>
<ul>
<li><code>curl</code> lấy nội dung trang web </li>
<li><code>sed</code> chuyển kí tự không phải chữ cái và khoảng trắng thành khoảng trắng </li>
<li><code>tr</code> chuyển chữ hoa thành chữ thường và khoảng trắng thành dấu xuống dòng </li>
<li><code>grep</code> bỏ các dòng trống </li>
<li><code>sort</code> xếp từ theo thứ tự và bỏ từ lặp </li>
<li><code>comm</code> để lấy ra từ không có trong từ điển </li>
</ul>
<p>Cái triết lí của Unix “Write programs that do one thing and do it well&quot; cũng từ pipeline mà ra. Chính xác hơn, là từ câu nói của Doug Mcllroy, người phát minh ra pipe trong Unix:</p>
<blockquote>
<p>This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.</p>
</blockquote>
<p>Trong quyển “Pattern-oriented software architecture”, khái niệm này còn có tên có tuổi hẳn hoi: Pipes and Filters pattern, một trong ba architectural pattern (pattern để xây dựng kiến trúc tổng quát cho phần mềm).</p>
<p>Mà kể ra thì pipeline nhìn cũng đẹp thật, gọn gàng, hiệu quả. Cho nên các Linux fanboy (như mình ngày xưa) hay lấy nó làm cái cớ hạ Windows xuống và vênh mặt lên tự hào (nói nữa sợ mất tính khách quan). Tiếc là “Write programs that do one thing and do it well” chỉ còn là quá khứ. Bạn thử nhìn vào hình dưới và đọc những dòng màu xanh nước biển:</p>
<p>&#160;<a href="http://lh5.ggpht.com/__AVcF151eXQ/S7L7rIxyozI/AAAAAAAAAdI/TCSxv6j_yRc/s1600-h/Untitled1%5B3%5D.png"><img title="Untitled1" border="0" alt="Untitled1" src="http://lh4.ggpht.com/__AVcF151eXQ/S7L7sf2gkAI/AAAAAAAAAdM/Nzm3lyQHs1c/Untitled1_thumb%5B1%5D.png?imgmax=800" width="345" height="305" /></a></p>
<p>Tất nhiên là gần như không thể đọc được. Bởi vì cái ls này đã quá ham hố làm hai thứ: liệt kê thư mục và định dạng dữ liệu xuất (chia cột, tô màu). Mà nó lại không làm tốt việc tô màu.</p>
<p>Không phải mình tự nghĩ ra đâu, mà là Rob Pike và Brian W. Kernighan (đồng tác giả “The C Programming Language”) nói thế trong paper “Program design in the UNIX environment”:</p>
<blockquote>
<p>An example of the first approach is Berkeley’s version of the ls command, which lists the filenames in a directory. Let us call it lsc to avoid confusion. The 7th Edition ls command lists filenames in a single column, so for a large directory, the list of filenames disappears off the top of the screen at great speed. lsc prints in columns across the screen (which is assumed to be 80 columns wide), so there are typically four to eight times as many names on each line, and thus the output usually fits on one screen. The option -1 can be used to get the old single-column behavior.</p>
<p>…The automatic columnation in lsc is reminiscent of the ‘‘wild cards’’ found in some systems that provide filename pattern matching only for a particular program. The experience with centralized processing of wild cards in the UNIX shell shows overwhelmingly how important it is to centralize the function where it can be used by all programs.</p>
<p>One solution for the ls problem is obvious — a separate program for columnation, so that columnation into say 5 columns is just ls | 5…</p>
</blockquote>
<p>Thế nên đừng tường cứ có pipe được là thành “do one thing and do it well”.</p>
<p>Chuyện này có từ thời BSD, nhưng thôi cứ chửi GNU cho tiện (vì bây giờ GNU rất phổ biến trên Linux). Vậy là từ cái đống lệnh pipe phức tạp nhưng dễ quản lí (vì mỗi người một việc) bây giờ chúng ta có một đống lệnh pipe phức tạp và khó quản lí (nhiều người cũng làm được một việc, chọn ai bây giờ). Tốt nhất là cứ theo kiểu Windows, thân ai người đấy lo, thiếu chức năng thì viết lệnh mới.</p>
<p>Dùng câu này trong “Pattern-oriented software architecture” để kết là hợp nhất:</p>
<blockquote>
<p>The Pipes and Filters pattern, in contrast, is less often used, but is attractive in areas where data streams can be processed incrementally. Surprisingly, some system families modelled in this fashion turn out to be poor candidates for this paradigm, neglecting areas where this pattern could be used more beneficially.</p>
</blockquote>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/linux/'>Linux</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=22&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/03/31/linux-m%e1%ba%adp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/__AVcF151eXQ/S7L7sf2gkAI/AAAAAAAAAdM/Nzm3lyQHs1c/Untitled1_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">Untitled1</media:title>
		</media:content>
	</item>
		<item>
		<title>Checked exception trong Java</title>
		<link>http://nmhblog.wordpress.com/2010/03/28/checked-exception-trong-java-va-c-ti%e1%ba%bfp/</link>
		<comments>http://nmhblog.wordpress.com/2010/03/28/checked-exception-trong-java-va-c-ti%e1%ba%bfp/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 01:36:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/03/28/checked-exception-trong-java-va-c-ti%e1%ba%bfp</guid>
		<description><![CDATA[Tiếp chuyện hôm trước, nhưng hôm nay không có C#. Không quan tâm tới chuyện checked exception trong Java hay dở thế nào nữa, tại vì chúng ta không phải là Sun. Họ làm sao là quyền của họ. Việc của chúng ta là làm theo ý họ theo cách tốt nhất có thể. Sun [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=21&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tiếp <a href="http://nmhblog.wordpress.com/2010/03/26/checked-exception-trong-java-va-c/" target="_blank">chuyện hôm trước</a>, nhưng hôm nay không có C#.</p>
<p>Không quan tâm tới chuyện checked exception trong Java hay dở thế nào nữa, tại vì chúng ta không phải là Sun. Họ làm sao là quyền của họ. Việc của chúng ta là làm theo ý họ theo cách tốt nhất có thể.</p>
<p>Sun có <a href="http://download-llnw.oracle.com/javase/tutorial/essential/exceptions/runtime.html" target="_blank">một bài dài</a> về checked exception, và họ kết luận:</p>
<blockquote><p>Generally speaking, do not throw a RuntimeException or create a subclass of RuntimeException simply because you don&#8217;t want to be bothered with specifying the exceptions your methods can throw.</p>
<p>Here&#8217;s the bottom line guideline: If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception.</p>
</blockquote>
<p>Tức là với Sun, lập trình viên phải ưu tiên xem xét checked exception trước. Trong quyển Effective Java: Programming Language Guide, Josh Bloch (một trong những người tham gia thiết kế Java) cụ thể hóa các chỉ dẫn trên một chút:</p>
<ul>
<li>Item 39: Use exceptions only for exceptional conditions. That is, do not use exceptions for control flow, such as catching NoSuchElementException&#160; when calling Iterator.next() instead of first checking Iterator.hasNext(). </li>
<li>Item 40: Use checked exceptions for recoverable conditions and runtime exceptions for programming errors. Here, Bloch echoes the conventional Sun wisdom &#8212; that runtime exceptions should be used only to indicate programming errors, such as precondition violations. </li>
<li>Item 41: Avoid unnecessary use of checked exceptions. In other words, don&#8217;t use checked exceptions for conditions from which the caller could not possibly recover, or for which the only foreseeable response would be for the program to exit. </li>
<li>Item 43: Throw exceptions appropriate to the abstraction. In other words, exceptions thrown by a method should be defined at an abstraction level consistent with what the method does, not necessarily with the low-level details of how it is implemented. For example, a method that loads resources from files, databases, or JNDI should throw some sort of ResourceNotFound exception when it cannot find a resource (generally using exception chaining to preserve the underlying cause), rather than the lower-level IOException, SQLException, or NamingException. </li>
</ul>
<p>Tuy nhiên, <a href="http://nmhblog.wordpress.com/2010/03/26/checked-exception-trong-java-va-c/" target="_blank">như đã nói</a>, các ông trùm đều cho rằng checked exception theo kiểu Java phá vỡ tính bao đóng, làm code dài, khó bảo trì, v.v cho nên một hướng dẫn chung chung thế kia có lẽ là chưa đủ. Có hai lựa chọn có vẻ đáng chú ý.</p>
<p>Thứ nhất là <a href="http://www.mindview.net/Etc/Discussions/CheckedExceptions" target="_blank">quan điểm “cực đoan”</a> của Bruce Eckel (người viết mấy quyển Thinking in), chỉ nên có checked exception. Bruce Eckel đề xuất việc mở rộng RuntimeException thành ExceptionAdapter có tác dụng:</p>
<blockquote><p>Here, you&#8217;re still able to catch the specific type of exception but you&#8217;re not forced to put in all the exception specifications and try-catch clauses everywhere between the origin of the exception and the place that it&#8217;s caught. An even more importantly, no one writing code is tempted to swallow the exception and thus erase it. If you forget to catch some exception, it will show up at the top level. If you want to catch exceptions somewhere in between, you can.</p>
</blockquote>
<p>Thứ hai là quan điểm “ôn hòa” của Rod Johnson trong J2EE Design and Development. Giống như Anders Hejlsberg, ông này cũng cho là checked exception là cần thiết, vấn đề là dùng sao cho hợp lí (trong điều kiện vẫn chưa tìm ra giải pháp nào phù hợp về mặt ngôn ngữ):</p>
<blockquote><p>Checked exceptions are much superior to error return codes (as used in many older languages). Sooner or later (probably sooner) someone will fail to check an error return value; it&#8217;s good to use the compiler to enforce correct error handling. Such checked exceptions are as integral to an object&#8217;s API as parameters and return values.</p>
<p>However, I don&#8217;t recommend using checked exceptions unless callers are likely to be able to handle them. In particular, checked exceptions shouldn&#8217;t be used to indicate that something went horribly wrong, which the caller can&#8217;t be expected to handle.</p>
</blockquote>
<p>Rod Johnson còn đề xuất cả một hướng dẫn cụ thể:</p>
<blockquote><table border="1" cellpadding="0" width="470">
<tbody>
<tr>
<td valign="top" width="159"><strong>Question</strong></td>
<td valign="top" width="139"><strong>Example</strong></td>
<td valign="top" width="170"><strong>Recommendation if the answer is yes</strong></td>
</tr>
<tr>
<td valign="top" width="159">Should all callers handle this problem? Is the exception essentially a second return value for the method?</td>
<td valign="top" width="139">Spending limit exceeded in a processInvoice() method</td>
<td valign="top" width="170">Define and used a checked exception and take advantage of Java&#8217;s compile-time support.<a name="page128"></a><a name="220"></a></td>
</tr>
<tr>
<td valign="top" width="159">Will only a minority of callers want to handle this problem?</td>
<td valign="top" width="139">JDO exceptions</td>
<td valign="top" width="170">Extend RuntimeException. This leaves callers the choice of catching the exception, but doesn&#8217;t force all callers to catch it.</td>
</tr>
<tr>
<td valign="top" width="159">Did something go horribly wrong? Is the problem unrecoverable?</td>
<td valign="top" width="139">A business method fails because it can&#8217;t connect to the application database</td>
<td valign="top" width="170">Extend RuntimeException. We know that callers can&#8217;t do anything useful besides inform the user of the error.</td>
</tr>
<tr>
<td valign="top" width="159">Still not clear?</td>
<td valign="top" width="139">&#160;</td>
<td valign="top" width="170">Extend RuntimeException. Document the exceptions that may be thrown and let callers decide which, if any, they wish to catch.</td>
</tr>
</tbody>
</table>
<p>Decide at a package level how each package will use checked or unchecked exceptions. Document the decision to use unchecked exceptions, as many developers will not expect it.</p>
<p>The only danger in using unchecked exceptions is that the exceptions may be inadequately documented. When using unchecked exceptions, be sure to document all exceptions that may be thrown from each method, allowing calling code to choose to catch even exceptions that you expect will be fatal. Ideally, the compiler should enforce Javdoc-ing of all exceptions, checked and unchecked.</p>
<p><em>If allocating resources such as JDBC connections that must be released under all circumstances, remember to use a finally block to ensure cleanup, whether or not you need to catch checked exceptions. Remember that a finally block can be used even without a catch block.</em></p>
</blockquote>
<p>Quyển J2EE Design and Development còn trình bày rất nhiều về exception và các vấn đề đáng quan tâm khác trong Java.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/java/'>Java</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=21&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/03/28/checked-exception-trong-java-va-c-ti%e1%ba%bfp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Checked exception trong Java và C#</title>
		<link>http://nmhblog.wordpress.com/2010/03/26/checked-exception-trong-java-va-c/</link>
		<comments>http://nmhblog.wordpress.com/2010/03/26/checked-exception-trong-java-va-c/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 08:35:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/03/26/checked-exception-trong-java-va-c</guid>
		<description><![CDATA[Có một thứ mình từng thấy rất khó chịu khi dùng C#, là nó không hỗ trợ checked exception. Trong Java, checked exception nôm na là các exception không phải do lỗi lập trình, mà là những tình huống đặc biệt, như không tìm được file, v.v. Bạn bắt buộc phải catch các exception này, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=20&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Có một thứ mình từng thấy rất khó chịu khi dùng C#, là nó không hỗ trợ checked exception. Trong Java, checked exception nôm na là các exception không phải do lỗi lập trình, mà là những tình huống đặc biệt, như không tìm được file, v.v. Bạn bắt buộc phải catch các exception này, hoặc throw lại nó. Với C#, tất cả các exception đều là unchecked. Điều đó có nghĩa là bạn phải dựa vào tài liệu hỗ trợ hoặc xem trực tiếp code để biết các exception mà một method có thể throw. Và việc không chắc chắn phải catch các exception có vẻ như sẽ gây trở ngại trong việc xây dựng một chương trình tốt.</p>
<p>Nhưng theo Anders Hejlsberg (kiến trúc sư trưởng của C#), thì <a href="http://www.artima.com/intv/handcuffs.html" target="_blank">cái cách Java hiện thực checked exception có vẻ không tốt</a>. Tức là, checked exception vẫn là một ý tưởng hữu ích:</p>
<blockquote><p>Frankly, they look really great up front, and there&#8217;s nothing wrong with the idea. I completely agree that checked exceptions are a wonderful feature. It&#8217;s just that particular implementations can be problematic. By implementing checked exceptions the way it&#8217;s done in Java, for example, I think you just take one set of problems and trade them for another set of problems. In the end it&#8217;s not clear to me that you actually make life any easier. You just make it different.</p>
</blockquote>
<p>Nhưng giải pháp Java đưa ra thì có vấn đề:</p>
<blockquote><p>The concern I have about checked exceptions is the handcuffs they put on programmers. You see programmers picking up new APIs that have all these throws clauses, and then you see how convoluted their code gets, and you realize the checked exceptions aren&#8217;t helping them any. It is sort of these dictatorial API designers telling you how to do your exception handling. They should not be doing that.</p>
</blockquote>
<p>Alan Griffiths <a href="http://www.octopull.demon.co.uk/java/ExceptionalJava.html" target="_blank">cũng đồng ý</a> rằng giải pháp của Java gây ra một số vấn đề, trong đó có việc phá vỡ tính bao đóng (mà cũng không biết ông này là ông nào, có điều thấy bài viết cũng được). Nhưng ngắn gọn lại thì cũng như quan điểm của Hejlsberg—lập trình viên sớm muộn sẽ catch và throw một loạt exception Exception:</p>
<blockquote><p>The throws clause, at least the way it&#8217;s implemented in Java, doesn&#8217;t necessarily force you to handle the exceptions, but if you don&#8217;t handle them, it forces you to acknowledge precisely which exceptions might pass through. It requires you to either catch declared exceptions or put them in your own throws clause. To work around this requirement, people do ridiculous things. For example, they decorate every method with, &quot;throws Exception.&quot; That just completely defeats the feature, and you just made the programmer write more gobbledy gunk. That doesn&#8217;t help anybody.</p>
</blockquote>
<p>Cái này mình cũng đồng ý, vì mình cũng hay làm thế cho nhanh. Vấn đề là Exception thì bao gồm cả RuntimeException, là những exception mà chúng ta không nên tự xử lí. Mình thấy tốt hơn hết là để cho lập trình viên catch những exception họ muốn/cần catch, và phần còn lại sẽ được throw tự động.</p>
<p>Có một lời giải thích khá thú vị cho giải pháp C# đưa ra—không hỗ trợ exception, hay chính xác hơn là không đưa ra giải pháp thực sự nào. Đó là vì họ chưa nghĩ ra.</p>
<blockquote><p>C# is basically silent on the checked exceptions issue. Once a better solution is known—and trust me we continue to think about it—we can go back and actually put something in place. I&#8217;m a strong believer that if you don&#8217;t have anything right to say, or anything that moves the art forward, then you&#8217;d better just be completely silent and neutral, as opposed to trying to lay out a framework.</p>
<p>And so, when you take all of these issues, to me it just seems more thinking is needed before we put some kind of checked exceptions mechanism in place for C#. But that said, there&#8217;s certainly tremendous value in knowing what exceptions can get thrown, and having some sort of tool that checks. I don&#8217;t think we can construct hard and fast rules down to, it is either a compiler error or not. But I think we can certainly do a lot with analysis tools that detect suspicious code, including uncaught exceptions, and points out those potential holes to you.</p>
</blockquote>
<p>Cũng là một lời khuyên hay. Nếu không thể làm cho tình huống tốt hơn thì hãy để nó nguyên như thế, ít nhất nó cũng sẽ không tệ đi.</p>
<p>Vẫn còn <a href="http://www.artima.com/intv/anders.html" target="_blank">bảy bài phỏng vấn</a> với ông trùm ngôn ngữ lập trình này, phải ráng đọc cho hết.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/c/'>C#</a>, <a href='http://nmhblog.wordpress.com/tag/java/'>Java</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=20&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/03/26/checked-exception-trong-java-va-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Nhà vệ sinh</title>
		<link>http://nmhblog.wordpress.com/2010/03/21/nha-v%e1%bb%87-sinh/</link>
		<comments>http://nmhblog.wordpress.com/2010/03/21/nha-v%e1%bb%87-sinh/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 20:40:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linh tinh]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/03/21/nha-v%e1%bb%87-sinh</guid>
		<description><![CDATA[Tại sao một bao hot dog có mười cây còn một bao bánh mì hot dog lại chỉ có tám cái? Cuộc sống không phải lúc nào cũng như ý muốn của chúng ta, nên hãy biết hài lòng với những thứ mình có, vì bạn sẽ luôn có hot dog để ăn . Câu [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=19&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tại sao một bao hot dog có mười cây còn một bao bánh mì hot dog lại chỉ có tám cái? Cuộc sống không phải lúc nào cũng như ý muốn của chúng ta, nên hãy biết hài lòng với những thứ mình có, vì bạn sẽ luôn có hot dog để ăn <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Câu này trong phim Thầy tu chống đạn, và nó lãng xẹt, nghe chả triết lí gì hết. Nhưng mà nó có liên quan đến nhà vệ sinh nên tạm cho vào đây.</p>
<p>Quay lại nhà vệ sinh đã. Không muốn đưa chủ đề này lên blog, nhưng tại vì bức xúc quá thể. Đây là những gì thu nhặt được sau hơn một tuần buộc phải lê lết ở trường vì đói Internet:</p>
<ul>
<li>Số nhà vệ sinh nữ ít hơn rất nhiều so với số nhà vệ sinh nam. Nếu bạn định rủ bạn gái tới BK, tốt hơn hết là nên lập trước bản đồ, để lúc đấy đỡ phải lên Google map. Và nếu có thể thì vào thử luôn <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> , vì chuyện thứ ba. </li>
<li>Các nhà vệ sinh đều không có hệ thống xả nước tự động, ngoại trừ các thực thể sinh học thông minh có khả năng tự di chuyển và cọ rửa khoảng 12 hoặc 24 giờ một lần. Tuy nhiên rất nhiều sinh viên nam (vì nữ HM không thể biết được) mặc định rằng hệ thống ấy tồn tại. </li>
<li>Hệ quả của chuyện trên là khi vào nhà vệ sinh HM phải chuyển sang chế độ “tiết kiệm năng lượng”, cắt giảm các hoạt động không cần thiết trong cơ thể, để giảm bớt nhu cầu hô hấp tới mức tối đa. </li>
<li>Nếu bạn có từng vào nhà vệ sinh ở BK, có lẽ bạn sẽ nhận ra sự đan xen hài hòa giữa nhiều trường phái kiến trúc Đông Tây, mà điển hình là ở B1 và B9. Nhà vệ sinh ở B1 lấy ý tưởng đề cao sự giao lưu cộng đồng kiểu châu Âu (chắc thế, vì người ta hay nói ở tây hay tham gia hoạt động xã hội), cho nên cánh cửa được thiết kế sao cho chỉ cần hé mở một chút, thì sẽ không còn có sự ngăn cách nào giữa người đi vệ sinh và người đi bộ ngoài hành lang. Trái lại, nhà vệ sinh B9 lại được xây dựng đậm chất châu Á. Cụ thể hơn, là kiểu Pol Pot, không có gì là của cá nhân, tất cả đều thuộc về tập thể. Khó tả quá. Đại để là, chung một dòng sông. </li>
</ul>
<p>Thế nên phải vào nhà vệ sinh ở BK là cả một sự khổ nhục. Chỉ đến sáng nay, khi phải qua cơ sở 2 đại học sư phạm có chút chuyện HM mới nhận ra, có một cái nhà vệ sinh gắn vòi rửa tay như BK quả là một mơ ước đáng để ước mơ của sinh viên ở cơ sở này. Đúng là cuộc sống không phải lúc nào cũng như ý mình nên hãy biết hạnh phúc với những thứ đang có.</p>
<p>Nếu lúc nào bạn có chuyện gì buồn bã, tuyệt vọng thì hãy vào nhà vệ sinh ở BK, sau đó làm lại điều đó ở cơ sở 2 đại học sư phạm, nhất định bạn sẽ thấy nhẹ nhõm phần nào.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/linh-tinh/'>linh tinh</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=19&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/03/21/nha-v%e1%bb%87-sinh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Getter/setter</title>
		<link>http://nmhblog.wordpress.com/2010/03/01/gettersetter/</link>
		<comments>http://nmhblog.wordpress.com/2010/03/01/gettersetter/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 09:02:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình hướng đối tượng]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/03/01/gettersetter</guid>
		<description><![CDATA[Ngày xưa khi học C++ hay được dạy phải để field của object là private, sau đó tạo hai method public là get…() và set…(…) để truy cập và thay đổi các field này. Nhưng không ai dặn mình phải dùng nó một cách cẩn thận. Có quá nhiều lí do để get/set là dấu [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=17&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ngày xưa khi học C++ hay được dạy phải để field của object là private, sau đó tạo hai method public là get…() và set…(…) để truy cập và thay đổi các field này. Nhưng không ai dặn mình phải dùng nó một cách cẩn thận. Có quá nhiều lí do để get/set là dấu hiệu của một thiết kế yếu kém.</p>
<p>Thường thì chúng ta get một field để lấy thông tin của đối tượng, và thao tác trên thông tin đó. Vấn đề là tại sao phải trực tiếp làm việc trên thông tin này. Xét cho cùng, đối tượng là một thực thể mà tất cả những gì bên ngoài (nên) được biết về nó là các “dịch vụ” mà nó cung cấp. Cho nên, thay vì lấy thông tin từ đối tượng để thực hiện một công việc, hãy bảo đối tượng này làm nó cho chúng ta. Nếu điều này là không thể, thì có vẻ như thiết kế của chương trình có vấn đề, các đối tượng đã không được xây dựng để làm các công việc của nó một cách tách bạch, rõ ràng. Và khi sự coupling giữa các đối tượng càng cao, việc bảo trì và mở rộng trong tương lai sẽ càng khó khăn, phức tạp.</p>
<p>Mặt khác, khi get hay set một field nào đó, thường chúng ta đã có giả định về kiểu và ý nghĩa của nó. Nói cách khác, chúng ta đã có hiểu biết nhất định về hiện thực bên trong của đối tượng. Có điều, hiện thực của một đối tượng không phải là một bất biến. Khó có thể đảm bảo trong tương lai, khi đối tượng được xây dựng lại, các private field đó sẽ giữ nguyên kiểu và ý nghĩa như hôm nay, thậm chí nó có thể không tồn tại nữa. Hệ quả là, những đoạn mã có sử dụng get/set cũng trở nên vô dụng. Điều đó đồng nghĩa với việc không đạt được tính dễ bảo trì và mở rộng—mục tiêu mà lập trình hướng đối tượng hướng tới.</p>
<p>Tất nhiên, nói như thế không có nghĩa là chúng ta phải tránh xa get/set. Get/set sẽ tồn tại nếu chúng thực sự là những “dịch vụ” cần thiết, và không phụ thuộc và thay đổi của bất kì cách hiện thực nào của đối tượng. Nhưng lúc đó thì get/set lại không hẳn liên quan đến cái get/set người ta hay dạy cho học sinh nữa.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/l%e1%ba%adp-trinh-h%c6%b0%e1%bb%9bng-d%e1%bb%91i-t%c6%b0%e1%bb%a3ng/'>lập trình hướng đối tượng</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=17&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/03/01/gettersetter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Cyclic dependency trong C++</title>
		<link>http://nmhblog.wordpress.com/2010/02/27/c-header-file/</link>
		<comments>http://nmhblog.wordpress.com/2010/02/27/c-header-file/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 07:40:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cpp]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/02/27/c-header-file</guid>
		<description><![CDATA[Xét trường hợp này: Dễ thấy muốn có x.h phải có y.h, mà muốn có y.h thì lại cần đến x.h. Trừ khi có khả năng xử lý cyclic dependency (như kiểu của Java), trình biên dịch sẽ báo lỗi. Cách xử lí: Đây gọi là forward declaration. Nó giúp giải quyết được cyclic dependency [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=15&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Xét trường hợp này:</p>
<p><pre class="brush: cpp;">
/* ====== x.h ====== */ 
#include “y.h” 
class X 
{ 
  Y *m_y; 
  ... 
};

/* ====== y.h ====== */ 
#include “x.h” 
class X; 
class Y 
{ 
  X *m_x; 
  ... 
};
</pre></p>
<p>Dễ thấy muốn có x.h phải có y.h, mà muốn có y.h thì lại cần đến x.h. Trừ khi có khả năng xử lý cyclic dependency (như kiểu của Java), trình biên dịch sẽ báo lỗi.</p>
<p>Cách xử lí:</p>
<p><pre class="brush: cpp;">
/* ====== x.h ====== */ 
// Forward declaration of Y for cyclic dependency 
class Y; 
class X 
{ 
  Y *m_y; 
  ... 
};

/* ====== y.h ====== */ 
// Forward declaration of X for cyclic dependency 
class X; 
class Y 
{ 
  X *m_x; 
  ... 
};
</pre></p>
<p>Đây gọi là forward declaration. Nó giúp giải quyết được cyclic dependency kiểu trên, tuy nhiên, có những dạng cyclic dependency không thể xử lí bằng forward declaration được.</p>
<p>Bạn có thể đọc thêm một số nguyên tắc khác ở <a href="http://www.gamedev.net/reference/programming/features/orgfiles/page2.asp" target="_blank">đây</a>.</p>
<br /> Tagged: <a href='http://nmhblog.wordpress.com/tag/cpp/'>Cpp</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=15&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/02/27/c-header-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Lưu trữ bài tập lớn</title>
		<link>http://nmhblog.wordpress.com/2010/01/14/l%c6%b0u-tr%e1%bb%af-bai-t%e1%ba%adp-l%e1%bb%9bn/</link>
		<comments>http://nmhblog.wordpress.com/2010/01/14/l%c6%b0u-tr%e1%bb%af-bai-t%e1%ba%adp-l%e1%bb%9bn/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 06:39:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2010/01/14/l%c6%b0u-tr%e1%bb%af-bai-t%e1%ba%adp-l%e1%bb%9bn</guid>
		<description><![CDATA[Thường thì khi làm bài tập lớn (hay đồ án, luận văn) bạn có thể gặp phải một vài rắc rối sau: Máy tính hỏng. Nếu là hệ điều hành, màn hình, v.v hỏng thì không sao, còn ổ cứng mà hỏng thì xem như xong. Không lưu trước khi chỉnh sửa. Và chuyện “sửa [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=13&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Thường thì khi làm bài tập lớn (hay đồ án, luận văn) bạn có thể gặp phải một vài rắc rối sau:</p>
<ul>
<li>Máy tính hỏng. Nếu là hệ điều hành, màn hình, v.v hỏng thì không sao, còn ổ cứng mà hỏng thì xem như xong. </li>
<li>Không lưu trước khi chỉnh sửa. Và chuyện “sửa đồ lành thành đồ què” không phải là hiếm. </li>
<li>Làm nhóm. Tất nhiên là có cả tá lí do để việc làm nhóm không được như ý, nhưng nói chung đã cũng làm một bài mà mỗi phần lại ở một máy khác nhau thì cũng bất tiện. </li>
<li>v.v </li>
</ul>
<p>Tóm lại là cần phải có một chỗ lưu trữ nhanh gọn, an toàn. Dĩ nhiên với các rắc rối ở trên thì lưu trữ trực tuyến là hợp lí nhất, tuy nhiên nếu chỉ sử dụng các dịch vụ như <a href="http://ifile.it/" target="_blank">iFile</a>, <a href="http://www.mediafire.com/" target="_blank">MediaFire</a> thì sẽ có những hạn chế nhất định, như phải tải xuống/lên một lượng lớn dữ liệu một cách thủ công, khó khăn khi quản lí các bản sao lưu, v.v. Vì vậy, chúng ta sẽ dùng một công cụ gọi là <a href="http://en.wikipedia.org/wiki/Subversion_%28software%29" target="_blank">SVN</a>. Cụ thể SVN là gì thì bạn có thể tự tìm hiểu. Ở đây sẽ chỉ cách dùng trang <a href="https://sourceforge.net/" target="_blank">Sourceforge</a> và <a href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVN</a> để quản lí bài tập của bạn. Ngoài Sourceforge còn có nhiều trang cung cấp dịch vụ tương tự, như Google Code. Nếu bạn không muốn công khai mã nguồn thì có thể thử Unfuddle.</p>
<p>Việc đầu tiên là bạn phải đăng kí tài khoản ở Sourceforge. Sau đó tạo một project mới (vào link Create project). Khi đã tạo xong thì vào trang của project đó (từ mục/portlet My projects). Tại trang của project vào link Develop (link trong trang của project chứ không phải link cùng tên dưới logo Sourceforge). Và bạn sẽ có được một URL kiểu như thế này: <a href="https://nmh-blog.svn.sourceforge.net/svnroot/nmh-blog" target="_blank">https://nmh-blog.svn.sourceforge.net/svnroot/nmh-blog</a>.</p>
<p>Tiếp theo là cài TortoiseSVN.</p>
<p>Bây giờ tạo một thư mục để lưu project trên máy. Vào trong thư mục này, ấn chuột phải chọn SVN Checkout. Nhập vào URL lúc nãy. OK, và thế là xong. Giờ cái thư mục sẽ trông như thế này:</p>
<p><a href="http://lh6.ggpht.com/__AVcF151eXQ/S08ehCLmiyI/AAAAAAAAAac/a2DJ_jA6A8k/s1600-h/Untitled%5B2%5D.png"><img title="Untitled" border="0" alt="Untitled" src="http://lh6.ggpht.com/__AVcF151eXQ/S08eh7gHc9I/AAAAAAAAAag/7ZoxBG9_LI4/Untitled_thumb.png?imgmax=800" width="94" height="120" /></a></p>
<p>Sau khi làm xong một phần của bài tập, nếu bạn muốn tải lên mạng thì ấn chuột phải vào thư mục này và chọn SVN Commit. Chọn các tập tin cần đưa lên:</p>
<p><a href="http://lh6.ggpht.com/__AVcF151eXQ/S08eijNIYvI/AAAAAAAAAak/6WTeF2A-34A/s1600-h/Untitled1%5B3%5D.png"><img title="Untitled1" border="0" alt="Untitled1" src="http://lh6.ggpht.com/__AVcF151eXQ/S08ej-lb1LI/AAAAAAAAAao/dvdSjX3SceE/Untitled1_thumb%5B1%5D.png?imgmax=800" width="509" height="503" /></a></p>
<p>Và sau một vài thao tác lặt vặt:</p>
<p><a href="http://lh3.ggpht.com/__AVcF151eXQ/S08ek7qAu-I/AAAAAAAAAas/_8m7TVDX29k/s1600-h/Untitled2%5B3%5D.png"><img title="Untitled2" border="0" alt="Untitled2" src="http://lh3.ggpht.com/__AVcF151eXQ/S08el3lMf2I/AAAAAAAAAaw/khSluu5uUdE/Untitled2_thumb%5B1%5D.png?imgmax=800" width="508" height="248" /></a></p>
<p>Ngược lại nếu muốn tải xuống thay vì tải lên bạn chọn SVN Update thay vì SVN Commit. SVN đủ thông minh để chỉ tải xuống hoặc tải lên các phần dữ liệu bị thay đổi, nên thường bạn chỉ tốn thời gian trong lần đầu.</p>
<p>Nếu bạn lỡ dại làm gì đó bài tập của mình và muốn quay về phiên bản cũ, ấn chuột phải chọn TortoiseSVN &gt; Show log để xem toàn bộ các thay đổi của mình:</p>
<p><a href="http://lh4.ggpht.com/__AVcF151eXQ/S08enAr0_XI/AAAAAAAAAa0/zU1lSDTjC48/s1600-h/Untitled3%5B3%5D.png"><img title="Untitled3" border="0" alt="Untitled3" src="http://lh4.ggpht.com/__AVcF151eXQ/S08eoTGrOUI/AAAAAAAAAa4/Uj5xNoh2A7M/Untitled3_thumb%5B1%5D.png?imgmax=800" width="509" height="449" /></a></p>
<p>Và sau đó, chọn thời điểm bạn muốn quay lại, ấn chuột phải và …</p>
<p>Mà có lẽ bạn tự tìm hiểu sẽ thú vị hơn <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<br /> Tagged: lập trình <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=13&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2010/01/14/l%c6%b0u-tr%e1%bb%af-bai-t%e1%ba%adp-l%e1%bb%9bn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S08eh7gHc9I/AAAAAAAAAag/7ZoxBG9_LI4/Untitled_thumb.png?imgmax=800" medium="image">
			<media:title type="html">Untitled</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/__AVcF151eXQ/S08ej-lb1LI/AAAAAAAAAao/dvdSjX3SceE/Untitled1_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">Untitled1</media:title>
		</media:content>

		<media:content url="http://lh3.ggpht.com/__AVcF151eXQ/S08el3lMf2I/AAAAAAAAAaw/khSluu5uUdE/Untitled2_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">Untitled2</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/__AVcF151eXQ/S08eoTGrOUI/AAAAAAAAAa4/Uj5xNoh2A7M/Untitled3_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">Untitled3</media:title>
		</media:content>
	</item>
		<item>
		<title>Thư xin thực tập bằng tiếng Anh</title>
		<link>http://nmhblog.wordpress.com/2009/12/20/th%c6%b0-xin-th%e1%bb%b1c-t%e1%ba%adp-b%e1%ba%b1ng-ti%e1%ba%bfng-anh/</link>
		<comments>http://nmhblog.wordpress.com/2009/12/20/th%c6%b0-xin-th%e1%bb%b1c-t%e1%ba%adp-b%e1%ba%b1ng-ti%e1%ba%bfng-anh/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 17:21:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tiếng Anh]]></category>
		<category><![CDATA[việc làm]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2009/12/20/th%c6%b0-xin-th%e1%bb%b1c-t%e1%ba%adp-b%e1%ba%b1ng-ti%e1%ba%bfng-anh</guid>
		<description><![CDATA[Trang này có một mẫu thư xin thực tập khá ổn. Tât nhiên nội dung không thể áp dụng cho mọi trường hợp, nhưng bạn có thể theo bố cục này để viết một lá thư cho riêng mình. Khuyến mại : Các bạn có thể lên englishforums.com để nhờ kiểm tra lại lá thư [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=11&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.faculty.iu-bremen.de/springer/career/sampleletter.htm">Trang này</a> có một mẫu thư xin thực tập khá ổn. Tât nhiên nội dung không thể áp dụng cho mọi trường hợp, nhưng bạn có thể theo bố cục này để viết một lá thư cho riêng mình. Khuyến mại <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> : Các bạn có thể lên <a href="http://www.englishforums.com" target="_blank">englishforums.com</a> để nhờ kiểm tra lại lá thư mình viết. HM cũng có tạo một CV mẫu <a href="http://nmhblog.wordpress.com/2010/12/03/cv-m%e1%ba%abu/" target="_blank">tại đây</a>.</p>
<p>Chép lại đây kẻo mất mất.</p>
<blockquote><p><b>Elements of an application letter for an internship for a BCCB student</b></p>
<p>Here is a letter that I made up as an example. Comments to each individual part are in the right hand-side column.</p>
<table border="1" cellspacing="0" cellpadding="0" width="549">
<tbody>
<tr>
<td valign="top" width="268">
<p><b>Text of letter</b></p>
</td>
<td valign="top" width="279">
<p><b><i>Comments</i></b></p>
</td>
</tr>
<tr>
<td width="268">
<p>Dear Dr. Miller,</p>
</td>
<td width="279">
<p><i>For the US, use Dr., not Prof., to address someone.</i></p>
</td>
</tr>
<tr>
<td width="268">
<p>I am a second-year student of Biochemistry and Cell Biology at the International University Bremen, Germany.</p>
</td>
<td width="279">
<p><i>Introduce yourself first.</i></p>
</td>
</tr>
<tr>
<td width="268">
<p>In order to gain practical experience in a research environment and to explore graduate school options, I wish to perform a 10-week internship in a research laboratory, and I would like to&#160; ask whether there might be a place available in your laboratory from June to August, 200x. </p>
</td>
<td width="279">
<p><i>Tell the addressee what you want from them, and why.</i></p>
</td>
</tr>
<tr>
<td width="268">
<p>During my studies at IUB, I have become interested in studying the molecular mechanisms of the immune response. I find it especially interesting how one might manipulate the system in order to induce specific immunity against viruses or other pathogens. The molecular basis of this is antigen presentation through MHC class I molecules, and I would like participate in research on them because it combines techniques across the whole spectrum of the life sciences, from molecular dynamics to cell biology.</p>
</td>
<td width="279">
<p><i>The next question the addressee will ask is &quot;Is he or she really motivated to work with me, i.e. applying specifically to my lab or am I just one of many people who get a nonspecific letter?&quot;</i></p>
<p><i>So first, you need to demonstrate that you have a connection to the subject.</i></p>
<p><i>Of course, this section very much depends on your interest and the lab you are applying to. The text on the left is just an example.</i></p>
</td>
</tr>
<tr>
<td width="268">
<p>I came across your laboratory when reading the literature on MHC class I molecules, and especially the work in your group described in the Journal of Immunology, 2004 (&quot;<i>The role of class I molecules in ankylosing spondylitis&quot;) </i>and in Nature, 2005 (&quot;<i>Class I haplotype determines clinical outcome of ankylosing spondylitis&quot;</i>) has motivated me to write to you.</p>
</td>
<td width="279">
<p><i>Next, you should demonstrate that you know some of the work from the lab, ideally by mentioning the titles of a couple of interesting papers (make sure you have actually seen them). </i></p>
<p><i>Of course, this section very much depends on your interest and the lab you are applying to. The text on the left is just an example.</i></p>
</td>
</tr>
<tr>
<td width="268">
<p>I would be very excited to participate in work on a similar subject.</p>
</td>
<td width="279">
<p><i>Do not suggest an actual research project &#8211; as an intern you have no control over that.</i></p>
</td>
</tr>
<tr>
<td width="268">
<p>Regarding my training, I am convinced that the intense teaching approach at IUB has equipped me with solid fundamental knowledge of biochemistry and cell biology. Since IUB puts its students on the track to a career in research, this is complemented by laboratory courses from the first semester on. In addition, I have worked as a research assistant in Prof. xxx&#8217;s lab for xxx months to gain some additional experience.</p>
</td>
<td width="279">
<p><i>The next question the addressee will ask is &quot;Is that person <u>qualified</u> to work in my lab or will they just break everything?&quot; So you must convince them that you are well-trained. Of course, only write what actually applies to you. </i></p>
</td>
</tr>
<tr>
<td width="268">
<p>If I am given the chance to work in your group, I am certain that due to my previous training and my enthusiasm for the subject I will be able to make a meaningful contribution to your research effort.</p>
</td>
<td width="279">
<p><i>This part is important. What is your host going to get from your time with them? </i></p>
</td>
</tr>
<tr>
<td width="268">
<p>I have attached my CV, which contains the details of my theoretical and practical training, my current university transcript, and the names and addresses of three referees. If you wish, I can ask them to send their letters directly to you.</p>
</td>
<td width="279">
<p><i>Normally, for an internship, the prospective host should contact the referees and ask for the letters. (This also helps minimize the impact on IUB faculty who have to write many letters for grad school already.)</i></p>
</td>
</tr>
<tr>
<td width="268">
<p>I am looking forward to hearing from you.</p>
<p>Sincerely,</p>
<p>&#8230;&#8230;.</p>
</td>
<td width="279">&#160;</td>
</tr>
</tbody>
</table>
<p>© Sebastian Springer 2005. Please contact me with suggestions for improvements.</p>
</blockquote>
<br /> Tagged: tiếng Anh, việc làm <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=11&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2009/12/20/th%c6%b0-xin-th%e1%bb%b1c-t%e1%ba%adp-b%e1%ba%b1ng-ti%e1%ba%bfng-anh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
		<item>
		<title>Scheme</title>
		<link>http://nmhblog.wordpress.com/2009/12/18/l%e1%ba%adp-trinh/</link>
		<comments>http://nmhblog.wordpress.com/2009/12/18/l%e1%ba%adp-trinh/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 06:38:00 +0000</pubDate>
		<dc:creator>minhhai2209</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lập trình]]></category>
		<category><![CDATA[lập trình hàm]]></category>

		<guid isPermaLink="false">http://nmhblog.wordpress.com/2009/12/18/l%e1%ba%adp-trinh</guid>
		<description><![CDATA[Scheme là ngôn ngữ lập trình từng được MIT sử dụng để dạy cho sinh viên (hình như giờ đã thay bằng Python). Mình biết đến Scheme qua một bài viết trên blog Khoa học máy tính. Mặc dù mình chỉ lọ mọ tìm hiểu sơ sơ về nó (chính xác hơn là về Scheme [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=10&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Scheme là ngôn ngữ lập trình từng được MIT sử dụng để dạy cho sinh viên (hình như giờ đã thay bằng Python). Mình biết đến Scheme qua <a href="http://www.procul.org/blog/2006/01/30/khmt-khong-ph%E1%BA%A3i-ai-cung-nen-h%E1%BB%8Dc/" target="_blank">một bài viết</a> trên <a href="http://www.procul.org/blog/" target="_blank">blog Khoa học máy tính</a>. Mặc dù mình chỉ lọ mọ tìm hiểu sơ sơ về nó (chính xác hơn là về Scheme và IDE của MIT), nhưng cũng kịp có vài ấn tượng.</p>
<p>Thứ nhất, Scheme có tương đối ít khái niệm hơn các ngôn ngữ phổ biến, như C#, C++, Java, v.v. Điều này giúp bạn tập trung vào những yếu tố quan trọng khác trong lập trình, thay vì tiêu tốn thời gian và công sức vào những chi tiết cú pháp vụn vặt.</p>
<p>Thứ hai, chương trình dùng Scheme viết ra nhìn rất ngắn gọn và đẹp (nói chung các ngôn ngữ lập trình hàm đều thế). Ví dụ:</p>
<p><pre class="brush: plain;">
(define (even-fibs n) 
(accumulate +  
            0  
            (filter even?   
                    (map fib    
                         (enumerate-interval 0 n)))))
</pre></p>
<p>Đoạn mã trên là một phần của chương trình tính tổng các số chẵn trong (n+1) số Fibonacci đầu tiên. Bạn có thể thấy từng bước tính toán nếu đọc ngược từ dưới lên:</p>
<ul>
<li>Liệt kê (<code>enumerate</code>) các số từ 0 đến n, </li>
<li>Ánh xạ (<code>map</code>) dãy trên sang dãy Fibonacci. Nôm na là tạo danh sách các số Fibonacci từ thứ 0 đến thứ n, </li>
<li>Lọc (<code>filter</code>) các số chẵn trong danh sách, </li>
<li>Tính tổng (<code>accumulate</code>) các số vừa được lọc. </li>
</ul>
<p>Thứ ba, ngay cả một chương trình Scheme cỡ trung bình cũng khá khó viết. Nếu chưa có một phác thảo tương đối rõ ràng về chương trình của mình, thì thậm chí cái bạn viết ra có thể không chạy được chứ chưa nói đến chạy đúng hay sai, nhất là khi dùng IDE của MIT. Có lẽ chính sự quá dễ dàng trong việc viết ra một chương trình “chạy được” bằng các ngôn ngữ như C, C++ (cái này BK chọn để dạy trong môn Kĩ thuật lập trình), Java, C# khiến cho chúng ta nhiễm thói quen “mì ăn liền”, đọc yêu cầu xong là nhảy vào lập trình liền, và kết quả là chương trình rất rối rắm và dễ mắc lỗi.</p>
<p>Nếu quan tâm tới Scheme, bạn có thể tham khảo thêm ở <a href="http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-001Spring-2005/CourseHome/index.htm" target="_blank">trang web của môn này</a> ở <a href="http://ocw.mit.edu/OcwWeb/web/home/home/index.htm" target="_blank">MIT OCW</a>. Quyển sách giáo khoa chính—<a href="http://mitpress.mit.edu/sicp/full-text/book/book.html">Structure and Interpretation of Computer Programs</a>—là một trong những quyển sách về máy tính hay nhất mà mình từng đọc. Bạn có thể tìm thấy ở đó không chỉ những hướng dẫn về lập trình Scheme mà còn rất nhiều lí thuyết thú vị, như thiết kế chương trình, tính trừu tượng, tính nondeterministic, v.v. Đọc nó, và bạn sẽ không bao giờ còn băn khoăn liệu mình có chọn sai ngành.</p>
<br /> Tagged: lập trình, lập trình hàm <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nmhblog.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nmhblog.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nmhblog.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nmhblog.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nmhblog.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nmhblog.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nmhblog.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nmhblog.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nmhblog.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nmhblog.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nmhblog.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nmhblog.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nmhblog.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nmhblog.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nmhblog.wordpress.com&amp;blog=13209873&amp;post=10&amp;subd=nmhblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nmhblog.wordpress.com/2009/12/18/l%e1%ba%adp-trinh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/651a9449c84a5793f265aceb017e2fa9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">minhhai2209</media:title>
		</media:content>
	</item>
	</channel>
</rss>
