Sunday, August 21, 2011

New move of software development

As your awareness, in some recent years, the software technologies has changed a lot in the very fast pace. Remembered that one or two years ago, Microsoft technologies seem to be on the top with lots of new tools introduced like: ASP.NET MVC, MEF, Silverlight, .NET Framework 4. 0, LINQ. ..

But for now, Microsoft is no longer a leader on technologies, even though I have felt that this big company is likely kind of later than others, especially open source technologies. With the birth of HTML5 and the popularity of REST, mobile development, No Sql, the software development world has changed differently for the new decade.


HTML5 is born to change our thought of front end technologies and shorten the gap between web UI and Win UI, the gap between desktop development and mobile development. HTML5 has been dominating UI and might be the killer of other technologies: WPF, Silverlight, Flex…. As you might know MS has announced to build Windows 8 on HTML5 and they did a review for this. It also led to the dead of cookie whose data-capacity limitation and always carried over HTTP requests with the new introduction of web storage: local storage and session storage.

HTML5 is ready to adopt into mobile web development as its standard continues to evolve and will become a strong alternative with native applications on mobile operating system like Android, iOS because of its very strong pro: able to be multi-platform.

Web Socket, I believe it will come to the standard soon and resolved some security problems rose from Microsoft. With Web socket, it will be easy for us to push data from server to client over one and only one open TCP connection which we cannot do it before, this only way to do is polling requests from client to server to fetch data, although comet and some other technologies were born to solve this but they are still polling mechanism.


With HTML5, JavaScript is becoming the king language in frontend layer, most of developers thought that JavaScript is just a toy language before but now we need to re-think again how important it is and eventually JavaScript is likely the first and essential language to learn. Right now, there are a lot of JavaScript libraries which are used a lot: jQuery, CoffeeScript, Backbone, Knockout, Node… and on the way to be becoming frontend framework for web development.

REST architecture

REST has come out for long time, from thesis of Thomas Fielding on 2000, but now it is more and more popular. Remember that REST is not standard like other RPC (Remote Procedure Call) SOAP, AMF… it is just style in order to build distribution application based on HTTP and use HTTP methods. So, you are able to use any language with its pro: simple and lightweight.

I do believe that with the evolution of REST and JavaScript, it seems we only need REST service on the backend and use JavaScript to get data from REST and render in browser. Needless to have web technology on the server to mediate like ASP.NET MVC…. There are just frontend frameworks with JavaScript and HTML5 and REST service is enough to build a web application.

REST also led to the dead of SOAP, a standard promoted by Don Box, truly SOAP is inessentially complicated and does need lots of configuration compared to REST.  Most of popular services on web are REST service: Flickr, Twitter, GitHub.

For all above, SOAP service, WCF should be in consideration because it is based heavily on SOAP.


Relational database has been for long time although it is likely dominant database architecture in two decades. But now, it has changed with the new evolution of Non-relational database like: document database, json database, graph database with popular tools: Mongo, Cassandra, Redis and many others are maturing daily and play important role in software architecture. Lots of big web apps are using No SQL, Facebook, Google+, and Twitter.

With the new move of software development, my current focus will be on HTML5, JavaScript, REST and consideration to use on technologies: SOAP, Silverlight, WPF, and WCF…

Monday, July 13, 2009

Concepts and principles over technologies

Being a .NET developer, most of you surely was wondering one thing that why Microsoft releases technologies too fast, I have nearly five year experiences in .NET technologies, but I still feel getting drown and cannot keep up the newest technologies from Microsoft. I have not yet touched Silverlight 2.0, Microsoft has already released Silverlight 3.0, I just got VS 2008 and are learning .NET framework 3.5, again Microsoft has released and framework 3.5 SP1 and even introduces VS 2010 beta and framework 4.0 right after... and a lot of new technologies that I feel that I seem have not enough time to grasp of such as Oslo, Dublin, Azure, Astoria, Velocity, MVC... oops, confess that I cannot grasp of all technologies from Microsoft and I am sure that most of you feel the same way with me, right?

So the question is: whether we are supposed to know all new technologies in the very fast pace like now? if not, what we need to focus on?

As far as I know, a lot of developers, they tried to learn a lot of new technologies asap, but they actually don't understand what is behind the scene, they just tried to learn how to use it, not how to get into it and the concept beyond the wall. For instance, they use LINQ to SQL or Entity Framework smoothly, drag and drop data context, VS then generate code and use it, it's easy huh? but just few developers know some key principles: Unit of works, Identity Map, Data Mapper... behind OR mapping tools, that's it.

Although, I am a .NET developer, use .NET framework for learning and working, but some points from Microsoft that I don't like, don't you notice that Microsoft has a lot of "drag and drop development" tools for you, they will turn you to be a "drag and drop" developer and needless to know anything behind the scene. Can you imagine, wow, it is easy for you to design a web page by drap and drop even without knowing Html (kind of exaggerated in here), use WPF without knowing xaml, use OR Mapping with Linq to Sql or EF without knowing "OR Mapping"... I know that it will improve productivity and performance to get more benefit but honestly I don't want to be a "drag and drop" developer, I wanna have more controls on what I am doing, don't you feel puzzling and shout at Microsoft "what the heck?" because you don't know code, don't know anything. If I have options to opt (normally I have not :D), I will prefer ASP.NET MVC over webform, NHibernate over EF (LINQ to SQL is not counted in because you know the reason)

