Yanesh Tyagi writes …

November 20, 2009

Architecture Definition and Development

Filed under: Programming, Technology — yaneshtyagi @ 3:52 am
Tags:

One of the major challenge I felt as an architect is that client or project stakeholders want everything to be put in the architectural documents. A couple of days ago, I was in the conference with the client’s Project Manager. We were discussing the architecture of the new application, we are going to develop. I have mentioned major classes and components in the rational rose model. But the Project Manager was insisting that I should mention every class  in the model. And as this was not enough, he said that I should not miss any property or method of any class, public or private. And to make the things worst, requirements were not finalized at that time. We were expecting next version of the requirement documents in a couple of days. I had a hard time to convince PM that it’s neither possible not feasible to put so much details in the documents. So, I decided to post my thoughts on this matter.

What should be the depth of architecture?

This is the most challenging question for an architect. At the top level you can decide. For example you can settle down that the use case diagrams, component diagrams, class diagrams and sequential diagrams will do the work for your application. However, the problems comes when you decide depth of these diagrams. I have seen use case diagrams defined from the 30,000 feet to 100 feet.

For example, while looking at the design document for a web project, I found only one use case. This has two actors – webmaster and visitor. And there was only one use case – the application itself. A good example of 30,000 feet altitude view :) .

Anther extreme case was with a windows application with only three forms. And they have defined around 40 use cases for this. Each method was a use case in itself. A good example of 100 feet (or even 10 feet) altitude.

There are many same stories for other diagrams as well. As I stated in the beginning of this post, defining each and every method of each class in a big application is 10 feet altitude. This is neither feasible nor practical. I feel that we should remain at an altitude of 1000 feet to 5000 feet. At this range, we provide the details which are small enough for the management to have a bird’s eye view of the architecture and good enough for the development team to have guidelines to code. This does not bound the developers to the defined architecture – they are free (to certain extent) to showcase their creativity. Having clear understanding of the objectives of the architectural documents makes the decision making easier.

What is the objective of architecture and design document?

There are two types of technical documents – informational and manual. Manuals are supposed to have detailed information about any product, service, or whatever. But informational documents are meant for communication. If you put too much details in an informational document, its will be a waste of efforts. No one is going to read it line by line. Communication should be short and to-the-point. According to easycommunication.info, communication should be “adequate briefing of the recipient”. Notice that they use the word briefing. The same is true for architectural document.

These documents are supposed to communicate main architectural decisions and relationship with major components of the system. They should include only relevant information. If you put all the details in the architectural documentation, it will become a manual of the system and will fail to communicate its core purpose. So, what should be included in the architecture and design documents? This post is getting longer, so I will answer this question in the words of Martin Fowler, the architecture guru.

Do we define everything in the architecture?

Martin Fowler says “Draw a class diagram that shows the important classes in the package but not necessarily all of them”. He further tells that “For each class show only the key attributes and operations, definitely don’t show all of them”.

More of this stuff in the next post. I know you are getting bored.

 

Follow_Me_On_Tweeter_For_BlogTweet_This4

Digg This

October 21, 2008

Getting Browser Information and Capabilities in ASP.Net

Filed under: .Net, Programming, Web Technology — yaneshtyagi @ 7:40 am
Tags:

While developing a web site or web application, one need to keep in mind the features supported by different browsers. This is very unfortunate that there is no industry standard in the browser market. Fortunately ASP.net provides HttpBroserCapability class to determine the browser type and features supported by the browser.

The browser property of request object returns the object of HttpBrowserCapability object. This object has several properties which provide the information about the browser type, version and features supported by this.

Following C# code explains how you can use HttpBrowserCapability class to fetch browser information.

private void btnBrowserInfo_Click(object sender, System.EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = “Browser Capabilities\n”
+ “Type = “                    + browser.Type + “\n”
+ “Name = “                    + browser.Browser + “\n”
+ “Version = “                 + browser.Version + “\n”
+ “Major Version = “           + browser.MajorVersion + “\n”
+ “Minor Version = “           + browser.MinorVersion + “\n”
+ “Platform = “                + browser.Platform + “\n”
+ “Is Beta = “                 + browser.Beta + “\n”
+ “Is Crawler = “              + browser.Crawler + “\n”
+ “Is AOL = “                  + browser.AOL + “\n”
+ “Is Win16 = “                + browser.Win16 + “\n”
+ “Is Win32 = “                + browser.Win32 + “\n”
+ “Supports Frames = “         + browser.Frames + “\n”
+ “Supports Tables = “         + browser.Tables + “\n”
+ “Supports Cookies = “        + browser.Cookies + “\n”
+ “Supports VBScript = “       + browser.VBScript + “\n”
+ “Supports JavaScript = “     +
browser.EcmaScriptVersion.ToString() + “\n”
+ “Supports Java Applets = “   + browser.JavaApplets + “\n”
+ “Supports ActiveX Controls = ” + browser.ActiveXControls
+ “\n”;
txtBrowserInfo.Text = s;
}

