Monday, November 24, 2008

Dotnet Enterprise Library

Enterprise Library has 8 parts namely,Data Access Application blocks, caching application blocks, logging application blocks, Exception handling application blocks, security application blocks, cryptography application block, validation application block, policy injection application block.

It is not a pattern, it is not part of dot net framework, Its not an application framework. This is not a Microsoft framework, it is community project with source code.

Choose DataAccessApplicationBlocks when DB operations are standard and doesn't need any customization, need an easy way to switch between databases, portable code for multiple data sources.

Exception shielding in Exception Blocks helps prevent web service from disclosing internal information in case of errors.

Download latest enterprise library from below location.

You can use more then one application blocks with combination.
http://www.microsoft.com/downloads/details.aspx?FamilyId=90DE37E0-7B42-4044-99BE-F8ECFBBC5B65&displaylang=en

you can find all the releases of enterprise library in the below link
http://msdn.microsoft.com/en-us/library/cc467894.aspx

Consistency, easy of use, extensibility and integration are the main goal features of Enterprise Libraries.

Refer to below excellent article on application blocks, consider reading this before implementing.
http://msdn.microsoft.com/en-us/library/cc816060.aspx

Happy Learning !!!

Tips and Tricks of Dotnet II

Continued from part I, refer to part I below....

http://suryaprakashj.blogspot.com/2008/11/tips-and-tricks-of-dotnet.html

The TraceSwitch class provides a switch that allows you to control tracing and debugging output of a .Net application without recompiling the code. You can use the switch to change trace options simply by using the config file.


The invariant culture is a culture-neutral storage format.

Web user controls can only be shared by copying their files into each application that you want to use the control in.

A web garden is basically just a single computer with multiple processors. The advantage of a web garden is that you can add additional processors to this single computer to boost the power and speed of your web application.

DataList is the only one which allows you to display two columns.

The FileStream class allows for byte-by-byte input or output

The StandardTab property should be set to True to move the focus to the next control in the tab order rather than move focus to the next cell in the DataGridView

Use a TableLayoutPanel and create the desired rows and columns. It can change dynamically as the application environment changes hence adjusting the controls contained within it.

Sunday, November 23, 2008

Tips and Tricks of Dotnet

If you are implementing atleast 10 of the below tricks / tips in your code, you are giving performance oriented to your client. This is a collection from my previous experience or my reading on internet.

System.io.compression namespace has the objects useful for zipping and unzipping files in .net 2.0 onwards. Sharpzip is also a opensource option.

To remove the dupliacates in an arraylist simply copy it into hashset (hashes eliminate duplicates) and copy that back into arraylist.

Databinder.eval has same syntax for vb.net and c#.net, it might be a performance block because it uses runtime reflection to convert the object (int,object,byte,string) into a string. Better use Databinder.datarow[i]......

using the WebRequest class, you can screen scrape web pages, and pass the resulting Html string to the MailMessage object. Mail will look like your html page.

How many TPS (Transactions Per Second) you want to your application to handle.

Perfromance Objectives are Throughput, Response time, Resource utilization, work load (data , users, transactions)

Coupling cohesion, communication, concurrency, resource, caching, state management, Datastructures and algorithms.

If your image has fewere colors use GIF format, if your image has more colors use JPEG.

Arraylist, sortedlist, Namedvalue collection --->sort

Hashtable, stringdictionary, listdictionary ---> search

Don't use Array list for storing strings, use it for custom objects and where you have insert and delete operations frequently.

use string collection to store strings. Use hash table for frequently queried data, with key pair combination. Use hybrid Dictionary for frequently queried data , low size.

