Madhawa Learns To Blog : C#, Java

.net, c#, java,sql, OOAD and more mad memory dumps...

  Home  |   Contact  |   Syndication    |   Login
  35 Posts | 0 Stories | 19 Comments | 15 Trackbacks

News

Archives

Post Categories

Blog Roll

Hang Outs

My old blog

Tuesday, September 02, 2008 #

I have a small question for sharepoint experts. :)

Can we deploy a Content Type as a feature with some extended settings like "Workflow settings" and "Information management policy settings"?

If so please enlighten me on how to do that.


Monday, September 01, 2008 #

Type below in the command line replacing <MC name or IP> with the machine name or IP you want to connect. This works with WinXP and Vista.

mstsc -v:<MC name or IP> /f -console


Tuesday, August 26, 2008 #

STSDEV is a simple tool for SharePoint developers. It helps you to create SharePoint projects (with solutions precisely) and deploy templates and components into the SharePoint 2007 platform.

http://www.codeplex.com/stsdev

This tool creates project and solution in same name and in the same folder. We all know we never put the solution and project files in the same folder and never use same name for the solution and the project. Unfortunately we didn’t find a way of changing those and use the tool after since it gives errors. I found a very easy way of tweaking that from changing small line in the source code or changing a line in the generated .target file.

And furthermore I have changed the tool to support for supplying a different project name when creating a solution and now we are using it in our SharePoint project.

BTW I'll explain how to tweak the tool to use separate source folder for project by a small change in the source code in next post. Until then play with the tool and have some fun.

If you want that version of the tool with source code please email me.

 


Monday, August 25, 2008 #

One of the main things you should consider if you believe in good coding is error or exception handling. When it come to programming languages, now all popular object oriented languages have try, catch method to handle an exception.

We can put our code (which might gives errors or exceptions) inside the try block and error handling code in the catch block. This has become the de-facto of error or exception handling now.
But when it comes to T-SQL we hadn’t got that luxury. Error handling in T-SQL was always tedious and tricky job. Most of the time we used not to handle the error at the T-SQL level but handling it in the upper most level. (data access layer or business layer, handling database errors in business layer is a totally wrong practice)

But now in SQL 2005, 2008 you have proper error handling mechanism just like in modern OO languages. You can use try catch in the stored procedures and functions. Actually I knew that I can use try catch in stored procedures but only today I got to know about a more interesting method we can use.

After catching an error what we can to do was a question for me. If it’s in C# or Java we can log the error and may be throw a customized exception to the next layer. (There are so many options in handling errors)
Can you remember throw exception in C#? Of cause you know it. :) Well… we can do the same in T-SQL using RAISERROR function.

Using the RAISERROR is as follows,

BEGIN TRY
    -- RAISERROR with severity 11-19 will cause execution to
    -- jump to the CATCH block.
    RAISERROR ('Error raised in TRY block.', -- Message text.
               16, -- Severity.
               1 -- State.
               );
END TRY
BEGIN CATCH
    DECLARE @ErrorMessage NVARCHAR(4000);
    DECLARE @ErrorSeverity INT;
    DECLARE @ErrorState INT;

    SELECT
        @ErrorMessage = ERROR_MESSAGE(),
        @ErrorSeverity = ERROR_SEVERITY(),
        @ErrorState = ERROR_STATE();

    -- Use RAISERROR inside the CATCH block to return error
    -- information about the original error that caused
    -- execution to jump to the CATCH block.
    RAISERROR (@ErrorMessage, -- Message text.
               @ErrorSeverity, -- Severity.
               @ErrorState -- State.
               );
END CATCH;

Pretty good ha…
You can follow up this more in
MSDN.

 

 


Tuesday, January 29, 2008 #

Well... After 6 months I’m gonna do it again. I don’t know people who used to visit my blog still are doing that. Anyway will tell ya what happened in last 6 months later. :D


Well today I was working on deploying a SharePoint site in 64 bit server. This is the first time I’m putting my hands on x64 bit machines.  If you are used to do or want to do SharePoint deployments and never done that in 64 bit servers just keep in mind below.

There are 2 programming files folders in 64 bit machines. Normal "programming files" folder for x64 bit programs and "programming files (x86)" for 32 bit programs. So when you are using script files or solutions  (wsp files) for deployment make aware of this. More info will follow…. :)

 


Thursday, July 26, 2007 #