I have placed one button on the aspx page and named it as Browser Information. The id of the button is btnBrowserInfo. On the click event of the button, I wrote the above code.

I also placed a TextBox on the page and named it as txtBrowserInfo.

First I initialized an HttpBrowserCapability object named browser with the Request object’s browser property. I fetched the different property of browser and concatenate these into a string variable. Finally I displayed the concatenated string into the text box.

kick it on DotNetKicks.com

September 27, 2008

My First ASP.Net MVC Appliacation

Filed under: .Net, Programming, Technology, Web Technology — yaneshtyagi @ 4:50 pm
Tags: ,

I was thinking about MVC since I read first post on ScottGu’s blog. Yesterday, on Friday night, I decided to create my first MVC applications. I downloaded Visual Web Developer 2008 Express Edition 2008 last night. That 128 MB download took quite a long time to download. Then I downloaded MVC preview 5. After successful installation of MVC, I was ready to fly…

Finding a suitable example on the web:
Before starting develop a new MVC project,  I needed a good example. After searching the web for a while, I found two links that seems to be useful.

First was a 4 part tutorial written by ScottGu. I was a detailed introduction to MVC framework and how it works. I was like a step by step DIY guide. Scott demonstrated how to create a complete e-commerce site using MVC framework.

The second choice was a simple To Do List application. This application allowed one to enter a list of tasks, save these into database and mark them complete. Both applications used LINQ to SQL for accessing database.

I decided to go with the Task List application as this was simple and small application. This app is like the typical Hello World example with database support. I took only one hour to complete this app and run it properly.

