Archive

Archive for the ‘Technique’ Category

Comparing between Guice and PicoContainer

  • Guice

The first thing u’ll notice is that Guice makes extensive use of Java 5 language features. ie, generics and annotations. While generics lead to the extraordinary type safety mentioned by Kevin Bourrillion, annotations couple your code to the Guice framework. If u’ve really picky about loose coupling you might ask why you should use a framework that adds a dependency to itself? You end up with lots of imports of the Inject annotation scattered all over your code base. And it’s getting worse if you have to use Singleton, ImplementedBy and so on and so forth. You may want to define that elsewhere because your classes shouldn’t know any thing about their usage or where dependencies should be Inject – That’s what inversion of control is all about, isn’t it :).

However, for those who aren’t so pickly there are some really cool things about Guice:
– it is type safe
– it reports same error messages
– it is small and very fast

Well it is really type safe: if you ask Guice to give you an object of type Bar, it’ll do so – no cast to Bar required. The authors of Guice don’t want it to be used as a simple service locator for a good reason: your code would still be coupled very tightly. That being said you want to call Guice only in some places in your code where it hand you a top-lever class where all the dependencies are injected. Whether you’ll have to do a cast on these few occasions shouldn’t be that bad; this puts the big feature of type safety into another perspective (read: isn’t that important). But this is definitely a plus for Guice though.

Reasonable error messages are one point for Guice: if something goes wrong you can identify the problem easily. From a user’s perspective this should be the case anyway but Guice manages this very well – as far as I noticed it.

  • Pico Container

PicoContainer is a nice piece of software that facilitates dependency injection without much overhead: no external configuration files (read XML files) and no annotations needed. All you have to do is register your components with the container; for small projects this is an effortless thing.

As with Guice you write everything in Java and can reap the benefits of your IDE’s refactoring capabilities: if you change a class’s name all references will be changed too

Categories: Java

SQL Server 2008 display error when i want to edit a table

October 28, 2009 Leave a comment

SQL 2008 Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created.

I’ve just started using SQL 2008 and have encountered a very annoying problem. Whenever I change a table I get an error:

Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.

WTF? I was able to change tables whenever I wanted to in SQL 2000 and 2005 and now I’m not allowed to in SQL 2008. Oh wait, I need to disable some stupid option that shouldn’t have been enabled in the first place. To do this follow these instructions:

Within SQL Management Studio click on the Tools menu. Then Options, then the Designer node and uncheck the box that says: Prevent saving changes that require the table to be re-created.

Now we can actually work with tables like we were able to do in SQL 2005. Nice extra step MS, next time make it more difficult to do what we need to do.

Categories: SQL Server 2008

Visual studio 2008 SP1 is available

October 27, 2009 2 comments

This is download link for VS 2008 SP1. If you want install SQL Server2008, must be install VS 2008 SP1 before

http://download.microsoft.com/download/a/3/7/a371b6d1-fc5e-44f7-914c-cb452b4043a9/VS2008SP1ENUX1512962.iso

Add telerik into VS 9

September 8, 2009 Leave a comment

Add các file .dll trong thư mục bin35 vào thư mục bin của solution và vào thư mục C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies

Categories: .NET

Hiển thị tab security trong properties của folder

July 24, 2009 1 comment

Yêu cầu trước tiên đối với phát triển module DotNetNuke là account ASPNET phải được cấp full control đối với thư mục web đó.

Read more…

Categories: DotNetNuke Tags: , ,

VS không chịu Debug website project chạy trên IIS

Ấn F5, nhận được thông báo này, buồn hẳn.

Cách fix:

  1. Vô IIS, chọn properties của webproject
  2. Trong tab Driectory Security chọn Edit ở Anonymous….
  3. Checked Integrated Windows authentication

Chạy lại debug là thấy đẹp lại ngay

Categories: .NET