Google announced that they have opensourced the Google Singleton Detector, or GSD. Simply GSD is a tool which analyzes Java byte code and detects the use of Singletons.

As they say:

It's not quite as simple as that, however. First, GSD doesn't only detect singletons; it detects four different types of global state, including singletons, hingletons, mingletons and fingletons.Second, it outputs a graph with all these different types of static state highlighted, and shows all the classes that are directly dependent on them. The point of this tool is to allow you to see all of the uses of global state inside a project, as well as how they are all interrelated. Hopefully you'll be able to locate global state that is heavily depended on and remove it.

Well... Now you might think what’s wrong with the good old singleton pattern which we always use freely in every project?  Singleton pattern is the first pattern I learned and used.  

Actually there are some problems with singletons.

Major problem is that it’s hard to write unit tests if you are using singleton classes. How that could be? Well... If your unit tests are really good those should be loosely coupled. That’s mean you should be able to execute your tests without any proper order and yet those tests should be passed. But if your class had used singleton class one method can alter a state of sth in the singleton class and that would effects in the other tests. That’s make your tests are tightly coupled with each other. So you should have to have an order in executing your tests or you should reset your singleton objects in each test.

Ok folks, let’s dig into further on this problem and of cause will try to find some workarounds, in my next blog post.

 


Tuesday, July 17, 2007 #

Visual WebGui










Visual WebGui is the .net answer for GWT (Google Web Toolkit). But it’s seems more powerful than GWT even though it’s not coming from Microsoft and yet it’s open source. Still I hadn’t got time to put my hands on deeply but you can feel it by just browsing their web site and checking the features and comparing those with GWT.
Not like GWT, in Visual WebGui you can use existing windows controls to create your UI.  Major advantage of Visual WebGui over GWT is we can deploy Visual WebGui applications as web applications or desktop applications. That’s a huge step taken by Visual WebGui.  And most importantly Visual WebGui is open source.

And with world best IDE (Visual Studio 2005) you have the ultimate power of designing your graphical user interfaces. Just check these features out by visiting Visual WebGui.

User-Friendly – Visual WebGui was designed to be the next VB6 for the web. Simple to program, simple to deploy. With a full WinForms API and design time support you can start developing complex AJAX applications in seconds with no web know-how.

 

Secured – Visual WebGui was designed to provide for military grade secured AJAX applications by eliminating client side service consumption and business logic processing using an empty client concept. The browser is used as a looking glass to the server that runs the application.

 

Productive – With full WinForms API and design time support, Visual WebGui is almost as productive as R.A.D. platforms without limiting your options. Debug your application the same way you would debug any .NET application free of script debugging nightmares.

 

Powerful – Visual WebGui was designed to support enterprise class applications with unlimited complexity supported by full object oriented programming. Using our unique AJAX transport, Visual WebGui applications consume 1% of bandwidth compared to any alternative AJAX framework.

 

Feature-Rich – Visual WebGui contains most of WinForm's components including non trivial implementations of controls such as the PropertyGrid that provides a simple way to edit live objects. 

 

Supported - Visual WebGui is supported by its Core Team of developers and a dedicated international community. Through online forums and our support@visualwebgui.com mail box support is always close at hand (commercial support will be available soon).

 

Easily Installed – Visual WebGui comes with a simple installation that will get you started on developing your AJAX application in no time. Visual WebGui's toolbox and templates are integrated into Visual Studio so they are always available.

 

Localized – Visual WebGui includes full .NET and WinForms multi-language localization support which allows you to localize your application in the designer the same way you localize a WinForms application.

 

Open Source – Visual WebGui SDK is provided free, as open-source software, and licensed under a standard LGPL agreement. It allows individuals to do whatever they wish with the application framework, both commercially and non-commercially.

 

Cutting-Edge – Visual WebGui provides the developer with full object oriented .NET support allowing utilization of all the .NET capabilities including reflection, generics and more. This is enabled by a unique architecture that provides an alternative HTTP processing pipeline that does not include serializing JavaScript.

 

Extensible – Visual WebGui is provided with many customization and extensibility features including custom control creation, theme creation and gateways.

 

Interopable – As an extension to ASP.NET, Visual WebGui can also interact with standard ASP.NET pages hosting them within your Visual WebGui application or calling Visual WebGui dialogs and forms from your ASP.NET code.

 

Visual WebGui's roadmap includes…

 