Starting the new project
I opened VWD (Visual Web Developer0 and choose to create new project. MVC applications are developed as web applications. They are different from web sites. In the New Project dialog, I chose ASP.NET MVC Web Application. This automatically created a sample application in the solution explorer with three special meaning folders – Controller, Model and View. I deleted the classes and pages auto-generated by the WVD. The I proceed step by step as instructed in the example application.

Step By Step Progress Through Solving Issues:
Once I completed typing (yes, I preferred to type instead of copy-pasting it) the code and creating all the classes and pages, I was time to see the code in action. But as you know, no code runs for the very first time. Although VWD (and VS as well) minimizes the  chances of syntax errors to zero, many other types of error always occurs in the code. I face following problems for which I again need to do some Googling.

The ViewData Problem:

“The name ‘ViewData’ does not exist in the current context”

Even before compiling the code, my Index.aspx view warned me that ViewData is undefined by placing a red line below this. After some unsuccessful silly adjustment to the code, I go for Googling. I found a post in ASP.net forums asking for the same question. ScottGu answered the post by saying – “Have you tried compiling the project?  It could be that you haven’t done a compile since you added the page, and so intellisense with C# hasn’t picked up that you are deriving from a base-class yet”. This was very strange for me but I decided to go with Scott and compiled the code successfully. But when I run the code, the same problem reappeared.

After 20 minutes of unsuccessful Googling, I decided to use trial-and-error method. And finally I got the solution.

Solution:
The root cause of the problem was that I added a Web Form in my Views folder instead of MVC View Content Page. The normal web form is inherited from System.Web.UI.Page class  while an MVC View Content Page is inherited from System.Web.Mvc.ViewPage class. I change the parent class to ViewPage and it worked fine.

Primary key error in inserting the record:
Now I rum my application without any error. The Index page that displays a list of all tasks appears on the browser. I opened create page to add a new task. On pressing submit button, it gave primary key related error. The error was cause by the InserOnSubmit method of the LINQ generated class. The error was quite obvious that I forgot to define primary key on the table. I had an Id column with its Identity attribute set to on. So, ideally any insert statement should not have issue with the primary key. But to fix the error, I modified the table structure and declare Id column as primary key. But the problem still persisted. Like the above issue, Googling was unsuccessful in this case as well and I had to go for trial-and-error method.

Solution:
The solution was quite simple. I had to open the dbml file which is used for LINQ-to-SQL. I deleted the table from this file and again dragged that table into dbml designer from Server Explorer. Pressed F5 and the page was opened successfully in the browser. Opened the create page, added a task and pressed submit button. No error…
I checked into database table and the record was successfully inserted.

So this was the experience of developing first MVC application. The overall experience was good and exciting. I liked the simple and easy-to-read URLs that were displayed in the browser’s address bar.

Keep watching for more in ASP.Net MVC

Technorati Tags: ,

kick it on DotNetKicks.com

Scott Guthrie’s ASP.net MVC Tutorial Links

Filed under: .Net, Programming, Technology, Web Technology — yaneshtyagi @ 12:13 pm
Tags: ,

ASP.NET MVC Framework
One of the things that many people have asked for over the years with ASP.NET is built-in support for developing web applications using a model-view-controller (MVC) based architecture. Last weekend at the Alt.NET conference in Austin I gave the first…

ASP.NET MVC Framework (Part 1)
Two weeks ago I blogged about a new MVC (Model View Controller) framework for ASP.NET that we are going to be supporting as an optional feature soon. It provides a structured model that enforces a clear separation of concerns within applications, and…

ASP.NET MVC Framework (Part 2): URL Routing
Last month I blogged the first in a series of posts I’m going to write that cover the new ASP.NET MVC Framework we are working on.  The first post in this series built a simple e-commerce product listing/browsing scenario.  It covered the high…

ASP.NET MVC Framework (Part 3): Passing ViewData from Controllers to Views
The last few weeks I have been working on a series of blog posts that cover the new ASP.NET MVC Framework we are working on.  The ASP.NET MVC Framework is an optional approach you can use to structure your ASP.NET web applications to have a clear…

ASP.NET MVC Framework (Part 4): Handling Form Edit and Post Scenarios
The last few weeks I have been working on a series of blog posts that cover the new ASP.NET MVC Framework we are working on.  The ASP.NET MVC Framework is an optional approach you can use to structure your ASP.NET web applications to have a clear…

ASP.NET MVC Preview 5 and Form Posting Scenarios
This past Thursday the ASP.NET MVC feature team published a new “Preview 5″ release of the ASP.NET MVC framework.  You can download the new release here .  This “Preview 5″ release works with both .NET 3.5 and the recently…

Technorati Tags: ,

kick it on DotNetKicks.com

September 23, 2008

Project Rosetta

Filed under: .Net, Programming, Technology, Web Technology — yaneshtyagi @ 7:15 pm
Tags:

ASP.net programmers, are you ready for the Silverlight? Still wondering what Silverlight is?

Silverlight is the Microsoft’s answer to the Adobe’s Flesh. And considering the Microsoft’s marketing strategy and market share, I can bet this is going to be the next big thing in the Web 2.0 age.

So does that mean learning a new technology? The answer is – Yes. As an asp.net programmer you have to learn this Silver Light thing. Soon those static (including DHTML) websites will be history. This is the RIA age. RIA – Rich Internet Application – are getting more and more popular following Moory’s law.

But here is a good news from Microsoft. Microsoft has started a new project that will help one to learn this Silverlight stuff.  Below is the excerp from today’s MSDN Flash:

Project Rosetta
Still wondering what all the buzz around Silverlight is about? Check out Project Rosetta, a site dedicated to helping designers and developers build applications in Silverlight while taking advantage of skills they already know from their experience with Flash programming.

So if you know flash (or don’t. doesn’t matter), it is really easy to learn silverlight. But as with any other design skills, learning and being creative are two different things.

So get your hands started on Silverlight ASAP and get experienced before it’s too late.

Related Links:

August 10, 2008

VB.net to c# converter

Filed under: .Net, Programming, Technology — yaneshtyagi @ 9:58 am
Tags: , ,

Many times we need to convert VB.net code to c#. There are many utilities to do this. but none of these is perfect as these have one or other shortcomings. Most of these utilities are the windows apps written in c# language. The draw back of windows app is that you need to upgrade the app at times.

I was looking for an online app for the conversion. And after some googling I found a cool online tool from the Developer Fusion Lab. This conversion tool is quite accurate in conversion and if it could not convert any code then it inserts the error message into the code. So one can easily identify the error message and do the manual conversion.

Link:
Convert VB.NET to C# – A free code conversion tool from Developer Fusion

June 3, 2008

True / False in classic VB

Filed under: Programming, Technology — yaneshtyagi @ 10:03 am
Tags: ,

In classic VB (and classic ASP as well), zero is considered as false and any other non-zero integer is considered as true.

While debugging an asp page, I come across following line:

If Not Request.Form.Count Then

Now form count was 2 (true) so the condition should evaluate as false (Not true). But this was always evaluating as true. It took me half an hour to find the catch.

What actually happening here was that Not is a bit-wise operator in VB. It flips the bits. So,

2 is 0000 0010 in binary.
NOT 2 is 1111 1101 in binary.

Considering that the last bit is sign bit, this becomes -3.

Now our condition If NOT (2) becomes If (-3), which always evaluates to true (non-zero integers are always true in VB).

Technorati Tags: ,,,

May 26, 2008

Automatic Formatting of Markup (HTML) in ASP.NET

Daniel at dimebrain did a really fantastic work writing a plug-in for VS that can format the markup in asp.net. When you build a web page using the VS designer, it auto generates the markup. But the auto generated code so clustered and impossibly hard to read.  You have to manually format the markup (HTML) code by hand. This is always very tiresome and boring job. Also this is wastage of time.

Daniel also felt the same. After being inspired by the Joe Stagner, he developed this plug-in. It provides an additional Edit menu item and hotkey (Ctrl+K, Ctrl+Z) to automatically line up attributes in a selection of text, or format the entire document if no text is selected. The meat of the add-in is a handful of regular expressions that parse tags (XAML, HTML, and ASP.NET directives) and a few IDE tools to line them up according to their indent level.

Download Links:

Screen Shots:

April 3, 2008

Top 20 Programming Books

Filed under: Books, Programming, Technology, Uncategorized — yaneshtyagi @ 4:09 pm
Tags:

1. Code Complete by Steve McConnell – Darn near a bible of software development goodness, Code Complete reminds us of our priorities. It’s essential and everyone who writes code should read this book.

2. The Pragmatic Programmer by  Andrew Hunt and Dave Thomas – I like to read this book at least every six months or so. It’s clean, clever, clear and full of concrete tips you can use to be a better, simpler, pragmatic programmer. A new classic.

3. Programming Pearls by Jon Bentley – This may feel initially like a C book, but it’s really an algorithms book at its heart. It’s old school with techniques and thought problems that can be applied today, even in language like Ruby and C#.

4. Refactoring: Improving the Design of Existing Code -by Fowler, Beck, Brant, Opdyke, Roberts Although the language used is Java, the concepts are universal. This is a very linear, easy to read, learn by example book. If you think you know how to refactor, but you haven’t read this book, pick it up and refresh yourself. You’ll find names for Refactorings you’ve used for years and you’ll definitely not only pick up new ones, but be better able to spot opportunities to use them.

5. Design of the UNIX Operating System by Maurice J. Bach So few programmers today can answer questions like “explain how virtual memory is managed” or “how are Unix processes different from Windows.” How did we get here. Know your history.

6. Design Patterns by Gamma, Helm, Johnson, Vlissides – One of the comments on Amazon says it best, “It is expected that any professional developer has read this book front-to-back. Buy it, read it, then put it in your bathroom and read it when convenient. Also, when you’re done, spend some time at the Portland Pattern Repository.

7. Working Effectively with Legacy Code by Michael Feathers – The book is highly entertaining and comes across as a conversation with a really sharp, really patient guru developer. Often, it’s a chore to slog through code-heavy books. But Feathers manages to keep my attention with interesting stories, loads of examples, and well-written text.

8 .The Cuckoo’s Egg by Cliff stoll – A sentimental favorite, The Cuckoo’s Egg seems to have inspired a whole category of books exploring the quest to capture computer criminals. Still, even several years after its initial publication and after much imitation, the book remains a good read with an engaging story line and a critical outlook, as Clifford Stoll becomes, almost unwillingly, a one-man security force trying to track down faceless criminals who’ve invaded the university computer lab he stewards. What first appears as a 75-cent accounting error in a computer log is eventually revealed to be a ring of industrial espionage, primarily thanks to Stoll’s persistence and intellectual tenacity. –This text refers to an out of print or unavailable edition of this title.

9. Head First Design Patterns by Elisabeth Freeman, Eric Freeman, Bert Bates, Kathy Sierra – I just started reading it yesterday and it is a really well written (lots of pictures and examples) and is put in terms even I understand. Even so early on I would recommend it to anyone wanting an introduction into design patterns.You may not want to include it is all the examples are in Java although if you know c# you should understand it and even the VB / C++ shouldn’t have to jump to far.

10. From Coder to Developer: Tools and Strategies for Delivering Your Software by Gunderloy and Sybex – started very interesting. For someone new to the business it gives a nice overview of what the whole software development process entails and made things a lot clearly for a new graduate like me.

11. Code Reading by Spinellis – is a good read for learning how to quickly and efficiently get to grips with an existing codebase. I’m fortunate enough to have worked on greenfield stuff my last couple of projects, but this is gold when starting at a new company and needing to get up to speed. Also great if you’re looking to join an open source project. (http://www.spinellis.gr/codereading/).

12. Writing Secure Code 2 by Michael Howard – This book provides a great overview of what techniques are important when writing secure applications, and what pitfalls to avoid. The book does a good job at making a point through examples and by explaining possible exploits.

13. The Mythical Man Month by  Brooks – This is a touchstone book, where by merely mentioning the name, you instantly communicate a body of knowledge on software engineering insight. It’s full of truths about Software Engineering that are still relevant. 30 years later.

14. Patterns of Enterprise Application Architecture by Martin Fowler – Noted software engineering expert, Martin Fowler, turns his attention to enterprise application development. He helps professionals understand the complex–yet critical–aspects of architecture. Enables the reader to make proper choices when faced with a difficult design decision.

15. TCP/IP Illustrated Volume 1 by  W. Tichard Stevens – Even though this book was published in 1994, it still serves as a useful reference and learning tool for the TCP/IP protocol. There are of course changes and additions that have been made to TCP/IP over the last 7 years such as IPv6, but one can still refer to this book as a good source of information about the dynamics of TCP/IP. There are exercises at the end of each chapter, so it can, and has been used as an effective textbook.

16. Don’t Make Me Think: A Common Sense Approach to Web Usability, 2nd Edition by Steve Krug – A practical Web design usability guide, “Don’t Make Me Think!” is based on empirical observation not exhaustive statistics. Steve Krug’s five years of usability consulting and testing are distilled down to this thin yet gem-filled how-to. Krug observed how people actually use the Web rather than how we *think* they use it, gleaning key usability guidelines.

17. The Inmates are Running the Asylum: Why High Tech Products Drive Us Crazy and How to Restore the Sanity by Alan Cooper – It’s worth reading this book — even despite the painful tone he often takes — just to pick up on the ideas of creating concrete personas and how you use them to develop your product. We do that today at Microsoft (at least in Developer Tools), and it’s a highly successful way of not only building a good product, but also in helping hundreds of developers understand why a feature is ‘in’ or ‘out’, no matter how much they might like it personally.

18. Mastering Reguler Expressions by Jeffrey E. F. Friedl – Regular expressions, a powerful tool for manipulating text and data, are found in scripting languages, editors, programming environments, and specialized tools. In this book, author Jeffrey Friedl leads you through the steps of crafting a regular expression that gets the job done. He examines a variety of tools and uses them in an extensive array of examples, with a major focus on Perl.

19. Test Driven Development by Kent Beck – The book teaches the concepts of TDD by working through two complete sample projects. Along the way, Beck gives the reader valuable insight into the thought process and techniques behind successful test-driven development. When the reader has finished working through these sample projects, he should know enough about TDD to get started working on a TDD project.

20. Head Rush Ajax by Brett McLaughlin – The Head First Labs crew has done it again in this excellent into to Ajax. The book really gives a great overview of Ajax for both programmers and non-programmers alike. You don’t need to be a rocket scientist to pick this up. Although the book covers more PHP than I care for, and not enough of XML as I would like to see, it does an excellent job of covering their bases in a way that’s easy to understand. I highly recommend this book to anyone with little to no understanding of Ajax. Let’s pretty up the web, people!

February 18, 2008

Unicode Tool tip

Filed under: .Net, Programming, Web Technology — yaneshtyagi @ 1:39 pm
Tags: ,

While using windows XP, I was facing a problem. I was working on a multilingual web site. we were showing tool tips to help user to understand what a particular button will do or where a link points. The tool tips were working fine for language which uses English language characters. But in case of other characters (read unicode) such as Chinese or Arabic, it showed small boxes instead of letters.

I had to do lot of research on the internet (googling is my first habit) and here is what I found:

To set your tooltip font to be able to display Unicode characters:
Right click on the desktop, pick Properties -> Appearance -> Advanced ->Item: ToolTip, then set the font to Arial Unicode MS or other large font.

This will show unicode characters in the tool tip.

Next Page »

Blog at WordPress.com.