use queue for FIFO kind of purposes and stack for LIFO kind of purposes. Use Sorted list for fast object retrieval (don't use it for large amount of data). In case of large data use array list and use sort method.

Hybrid Dictionary uses List dictionary for small size data and uses hash table for large data. List dictionary is useful for 10 or less key value players.

Use for loop instead of Foreach , because of enumeration in foreach loop performance will be hit.

StringCollection is strongly typed arraylist of strings.

StringDictionary is a hash table with the key strongly typed to be a string rather than an object.

Early binding allows the compiler to identify the specific type required and perform optimizations that
are used at run time. Late binding defers the type identification process until run time and requires
extra processing instructions to allow type identification and initialization. (TypeOf, GetType, and IsInstanceOfType)

each time you are using string concatination, new string is created. so use string builder instead of string if you want to do concatination.

always use page.ispostback == false for first time initializations

Use server.transfer than response.redirect, ensure debug is set to false, clientside validations

Don't mix multiple languages in the same directory.

pages having server control, datagrid will increase load of viewstate. Avoid server controls when not needed, like no need to retain across postbacks (labels), readonly data.

Use caching on asp.net page, it uses LRU(least recently used) algo to clear the content. you can expire the cache with timer also. put infrequently modified data like headers in cache.

If you want to store user specific data use session instead of caching.

Use cookies, hiddencontrol, querystring for lightweight data and not needed much security.

Response.write, string builder, htmltextwriter are good for performance.

From asp.net 2.0 onwards you can take advantage of 64 bit servers.

use System.data.sqlclient for sql 7.0 onwards (as it uses TDS - Tabular Data Stream protocol). System.data.oledb for sqlserver 6.5

when using datareader specify commandbehaviour.close connection.

use executenonquery for commands that doesnt return any data. dont use select *, specify columns you need. Set NO COUNT ON in stored proc.

Friday, November 21, 2008

Outlook Add - in with Dotnet

Do you know we have separate tool kit in Visual studio 2008 for creating Add-ins for outlook, Word , Excel etc., You can use it for specific business flows as well.

Let me explain how it will be useful in a typical business scenario. You can develop add-in called Purchase Order Processor to your outlook.

Whenever some one want to place a purchase Order, he will clik on the add-in it will open a windows form. He will enter all the details and it will submit the form for the approver with a mail. Once approver opens the mail he will get the details of that order, he can approver or Deny it. If he approves the order mail request will be sent to vendor, if he denys the order mail will be sent to requester.

You can achieve all functionalities like connecting to Database, reports, download of excel, pdf's. In short you can automize business workflow simply from outlook.
Lets see the technically options for implementation.

Options
1. Developing COM add in VBA: In outlook go to Tools --> Forms --> Design Form --> select library from Look in. You have variety of standard library's from which you can select. You have to write code in VBA.
Pro:
Quick development.
Con:
Old fashioned development. Customization, scalability is limited.

2. Developing using Visual Studio Tools for Office (VSTO): You can develop using VB.net or C#.net add-in for Outlook for 2003 or 2007. If you have visual studio 2005, you have to download VSTO from here:
http://msdn.microsoft.com/en-us/office/aa718674.aspx
If you are using Visual Studio 2008 it comes in built in.

Advantage of VSTO option:
A solution structure that includes both the add-in project itself and a setup project to ease deployment
Simple Start up and Shutdown events where developers start adding their code
A run time component
An add-in loader that creates the add-In's App Domain and handles security and some other add-in essentials
Not to mention better debugging and error handling.

You can select "Extensibility Projects" in "Other projects" in Visual Studio templates. You have to select add-in project specific for word, excel, outlook etc.,
You can handle all events in the IDTExtensibility2 class, Like On add-in start, update, on add-in connection, disconnection, close etc.,

You can implement windows form to create and submit custom Forms.

For deployment you can make use of click once deployment by Microsoft or simply copy the DLL and manifest to user computer office add-In's folder. When he starts the application (word, excel, outlook ) the add-in will be automatically detected.
Happy Learning.

Wednesday, November 12, 2008

Software Productivity, Quality and Innovations

--This article is compilation from different source embedded with my views.--

In old days programs are written in C and C++ (you can imagine how hard it must be) of course for controlling systems, Defense applications and automatic logic inside tools and appliances. Now the purpose of software crawled to new heights. Most of the development is happening on WEB or client applications. We have very good editors for programming languages, good tools for testing, source control, deployment etc., still Quality and Productivity in Software industry is a question. WHY ???

Besides maintaining quality and productivity how many major innovations happened in Software. Few of the impressive innovations are email, search engine, messengers, social community sites, ecommerce, TV on Internet, etc.,
Microsoft is working closely with a innovative firm in India to develop software for a robot, which can unharvest coconut from coconut trees. Research is going on. If it succeeds it will be a millions of dollars business and raises curtain for billions of innovations.
I strongly believe Universities are the places where the seed of innovation starts. we need to encourage R&D at universities especially in India. Though 30%+ employees in Microsoft are Indians no Indian entrepreneur was able to capture this market !!!

How many options are available at different stages software development:
the software industry has more than 600 programming languages in use. We
have more than 40 different methods of designing applications. We have 38 different
kinds of size metrics. We have some 26 named development methods. There are about
25 international standards that affect software. There are at least 18 different kinds of
testing, and four different kinds of review and inspection method.

How many methodologies Software has:
Agile development, the capability maturity model (CMM), the
capability maturity model integration (CMMI), CASE tools, clean-room development,
CRYSTAL development approach, dynamic system development method (DSDM),
extreme programming (XP), incremental development, ISO 9000-9004 standards,
iterative development, object-oriented development, pattern-based development, personal
software process (PSP), rapid application development (RAD), reusability, SCRUM, six sigma
for software, spiral development, team structured process (TSP), total quality
management (TQM), and the unified modeling language (UML).

Software Engineering Issues that have stayed constant over years
Initial requirements are seldom more than 50% complete.
Requirements grow at about 2% per calendar month during development.
About 20% of initial requirements are delayed until a second release.
Finding and fixing bugs is the most expensive software activity.
Creating paper documents is the second most expensive software activity.
Coding is the third most expensive software activity.
Meetings and discussions are the fourth most expensive activity.
Most forms of testing are less than 30% efficient in finding bugs.
Most forms of testing touch less than 50% of the code being tested.
There are more defects in requirements and design than in source code.
There are more defects in test cases than in the software itself.
Defects in requirements, design, and code average 5.0 per function point.
Total defect removal efficiency before release averages only about 85%.
About 15% of software defects are delivered to customers.
About 5% of modules in applications will contain 50% of all defects.
About 7% of all defect repairs will accidentally inject new defects.
About 5% of software outsource contracts end up in litigation.
About 35% of projects > 10,000 function points will be cancelled.
About 50% of projects > 10,000 function points will be one year late.
Development costs about $1200 per function point in the U.S.
Maintenance costs about $150 per function point per calendar year.
After delivery applications grow at about 7% per calendar year during use.
Programmers need about 10 days of annual training to stay current.

Hope you had fun !!!

Thursday, November 6, 2008

SOA through WCF in Dotnet

SOA came into picture in late 1990's and early 2000's. Microsoft also introduced this in their 1.1 dot net framework through webservices, which was released in 2001. Before this companies were using Vitria middle ware. Other ways of implementing SOA are Remoting, DCOM, MSMQ etc.,

After all this there is a need to write code irrespective of implementation details whether it is webservice, DCOM, MSMQ or Remoting. This requirement is the birth of WCF. Microsfot released WCF in Fall 2006 as part of Dotnet Framework 3.0.

WCF supposed to work interoperably irrespective of enterprise servers.

http://it.toolbox.com/blogs/paytonbyrd/wcf-and-soa-getting-there-from-here-18438

you can find some nice tips here as well.http://weblogs.asp.net/socratees/archive/2007/11/03/wcf-and-soa-cool-tips.aspx

SOA gives us new option to refactor the existing architecture aliging to todays needs and promising tomorrow's scalability. Reusability makes the SOA great, it is one of the core pillar. The core factors of WCF are simple, secure, reliable, interoperable.

WCF with combination of WF (Workflow Foundation) promise to bridge the gap between technology and business. WF defines the business workflow while WCF promises scalable mode to the businss using the existing legacy systems for tomorrow needs.

You will be building WCF in .net 3.0 by selecting new template from visual studio which WCF template.
After adding "Hello World" kind of program, publish the site using Tools menu.
Add Service reference (this is 3rd option after "add reference" and "web reference") by selecting the SVC extention file url.

If you would like to have code and want to explore all the functionalities check the workshopt links below

http://www.sheltonblog.com/archive/2007/10/06/all-6-parts-of-the-soa-development-with-windows-communications.aspx

WCF is more than a web service in .net, it can handle other than HTTP interfaces, which web service can not do. WCF can handle MSMQ, TCP interface inputs as well.

Please keep in mind SOA will never be as quick as client application or database solution.

Happy Learning.......

Monday, November 3, 2008

Microsoft Solution Framework

While i was going through some of the articles on Microsoft methodologies. I found this new buzz word Microsoft Solution Framework.

This is a solution framework from Microsoft, targets a different approach than regular software methodologies and enables rapid applicaiton development.
Generally S/W development is basing on Water fall model or spiral model. MSF (Microsft Solution Framework) tried to get you best of both the worlds.

The main elements of solution are as below

Documentation
Selected technologies and custom code
Communications
Training
Support


Give a look at the diagramatic representation of this methodology.



This model explains the relationship between key elements of S/W deliverables namely Resources, Schedule and Feature. This is named as Trade off Triangle. You can fix one of these three and you can adust the other two components as per your convenience.

It provides people and process guidance from Team perspective. So as you can expect it is part of MSTS. It brings in Milestone based approach as well.

Find more details about this at the below article.




If you are looking for a text book definition, here it is from Wikipedia. You can find the interesting version history also here.




So following atleast one methodology will mitigate the risk of "COWBOY CODING" (Team member do whatever they feel is right)


Happy Learning !!!
 
web counter
Download a free hit counter here.