Mono deployment - Allowing your Visual WebGui application to run on non Microsoft servers (Visual WebGui for .NET 1.1 is already compatible with mono).

 

Legacy to web – Migrating WinForms or VB6 applications to web with out rewriting your application.

 

Dual mode deployment – Deploy your Visual WebGui application as a desktop application or a web application enjoying the best of both worlds.


Sunday, July 15, 2007 #

Well guys... If you have read my previous blog post about Guice and you are using only .net technologies you might got little bit worried of that why you can’t use such a nice framework. Don’t worry, there is a project going on at Google called Titan that inspired by Guice. It’s still in the beta stage though. It’s a pre-release version and they don’t recommend it using in mission critical applications.

Titan is a new take on inversion of control for .NET 2.0 applications, inspired largely by Bob Lee and Kevin Bourrillion's Guice. Ultra-lightweight, easy to use, fast, flexible, and powerful, Titan aims to make inversion of control accessible to all types of .NET projects, regardless of complexity.

Goals of Titan:

1. Ultra-lightweight. We aim to keep all baseline functionality in a single assembly with no non-standard dependencies, and keep that assembly's footprint around 100KB when compiled for release. (The current version weighs in at 96KB.)

2. Easy to use. Too many of the existing IoC projects sacrifice usability for features that aren't often used. Each time a feature is added to Titan, its benefit is weighed against the complexity it adds. Our goal is to keep the 'barrier to entry' -- the baseline level of knowledge required to use Titan -- as low as possible. Titan has many advanced features, but understanding them is not required to use the toolkit.

3. Fast. Instead of relying on reflection for invocation, Titan takes advantage of the lightweight code generation features in version 2.0 of the CLR. This results in a dramatic (8-50x) improvement in speed.

4. Flexible and extensible. Titan is designed with customization and evolution in mind. Many facets of the system can be augmented or modified to fit the requirements of each project.

5. Powerful. Titan includes many advanced features. For example, most existing IoC frameworks use key-based binding to select concrete components for injection. Titan introduces the concept of contextual binding, in which a different concrete implementation of a service may be injected depending on the context in which it is requested.

http://code.google.com/p/titan-ioc/


Saturday, July 14, 2007 #

Doing some R&D works on GWT a few weeks back, I really fascinated on the Google frameworks. Next Google framework I’m gonna puts my hands on is Guice: Google way of implementing Dependency Injection.  That isn’t a company assignment but I think its worth to learn and try. Guice (pronounced "juice") is an ultra-lightweight, next-generation dependency injection container for Java 5 and later.

If you have ever tried out to achieve loose coupling to the ultimate extent you really should know about dependency injection. It’s not a buzz word anymore. People are using several of methods and frameworks to implement DI. Couple of years back when I was at my good old place (Logical Systems now known as Kandysoft) I did my first application design on my own. It was an e-commerce web site and I got instructions to develop the application framework as generic as possible. So we can re-use some of it functionalities in other applications. Our focus was on product catalog and shopping cart. Some applications product catalog and shopping cart is not separated but I thought it has to be developed as separated. So I did it and it was a very successful one. At that time I actually had heard about DI and use of it to achieve loose coupling. But only article I had read was
Martin fowlers one and I couldn’t understand it much of it at that time. And for the worse case I had limited time frame to complete and deliver the project as we always do. Anyway I gained what I wanted by  using interfaces and now I know I have implemented dependency injection by hand even though I didn’t know  I was doing that.

BTW now there are so many application frameworks that leverage use of DI and some related functionalities. I think spring is in the top. They are hitting both java and .net so it’s a great framework to developers like me who focused on both java and .net.

But if you are new to DI and doing java I think Guice is the best to put your hands on first. Like all Google frameworks it simple and easy to learn. I’ll shed some posts later on DI and Guice.


Wednesday, July 11, 2007 #

Check this out. Worth to see.

http://www.glumbert.com/media/battlespecies

Thx Senthil for the url.


Sunday, June 24, 2007 #

There is a good audio talk show in .net Rocks with Mark Pollack who founded Spring.Net. Particularly this show would be more useful if you are not aware of the potential of Spring.Net.

