Tuesday, March 30, 2010

Validating ViewModel use Regular Expression

What do you think about Regular Expression(RE)?
Today, when working on RE in Validate ViewModel (used DataAnnotation), I just found important thing in RE. After reading about it, I implemented something very interested in it.
For examples:
In bussiness rule request me validate for string not contain any speial characters. So I can use this pattern ^[(0-9|a-z|\s|A-Z\.)]*$. It's so good. We can used this tool for validate string.
I also found useful stuff at here. This is very easy for understanding. In real working, RE's really important, and it make my work is easier. But we always had some problems when using it :D.

Thursday, March 25, 2010

Five Rules for IOC container

Today, I found the interesting article about 5 rules in using IOC container. And I really eager about it. In this article impressed in Service Locator is dead, and we need saying no with it. That is five rules about using IOC container:

+ Rule 1: Store in IoC container only services. Do not store any entities
+ Rule 2: Any class having more then 3 dependencies should be questioned for SRP violation
+ Rule 3: Every dependency of the class has to be presented in a transparent manner in a class constructor
+ Rule 4: Every constructor of a class being resolved should not have any implementation other then accepting a set of its own dependencies
+ Rule 5: IoC container should be explicitly used only in Bootstrapper. Any other “IoC enabled” code (including the unit tests) should be completely agnostic about the existence of IoC container

Inspite of it really old, publishing in 2009 but this article have something that I interested in. And we need make sense about Opaque dependencies and Tranparent Dependencies. What happen here if I use opaque denpendencies? It's make your class very hard for unit testing because it's seen hidden dependency class in your class. So you don't know to testing your class anywhere.In this articles of Mark Seemann, he's only showed for us about Oquaque Dependencies and he talked Service Locator is anti-pattern. But according to me, if we can use Transparent Dependencies, we can realize that Service Locator still use in the other context, and make your class don't know anything about existence Service Locator on it. In this articles, malovicn also showed for us about using internal key word for internal constructor, it's really useful for us when design the class that using Service Locator

Thursday, March 4, 2010

Differences between Custom Service and RESTful service

Up to before read this articles in MSDN magazines, I still know very implicit about RESTful service and Custom Service. Now I can define it as "Custom service is define orient-operator and RESTful service is define orient-resources". It's really make me clearly about ADO.NET Data services. And I think it will be development in the future (.NET 4 and Entity framework 4)

Friday, February 12, 2010

Active Directory Role Provider

Time passed very past. Today, it's very near Tet holiday. And I found a article from Mr. Thoai Nguyen, my co-worker at Hvn. It's really cool and useful for my work at company. I want to shared to all you about it. Click here for it

Monday, January 25, 2010

S.O.L.I.D principles

S: The Single Responsibility Principle
O: The Open Closed Principle
L: The Liskov Substitution Principle
I: Interface Segregation Principle
D: The Dependency Inversion Principle

Five principles that made the OOP world is re-use and easily maintain.
All thing is found by Robert Martin (a.k.a. Uncle Bob). And today, i find a link that write very good about S.O.L.I.D principles. You can find this at here.

Friday, January 22, 2010

How to references mutilple databases in SQL Server 2005

Today, when working with SQL Server 2005, I have a issue. This situation as "I have a select statement that references to multiple tables that reside in 2 different database". After finding in internet and helping from my team leader, I found a solution as below;

+ Using Synonyms in SQL Server 2005 for taking references to other database (other database server)
USE "Database using references";
GO
IF OBJECT_ID('dbo.OrgUnit', 'SN') IS NOT NULL
DROP SYNONYM dbo.OrgUnit;
GO
CREATE SYNONYM dbo.OrgUnit FOR ["name of database referenced"].security.orgunit.OrgUnit;

select * from dbo.OrgUnit


Note: I you want to know about "name of database referenced", using as
select * from sys.servers


+ Adding:
USE master;
GO
EXEC sp_addlinkedserver
'"IP Address"',
N'SQL Server'
GO


+ And now you can select the table that reside in the other location as

USE "Database using references";
GO;
select * from dbo.OrgUnit


For example:

Assume we have [Client] database at local and [Security] database at the remote side

USE master;
GO
EXEC sp_addlinkedserver
'SECURITY_DATABASE_ADDRESS',
N'SQL Server'
GO

select * from sys.servers

USE Client;
GO
IF OBJECT_ID('dbo.OrgUnit', 'SN') IS NOT NULL
DROP SYNONYM dbo.OrgUnit;
GO
CREATE SYNONYM dbo.OrgUnit FOR [SECURITY_DATABASE_ADDRESS].security.orgunit.OrgUnit;

select * from dbo.OrgUnit

Tuesday, January 19, 2010

Thinking about Patterns in ASP.NET for developer

Today, when try to finding about pattern, I found the new series articles about patterns for developer. It's really attractive me for exploring pattern in ASP.NET.

This is a three parts: part 1, part 2 and part 3 at http://devx.com
And this is a some pattern that apply for ASP.NET website at http://www.developerfusion.com here and here

Maybe, It's not new (because publish in 2007) but as me this very useful.