Sunday, February 3, 2008

TFS vs Others

Here is some of the features that I found in TFS but not in other version controls (CVS and SVN)
  • Rename - It will automatically rename your file without removing from CVS / SVN.
    Probably, Visual SVN also has this feature, But I never test it.

  • When Adding a project into source controls, It will efficiently exclude the bin folder and other files that will dynamically created. This will make source control very efficient. On the other hand, if using CVS/ SVN, you need to exclude the bin folder manually.

    TFS knows .net source files better than other source control.

  • TFS has integrated with VS nicely. more than Visual SVN.

  • TFS has integrated with Development Pattern methodology such as MSF Agile and CMMI
    More over you can add your custom development pattern and process.

  • It integrate with Sharepoint portal which enhance the functionality as document management and documentation process such as WIKI and Blogs.

TFS on VS 2008 Beta 2 - Adding a lost files

After playing around with TFS on VS 2008, I found a difficulties to add a new file which I have created outside VS 2008.

In another scenario may happen if you want to recover unintentionally delete and at the same time merge with the previous version.

Somehow, It displays an error after I merge my lost file which says that I need to choose the server version or my version. But I does not have an option to do that.

However after fiddling with it for 1 hour, Finally I found the easiest way to dealing with those issues.

  1. In source control , Right Click on directory which contains your new file or file that you want to recover.
  2. select Compare.
  3. TFS will list all new files or lost files and you can easily added into your source control.

Load Testing on AJAX Application

Sometimes we need to perform a web test and load test for AJAX Application especially in partial postback.

VS 2005 Test edition / Team System provides a functionality to perform a web test. However the limitation is , it can not capture a partial postback.

For that reason we need one of the web capture tool called fiddler to capture all ajax request and response and we save it as Visual studio web test. and After that we can perform our ajax Load Test using VS 2005 Test edition / Team system.

Here are the steps

Before we perform load test, we need to create a web test first.

You may create multiple web tests to perform different scenario test cases.

In order to test an AJAX, you need to capture using Fiddler.

Here are the steps:

  1. Open Fiddler application.

  2. Open Internet Explorer and perform a scenario of your test. Fiddler will automatically log your request and response even for partial Post back /AJAX

  3. Select All fiddler capture session responses and requests

  4. On Fiddler menu File>Save>Session(s)>as Visual Studio Web Test

  5. Import this web test into your VS Test project.

  6. And it's ready to perform load test by creating a load test file inside VS
Note: You may set a windows credential in your web test.
  • There is an icon on the top tool bar of your web test.

Thursday, January 31, 2008

Silverlight 2.0 is coming


Silverlight 2.0 is coming. It' s originally called Silverlight 1.1. I don't why they changed the name into 2.0. rrr....


The cool thing in Silverlight 2.0 is :
  • Include CLR as .Net Framework 3.0 (so you can use code behind in Vb.net / C#
    Base Class Library (BCL) provides classes for collections, reflection, regex, string handling, data access

  • Dynamic Language runtime in media files
    The first available languages written for the DLR are Iron Python 2.0 and Managed JScript.
    Microsoft is also building Iron Ruby and Dynamic Visual Basic (VBx) languages.

    Conversely, other .NET languages must be compiled ahead of time and delivered to Silverlight as .NET assemblies. The implementation of Managed JScript conforms to the ECMA Script 3.0 specification, and Microsoft claims that it is 250 times faster than interpreted JScript.
    http://weblogs.asp.net/scottgu/archive/2007/05/07/silverlight.

  • Extensible controls
  • XML Web Services - Data access over XML-based Web Service and WCF ( POX, REST, JSON )
  • Networking
  • LINQ API ( full support for LINQ to Objects and Expression Trees)
  • WPF model (Shapes, document, media and animation objects)
Limitation:

The current release, the UI controls do not have support for databinding to any data source. But, Microsoft has clarified that the limitations are due to this being an early preview release. Future releases will add more than 20 UI controls add two-way databinding support, and automated layout management as well as data manipulation controls such as data grid.
http://blogs.msdn.com/somasegar/archive/2007/11/29/quick-update-on-silverlight.aspx

Wednesday, January 30, 2008

Deferred Execution in LINQ

To boost the performance in Linq deferred execution, Linq has provided a nice method
called ToArray() and ToList()

By using those method, you just need to execute query into database once and iterate locally through your array or list.

Hibrenate - Lazy Initialization (could not initialize proxy - the owning session was closed)

Hibernate object relational mapping offers both lazy and non-lazy modes of object initialization. Non-lazy initialization retrieves an object and all of its related objects at load time. This can result in hundreds if not thousands of select statements when retrieving one entity. The problem is compounded when bi-directional relationships are used, often causing entire databases to be loaded during the initial request. Of course one could tediously examine each object relationship and manually remove those most costly, but in the end, we may be losing the ease of use benefit sought in using the ORM tool.


Hibernate proxies can be very handy if you have performance concerns, the idea is to load the objects lazily as proxies and never hit the database. The proxies are initialized meaning fetched from the database when they are first accessed, however life is not so easy:) Whether there is a configured filter-interceptor of spring to manage hibernate sessions or you manually take care of the session’s life cycle, once the session was closed, the proxies attached to that will lead to a proxy initialization error if they are accessed later.