BTW Spring.Net has announced the release of  Spring.NET 1.1 M1 (Milestone 1). 
New features and improvements in the release are below.

    * NUnit Integration:  Aids in writing integration tests. Configuration of test cases via dependency injection and automatic transaction rollback
    * NHibernate 1.0/1.2 Integration:  Simplify use of NHibernate and participation in Spring's declarative management
    * ASP.NET AJAX Integration:  Export 'plain .NET objects' as web service, configure and apply aspects to them, and then expose inside client side Javascript.
    * Transaction and AOP XML namespaces to simplify configuration.
    * AOP support for methods with out/ref parameters.
    * Sample NHibernate application.
    * Numerous bug fixes and improvements.


Last couple of weeks I was really busy with some R&D works on Google Web Toolkit (GWT).
May be you already know GWT is an open source software development framework for creating Ajax enabled web applications like Gmail. Wonderful thing about GWT is may be you don’t have any knowledge about Ajax or in depth knowledge in java script but yet you can develop very advanced Ajax enabled applications. So if you have a web application project and a team of java developers who don’t know much about web this is it.

If you have used Ajax you might know that how tedious and annoying process is to write java scripts. You have to be concern about things like cross-browser problems, platforms and much more. We are wasting lot of our valuable time on locating and fixing JavaScript errors.

Using GWT you can create front end using Java with your favorite IDE including good old Eclipse and the GWT compiler converts your java code in to browser complaint JavaScript and HTML. So we have luxuries like debugging our code in the IDE.

If you wanna know more about GWT go to GWT home and try it. There are lots of examples and a good documentation. I bet you will really love it.


Friday, May 25, 2007 #

Well… folks it’s have been a long time that I didn’t post anything in the blog or in the forum. People were asking me, dude… what’s going on?

Actually what going on was mmm… nothing. Its just I didn’t post anything. I was kinda busy sometimes but that doesn’t mean I hadn’t got time to post sth in the blog. Any way I’m gonna start doing that thing again.

Well I think I have to explain what’s happening on past couple of months. That surely requires dozens of posts. BTW Here I’m gonna give a brief summery.

I started doing an MSc. Yes it’s the MSc in IT at University of Keele UK. I’m doing it here at IIT Sri Lanka. Actually I had planned to do a Software Engineering one but later I decided to go for an IT one. I think I made the right decision. BTW there are lots of assignments coming along. Oh man I hate assignments  but nothing to do as I have invested lots of money on the MSc.

last couple of months was a hectic in my personal life which I don’t like to talk abt here. And my professional life was so boring and I can say I was idle and that was my most boring time in the career. There were lots of reasons behind that and I think I have made a good move to overcome that. The move ha… mmm as some of you folks already know I’m doing java these days. :D
Doing .net for abt 4 years and moving into java… as to some of my friends it’s the maddest and craziest decision I have ever made in my professional life. But I’m happy abt the move and these days I feel like I’m alive again. I had one month to learn java and still I’m learning various aspects of java technology. Honestly I don’t like swing and I’m looking forward to do some backend works but who knows what would happen? BTW if I get front end things to do there would be another big move in my professional life.

When I was looking for OO things like design patterns I always preferred java sites. Especially in java world there are tons of good articles on that. So I always thought I will do some java in my developer life. So I think this is it and I got a good chance. And I won’t let my .net skills to go away I’m planning a big training session on .net framework (3.0 and 3.5) on my self. Well I have witnessed some similarities as well as different things in java and c# as well as .net framework and j2ee/j2se.

Mmm I think this is enough for this post. I’m trying to maintain high cohesion in my blog : D.


Wednesday, December 13, 2006 #

It’s seems to me that lot of developers still don’t know there is a very easy way to create a temp SSL for your local server for testing your web application.

 

You don’t have to obtain a trial SSL’s from third party venders or installing and using certificate service.

 

All you have to do is just use selfssl.exe which coming with IIS6 resource kit . Even though that resource kit is for IIS6 you can use it (selfssl.exe) with XP (IIS 5.1). I think it’s also compatible with Win2k also (IIS 5.0).

 

BTW Today I found this simple tutorial which describes nicely how to install IIS6 Resource kit and use selfssl.exe.

 

http://www.visualwin.com/SelfSSL/


Friday, November 03, 2006 #

If you are coming from vs2k3 background you might know how easy to get the XML view of a Typed DataSet. But unfortunately in vs2k5 they have removed that convenient XML view tab.

So how we gonna see the xml of the typed dataset. One of my friends asked me today and my instance answer was use other editor to get that facility. But after doing some research I found that we can get into xml view by right clicking the XSD file in the solution explorer and picking “open with”. Not only the xml view but you can choose some other views from couple other options.