So, come back the question, for me, I would say "concepts and principles over technologies", I will totally focus on underlying concepts, patterns and principles for each technologies if I have chances to touch, though. Let's be SOLID (principles), be "PATTERNs".

Some of you might ask me WHY? Just simple, you have not enough time for all technologies, because you as well have to spend time for family, friends, and... beers. Why you have to learn all? for me just pick up some of them to learn and focus on principles in lieu of technologies. Pick up one of Ioc Containers: Unity, StructureMap, NInject, Winsor Castle, and focus dependency injection pattern in lieu of how to use them, pick up one of OR Mappings: EF, LINQ to SQL, NHibernate or Subsonic... to use and focus on persistence patterns (active record, unit of work, identity map, repository, persistent ignorance, data mapper...). One more thing, if you grasp of principles, you will find easy to learn other similar tools and pick up new technologies much faster, you also give better judgements the pros and cons of each tools and which tool is more appropriate for your project, just what I thought.

Friday, July 3, 2009

Dependency Injection

Inspired of rise of Dependency Injection (DI), I try to explain this concept in the simple way in this post and hope you understand it. DI now become very popular pattern in software development, both Java and .Net, you can find a lot of articles talking about, by putting the word "dependency injection" on google textbox, you will see. This pattern is invented by Martin Flower and here is his orginal article:

So, let's first talk dependency between two classes. As my thinking, we just have two kind of dependency:

1. Loose dependency. A class has dependency to interface of other class. In this below example, CustomerService have dependency to ICustomerRepository.

2. Tight dependency. Class A is created inside class B, or class B has creation dependency to class A:

So, the purpose is to turn from tight dependency to loose dependency between two classes, we need to follow the rule: the instant of a class need creating outside of other class. It is also called INVERSION OF CONTROL (IoC).

Some of you might concern what is the difference between IoC and DI? You can imagine that IoC is a principle and DI is just a methodology of this principle. How to do IoC? the answer is using DI, that's simple.

There are 4 types of DI for you to use as below:

1. Constructor DI, like above example in loose dependency
2. Property DI.
3. Interface DI.
4. Service Locator.

We often use constructor DI and property DI.
The pros of DI that everyone knows: LOOSE COUPLING between two objects. So why LOOSE COUPLING:

1. Easy to unit test for using mock object. If you are not familiar with mocking framework, I recommend take a look at Rhino, Moq or NMock2. For me I prefer Rhino Mock. Maybe I will write more about of unit test and mocking framework later. But you can know that the magic of unit test and mocking framework will improve your code design, the more your code is cover, the better your design are.

2. Easy for trouble shooting.

3. Maintainability will be improved as well, follow principle OOP (Open Close principle), your application will be more sustainable.

Talking about DI container or IoC container. This is is an abstraction responsible for object management, instantiation and configuration. Let's imagine that when you create an object, container will automatically create injects all dependent objects of this object into its constructor if you use constructor injection and so on. Technically, DI container is something like type pool or object pool that takes responsibility for creating objects and injecting dependency (DI). This is the difference of DI and DI container. With DI container, we also must notice about the lifetime of an object in container (or lifetime management), in general we have 3 lifetime managers:

1. Singleton. Hope you know what singleton is.

2. Per thread. Object is created when thread is created and is died when thread is died. More detail, object is contained in data slot of the thread.

3. Per request. For web application, object will live during the time of an HTTP request.

Be careful when using lifetime manager, depend on which context you should use which lifetime manager appropriately. Typical example that our team got: DON'T use data context as singleton, it will be a nightmare for you.

There are a lot of DI tools for you to find as below:

1. Unity from Microsoft, in Enterprise Library.
2. StructureMap from Jeremy Miller (my idol).
3. Spring.Net.
4. NInject.
5. Windsor Catlse.
6. Who knows more?

If you think that, ugh, why are there a lot of DI tools right now? you might be confused when opting an DI tool, maybe in the future you can switch to another DI tools, use Windsor castle in lieu of Unity for example. You just want to have a common interface for all DI tools, there are also a good solution for this kind of problem: Common Service Locator

Right now, DI is used a lot. Example for MVC when you customize controller factory (in mvc) to inject services into controllers (example in here will be better). As a chain of dependencies, DI container will continue inject repository (repository pattern) into services, then container injects Unit of work (DataContext, ObjectContext) into repository, my thought, or bla bla bla. Below is example how to injection dependency object into controllers:

Hope my little words above will make you clear about DI and DI Container

@My colleagues I know most of you are masters of this kind of concepts, correct me if I am wrong in here, your comments are always welcome.