The reason is tricky, a hibernate session is created and some data is loaded to the session as a proxy, later the session is closed without an access to the proxy occurred. Then proxy is decided to be used and accessed, at this point one may get the error “no session or session was closed” since the session which the proxy is attached is “closed”. In order to deal with this situation there are some solutions.

1) Reloading the proxy “before” using it in the new session, this will attach the new proxy to the new session.

2) Using static method Hibernate.initialize(obj) before the owning session was closed, this will hit the db and replace the proxy with the actual data.

3) Using a Session lock via Session.lock(obj,lockmode), this will reattach the proxy to the new session.

4) Or you just disable lazy initialization mode by mark the flag into false (lazy=false)

As you see this proxy business isn’t simple as it seems but I belive once you learn how to use them they are the best way to optimize the performance.In the end who has not the need for speed?

Monday, January 7, 2008

Abstract VS Interface

multiple inheritance
INTERFACE-A class may implement several interfaces.
ABSTRACT-A class may extend only one abstract class.

default implementation
INTERFACE- cannot provide any code at all, much less default code.
ABSTRACT- can provide complete code, default code, and/or just stubs that have to be overridden.

is-a vs -able or can-do
INTERFACE- are often used to describe the peripheral abilities of a class, not its central identity, e.g. an Automobile class might implement the Recyclable interface, which could apply to many otherwise totally unrelated objects.
ABSTRACT-defines the core identity of its descendants. If you defined a Dog abstract class then Datamation descendants are Dogs, they are not merely dog able. Implemented interfaces enumerate the general things a class can do, not the things a class is.

plug-in
INTERFACE- You can write a new replacement module for an interface that contains not one stick of code in common with the existing implementations. When you implement the interface, you start from scratch without any default implementation. You have to obtain your tools from other classes; nothing comes with the interface other than a few constants. This gives you freedom to implement a radically different internal design.
ABSTRACT-You must use the abstract class as-is for the code base, with all its attendant baggage, good or bad. The abstract class author has imposed structure on you. Depending on the cleverness of the author of the abstract class, this may be good or bad.

homogeneity
INTERFACE- If all the various implementations share is the method signatures, then an interface works best.
ABSTRACT-If the various implementations are all of a kind and share a common status and behaviour, usually an abstract class works best. Another issue that’s important is what I call "heterogeneous vs. homogeneous." If implementors/subclasses are homogeneous, tend towards an abstract base class. If they are heterogeneous, use an interface. (Now all I have to do is come up with a good definition of hetero/homo-generous in this context.) If the various objects are all of-a-kind, and share a common state and behavior, then tend towards a common base class. If all they share is a set of method signatures, then tend towards an interface.

maintenance
INTERFACE- If your client code talks only in terms of an interface, you can easily change the concrete implementation behind it, using a factory method.
ABSTRACT- Just like an interface, if your client code talks only in terms of an abstract class, you can easily change the concrete implementation behind it, using a factory method.

adding functionality
INTERFACE- If you add a new method to an interface, you must track down all implementations of that interface in the universe and provide them with a concrete implementation of that method.
ABSTRACT- If you add a new method to an abstract class, you have the option of providing a default implementation of it. Then all existing code will continue to work without change.