Wednesday, February 23, 2011

Sử dụng Table-Valued Parameter trong SQL Server 2008 và ADO.NET

Table-Valued Parameter đưa ra cho bạn một phương pháp đơn giản để truyền dữ liệu từ ứng dụng vào SQL Server mà không phải thực hiện các vòng lặp hoặc các xử lý dữ liệu logic phức tạp phía server. Bạn có thể chuyển toàn bộ các dòng dữ liệu trong ứng dụng và gửi về server chỉ bằng một tham số đơn của câu lệnh SQL.

Saturday, February 19, 2011

What is SOLID?

SOLID is a collection of best practices object-oriented design principles. The principles when applied together to make a system that is easy to maintain and extend over time. The principles of SOLID are guidelines that can be applied while working on software to remove code smells, to refactor the software's source code until it is both legible and extensible. It may be used with test-driven development, and is part of an overall strategy of agile and adaptive programming.

SOLID is abbreviated by Single Responsibility, Open Closed, Liskov Substitution, Interface Segregation and Dependency Inversion.

1. Single Responsibility Principle: A class or module should have one, and only one, reason to change.

2. Open Closed Principle: Software Entities (Classes, Modules, Functions, and so on) should be open for extension but closed for modification.

3. Liskov Substitution Principle: Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.

4. Interface Segregation Principle: Many client specific interfaces are better than one general purpose interface.

5. Dependency Inversion Principle:

a. High level modules should not depend on low level modules. Both should depend on abstractions.

b. Abstractions should not depend upon details. Details should depend upon abstractions.

Thursday, May 13, 2010

Sử dụng Bing Maps trong Silverlight

Việc sử dụng Bing Maps control trong các ứng dụng Silverlight rất đơn giản, bời vì Microsoft đã cung cấp cho chúng ta Bing Maps Silverlight Control SDK và bởi vì Silverlight là client-side, nên các truy vấn vào Bing Maps sẽ thông qua Bing Maps Web Services SDK.

Trước khi bắt đầu việc phát triển ứng dụng Bing Maps Silverlight, bạn phải cài đặt các thành phần sau:

Microsoft Visual Studio 2008 SP1

Microsoft Silverlight 3 Tools for Visual Studio 2008 SP1

Trong bài viết này, tôi sẽ làm từng bước để bạn có thể sử dụng được Bing Maps trong Silverlight:

Tạo Bings Maps Key

1. Bạn hãy download Bing Maps Sỉverlight Control từ đây và tiến hành cài đặt.

2. Tạo Bing Maps Developer account:

Sử dụng Bing Maps Silverlight Control

1. Tạo ứng dụng Silverlight trong Visual Studio

2. Hãy reference đến Microsoft.Maps.MapControl.dll và Microsoft.Maps.MapControl.Common.dll có trong thư mục C:\Program Files\Bing Maps Silverlight Control\V1\Libraries.

3. Open MainPage.xml và thêm tham chiếu đến Bing Maps control như sau:

xmlns:maps="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"

4. Tiếp theo, bạn hãy đưa Bing Maps control vào:

<Grid x:Name="LayoutRoot">
	<maps:Map x:Name="myMap" CredentialsProvider="[Bing Maps Key]" />
</Grid>

Chú ý: [Bing Map Key] chính là key đã được cung cấp bởi Bing Maps Portal ở trên.

5. Khi chạy thử ứng dụng, bạn sẽ có kết quả như sau:

BingMapsSample1

Như vậy, bạn đã có thể sử dụng được Bing Maps trong Silverlight, ở bài tiếp theo, tôi sẽ nói về việc sử dụng Bing Maps Web Services SDK để truy vấn các thông tin và hiển thị lên Bing Maps controls.