Sunday, October 19, 2008

Mono 2.0: .NET goes non-Windows

Justin James wanted to learn what is new in Mono 2.0, so he interviewed Miguel de Icaza, VP of Development Platforms and a founder of Mono, and Joseph Hill, Product Manager at Novell. Find out what is and is not included in the latest release.

——————————————————————————————————————-

For some time now, the Novell-sponsored Mono Project has brought .NET to non-Microsoft platforms. Unfortunately, Mono has been quite far behind the .NET Framework and CLR. This all changes with the release of Mono 2.0.

Three days before the October 6, 2008 release of Mono 2.0, I had the chance to speak with Miguel de Icaza, VP of Development Platforms and a founder of Mono, and Joseph Hill, Product Manager at Novell.

Mono 2.0 is API complete in regards to .NET 2.0; this means that Windows Forms applications and ASP.NET applications will both work within it. Additionally, many of the new features in .NET 3.5, including C# 3.0 and .NET Language-Integrated Query (LINQ), are included. Miguel told me that implementing C# 3.0 was both fun and challenging and that getting the lexical closures right was “probably one of the hardest parts to implement” (which is not surprising at all). However, the big frameworks from .NET 3.0, such as Windows Presentation Foundation (WPF) and Windows Communication Foundation (WCF), are not included. There is an implementation of the Parallel Extensions Library. Because Microsoft’s currently in CTP, Novell is not shipping its version with Mono 2.0, although it is available for download. And because Microsoft open sourced the DLR, IronPython and IronRuby will both work under Mono.

In terms of using code in Mono, no recompile is needed, although there is a C# compiler included. Because compiled .NET assemblies are in Microsoft Intermediate Language (MSIL), Mono acts as an MSIL interpreter like the .NET CLR. For Web applications, the Mono Project has produced both an Apache plug-in and a FastCGI binding to allow it to hook into your Web/application server. Mono works on a huge number of platforms, including Linux, Solaris (including SPARC platforms), Mac OS X, Windows, the Nintendo Wii (yes, you read that right), and BSD. In the case of BSD, you will need third-party patches to make it work; for all other platforms, Mono will work right out of the box and be running your .NET code. A recent version of Linux is needed (about three - four years old at most), since it uses some newer kernel features. On the Mac OS X platform, it includes Cocoa# for building native OS X applications in .NET. They also offer a pre-made VMware virtual machine with SuSE Linux and Mono installed for free.

They have also included a Mono migration analysis tool that will let you know if you are making calls that will work differently under Mono. Some .NET calls that access the Windows API mechanisms or low-level system calls will still work just fine, but the developer needs to keep in mind that the support is emulated or imitation — it’s not actually accessing the underlying mechanism. For example, accessing the registry is possible, but Mono creates a file-backed emulation of the registry and can only provide data that your application has stored in it to begin with. Something like trying to enumerate the NICs in the PC from the registry data will fail because those keys simply do not exist. You can also send the tool’s output to Novell to get feedback on it.

From these reports, Miguel guesstimated that 45% of applications work with zero lines of code that need to be changed. About 17% have 1 - 20 statements that need to be changed (this is typically about a week’s worth of effort). Another 20% have 20 - 100 calls to be changed (this is usually around two - four months’ worth of work). The remainders of the applications they see require too many changes to make it practical to put them on Mono. Miguel says that the performance is about 80% of that of the .NET CLR on average. Some statements run faster, some run slower. He also mentioned that Web applications often run faster in Mono than they do under the .NET CLR, because much of Mono’s slowdowns occur in the GUI portion of the system.

For developers who want an alternative to Microsoft Visual Studio, there is Mono Develop. A new version of Mono Develop is slated for release in January 2009; it will deliver improved usability and an enlarged feature set, including support for Visual Studio file formats. This will allow developers on the same team to use both Mono Develop and Visual Studio, with no conversions between the two needed.

Overall, Mono 2.0 sounds really good. In the near future, I will try it out and let you know what I think.

J.Ja

Two approaches to redirection in ASP.NET

ASP.NET provides a few ways to move to different pages. Here’s a look at these options.

—————————————————————————————————————-

Directing a user to another page or resource is a common aspect of a Web application. The user may initiate the transfer to another page any number of ways, including clicking a button or link or selecting a value in a drop-down list. ASP.NET provides a few ways to move to different pages. Here’s a look at these options, along with commentary on when you should use which approach.

Client vs. server

A key aspect of the various ways to send a user to another page within an ASP.NET application is where the transfer occurs; that is, it is handled within the client browser or on the Web server. The following list outlines two options for controlling page navigation.

  • Response.Redirect: The Redirect method of the Response object provides a way to implement client-side redirection.
  • Server.Transfer: The Transfer method of the Server object performs redirection using the server and avoiding HTTP requests.

Let’s take a closer look at each approach.

Response.Redirect
The default behavior of the Response.Redirect method is execution of the current page halts, and the user is sent to the new URL. The Web server issues HTTP headers and sends a 302 response to the client browser; this instructs the client to make redirected calls to the target URL. The result is two server requests for each redirection: the original and redirected requests. The following C# snippet shows it in action:

Response.Redirect("http://www.news.com");

Now, the Redirect method has two signatures with the second format accepting another Boolean parameter that signals whether execution of the current page should terminate (the default behavior). We could tell the system to continue execution of the current page while redirecting the user to the News.com site with the following snippet:

Response.Redirect("http://www.news.com", false);

Server.Transfer
The Server.Transfer method transfers the execution of a target URL to the server and halts execution of the current page. The result is only one request (as opposed to the two involved with the Response.Redirect method) since the server does not notify the client browser of the change. The experience can be a little disconcerting for users since the page address does not change in the browser. This C# snippet shows how you may use this method.

Server.Transfer("/default.aspx");

When using Server.Transfer, the target URL must be a virtual path on the same server since the Web server’s worker process is used, so you can’t use an address containing “http” or “https.” It has three signatures, with a second variation allowing you to transfer control to an IHttpHandler and the third adding a second parameter to the first version; whereas, the second value is a Boolean signaling whether the current form’s querystring and Form collections are preserved.

The PreviousPage property of the Page class provides code access to properties of the previous page in the browsing session, so Form and querystring variables are persisted between pages whereas they are not when using Response.Redirect.

Server.Execute

The Server.Execute method is a bit antiquated, as there are other ways to accomplish the task, but it basically allows you to execute a resource request without leaving the current page. It is not really used for redirection, but it is mentioned here only to avoid any confusion with the Server.Transfer method.

Server.Execute has five signatures, but the basic version accepts a path to a resource as the following snippet displays:

Server.Execute(ResourcePath);

Pros and cons of each approach

Redirecting a user to another Web resource is feasible in ASP.NET using one of the techniques discussed. However, you may be wondering why you would choose one approach over the other. The following list covers some of the advantages or disadvantages of Server.Transfer and Response.Redirect.

  • AJAX usage: The lack of browser interaction with the Server.Transfer method means it may break some AJAX and/or JavaScript functionality.
  • Bookmarking: Since Server.Transfer does its work on the server, the address within the client browser is not updated. The user sees the previous page’s address while viewing a new page. Consequently, the user is unable to bookmark certain pages.
  • Page refreshes: There is an issue when a true value is used with the second parameter of the Server.Transfer method. When users refresh a page located via this approach, it can trigger an invalid ViewState error message. This can be alleviated by disabling the enableViewStateMac property on a page, but this isn’t the best approach to security.
  • Performance: Response.Redirect introduces an extra call while making the roundtrip between client and server; since there is only one call with Server.Transfer, it offers better performance.
  • Scalability: The extra roundtrips associated with using Response.Redirect are often stated as a drawback with using it. However, I have seen it used in large applications without experiencing any performance issues.
  • Errors: While Server.Transfer can cause some user confusion as the URL displayed in the browser address bar, it can also lead to some confusion with error logging, as the page URL recorded during logging will display incorrectly.
  • Basic security: An interesting twist with using Server.Transfer is the ability to send data to another page without the user seeing it. This is enabled via the use of the QueryString, which is appended to the end of the target address. This new address will not show in the browser address bar with Server.Transfer, so it offers a simple layer of security. Of course, the Response.Redirect approach makes the QueryString visible to the user.

Usage depends on the situation

ASP.NET offers plenty of options when tackling a development task. The Response.Redirect and Server.Transfer methods provide two ways to redirect users to new URLs. Each method offers its own set of positive attributes, so deciding which one to use is really up to the developer’s preference.

10 ways to survive office politics

Office politics will never go away. It’s a fact of company life. However, destructive office politics can demoralize an organization, hamper productivity, and increase turnover. Here are some tips, applicable for both staff and management, on dealing with office politics.

Note: This information is also available as a PDF download.

#1: Live at peace with others

The easiest way to avoid problems with politics is to get along with people. I’m not saying you need to hug everyone and sing songs, and I’m not saying you have to be a pushover for everyone. You can be pleasant and professional, while at the same time being assertive when necessary. If you have a concern, focus only on the issue, not on the person. If you have to refuse a request, explain why and try to come up with alternative solutions.

Living at peace with others also means being careful about choosing sides during office power struggles. Aligning yourself with one faction or the other will prevent you from working effectively with people from the “other” side, thereby hampering your productivity and thus your performance. It’s even worse if “your” faction loses out. Instead, try to focus on your tasks, dealing with people in either faction on the basis of the tasks alone, and avoid talk on the political issue that separates the groups.

#2: Don’t talk out of school

Three can keep a secret if two of them are dead.
– Benjamin Franklin

Does your organization have issues? Have people told you things in confidence? Then keep those matters to yourself. Talking to outsiders about issues within your organization makes all of you look bad to that outsider. Furthermore, your boss or your boss’s boss will not appreciate that behavior. People will find out that you spoke about what they told you, and they’ll lose confidence in you and respect for you.

#3: Be helpful

We all have responsibilities and objectives, and those things should receive priority. Nonetheless, if it doesn’t take too much time, being helpful to others can reap benefits for you. Does someone need a ride in the direction you live? Did your co-worker leave headlights on in the parking lot? Is someone having trouble building an Excel macro? If you can help that person, especially if you can do so without taking too much of your time, you benefit yourself as well as the other person. By doing these things, you’re building political capital and loyalty. In doing so, you reduce the chances that you will be the victim of political intrigue.

#4: Stay away from gossip

I never repeat gossip, so listen carefully.
— Old joke

Nothing destroys the dynamics of an office more than gossip. Stay away from it, because nothing good comes from it. Just be sure you avoid the “holier than thou” attitude of lecturing your co-workers on the evils of gossip. You’ll make them lose face, and they’ll resent you. Instead, try subtly changing the subject. For example, suppose the group is talking about Jane’s problems with her child, and of course Jane is absent from the group. Do some free association and try to come up with some topic that’s related to Jane or her child, but won’t involve gossip. Then, make a comment about that topic.

For instance, suppose you know that Jane’s child is involved in a sports league. Mention this fact, thereby linking the child and the league. Then, shift the conversation so that you’re now talking about the league rather than Jane’s child. You could ask when schedules will be published, or if they need parent volunteers. If you do it right, no one will even notice that you’ve moved them away from the gossip.

#5: Stay out of those talk-down-the-boss sessions

Suppose your co-workers start complaining about the boss. If you join in, it makes you look disloyal to the boss. If you don’t, it looks awkward in the group. What can you do? As with the situation of gossip, try changing the subject by linking the boss to another topic, then talking about that topic instead. Or you could simply respond to your co-workers with a smile and a tongue-in-cheek, “Come on, aren’t we exaggerating? [name of boss] really isn’t THAT bad.” Be careful, though, because it could be taken as an admission by you that the boss is bad.

#6: Be a straight arrow

The best way to keep out of trouble politically is to be seen as someone who doesn’t play office politics — in other words, a straight arrow. Do what you say you’re going to do, alert people to problems, and admit your mistakes. Others will respect you, even if they don’t always agree with you. More important, you have a lower chance of being a victim of politics.

#7: Address the “politics” issue openly when appropriate

Many times, when I do organizational assessments, I sense anxiety on the part of client staff. To address this anxiety, I tell people I interview that I’m not there to get people fired. I’m there to help the organization function better. It might not completely allay their fears and suspicions, but at least I’ve brought up the issue and addressed it.

Think about doing the same thing if you believe politics is an underlying theme at your company. Tell people you’re not interested in scoring political points but only in getting the job done. It might not work, but unless you bring the matter up, there’s no chance at all that they will believe you. So if a co-worker is unavailable, and you have to act on that person’s behalf, consider saying to that person, “I had to act because of your absence. I wasn’t trying to go behind your back and I wasn’t trying to show you up.”

#8: Document things

Nothing saves a job or career more than having a written record. If you believe a matter will come back to haunt you, make sure you keep a record of the matter, either via e-mail or document. Documentation is also an effective way to highlight of your own accomplishments, which can help you when your performance evaluation is conducted.

#9: Set incentives to foster teamwork

If you’re a manager or senior executive, take a close look at your incentives. Are you unwittingly setting up your staff to work against each other? Do your metrics address only individual departments, or do they also address how departments could benefit the larger organization?

For example, suppose the hardware department of Sears reduced all its prices by half. If you measured only profitability of the department, you would conclude that it is performing horribly. However, that measurement would neglect to account for increased volume in all other departments because of the hardware department.

If you reward employees in a department based only on how well that department does, you may inadvertently cause destructive competition among departments. Each one will be competing against every other one, and all the departments could end up in a worse position. To minimize this possibility, give employees incentives based not only on department results but on organization results as well. That way, employees from different departments have more motivation to work together and less motivation to engage in destructive politics.

#10: Set an example for your staff

People in an organization look to leadership to see how to act. Do you want your staff to refrain from negative politics? Do you want to see collaboration and teamwork instead of petty rivalries, jealousy, and back-stabbing? Act the way you want your staff to act, and they will follow you.

10 mistakes to avoid when seeking a new job

Searching for a job requires you to do a lot of things the right way, avoiding missteps that can doom your efforts despite your strong qualifications and experience. Here are a few simple things to watch out for when your job-hunting campaign is underway.

Note: This information is also available as a PDF download.

#1: Relying on human resources office

You’ve heard it before, certainly, but the advice still remains valid: Don’t send your resume to human resources, or the hiring department, or the hiring manager. In most cases, these departments serve only screen people out. You’re much better off finding the name of a specific person, namely your prospective boss. If that person likes your qualifications, he or she might be able to push you through the human resources bureaucracy. Is it possible that that person may simply forward or refer you to human resources? Sure. But you’ve lost nothing in the attempt.

For details on finding and contacting people within a prospective company, see “Breaking through the wall.”

#2: Using an unprofessional e-mail address

You and your friends might think cutiepie@aol.com or drinkstoomuch@gmail.com are funny or clever addresses. Think, however, how a hiring manager might view them. That person might lack your sense of humor, and his or her reaction might hurt your chances. You’re better off with simply your name plus, if necessary, a numerical suffix.

#3: Having an unprofessional telephone greeting

The same logic applies to your voicemail greeting. All you need say is that you’re unavailable — not that you’re out clubbing or playing Wii. Why give a potential hiring manager a reason to pass you by?

#4: Overlooking misspellings in your cover letter

Back in college, a classmate of mine told me that he was applying for a job with what was then known as Morgan Guaranty. The trouble was, throughout the entire cover letter, he referred to them as “Morgan Guarantee.” Not surprisingly, he didn’t get the job.

Misspellings are never good, but they hurt you the worst if they involve the name of the company or the names of people. Check them out thoroughly before sending a letter. Names can be spelled in different ways, e.g. “Anne/Ann,” “Michelle/Michele,” “Scott/Scot.” Furthermore, as companies merge or become acquired, their names often change accordingly. If in doubt, check the company Web site or simply call the receptionist and explain that you want to confirm a spelling.

Remember that while Word has a spell-checker, it doesn’t have a “what you meant to write-checker.” If you wrote “they’re chances” or “there chances” when you meant to say “their chances,” Word won’t flag your phrase (at least it didn’t for me just now). Make sure of your sentences even if Word says the spelling is okay.

#5: Failing to write a post-interview thank you letter

Contrary to what others may say, writing such a note is not signaling desperation on your part, nor does it constitute groveling. When you travel to a company to interview, you are a guest. The person who invited you had to do many things to prepare, such as reserving a conference room and coordinating peoples’ schedules. Your note shows your appreciation for those efforts and gives you an additional chance to reinforce your strong points. Failing to write a note deprives you of that chance and may mark you as being unprofessional.

#6: Dressing inappropriately for the interview

If you’re interviewing at a bank, dress like a bank person. Forget the t-shirt, shorts, and sandals. Forget the too-high or too-tight skirts and too-low blouses. They’re out of place and will hurt your chances. When in doubt, dress more conservatively. Even better, research how people dress and do likewise.

#7: Omitting accomplishments from your resume

Don’t just list responsibilities on your resume. Talk about your accomplishments, and if you can, quantify them. For example, don’t just say, “Wrote programs in [name of language].” Instead, say “Developed system that reduced order entry processing time by x%.”

#8: Arriving late for an interview without letting someone know

If you’re running way behind, call or text ahead to let the interviewer know you’ll be late. Sure, it’s better to be on time. But if you can’t be, at least the people you’re meeting with can continue with other work while waiting for you. The worst alternative of all is to simply show up late. It smacks of rudeness and unprofessionalism and may hurt your chances.

#9: Bad-mouthing a former employer

Much as you might be tempted, and even if the interviewer asks you, avoid bad-mouthing your former company, co-workers, or boss. All you need say is that while you learned a great deal (a true statement, even if your boss and co-workers were horrible), you felt a need to move on and gain more challenge. Bad-mouthing the old company may mark you as a troublemaker by your prospective employer.

#10: Failing to leverage existing contacts

If you’re looking for a job, you don’t have to do it alone. Think of other people who can help, such as former co-workers, vendors, and especially fellow alumni from high school or college. If you fail to do so, you simply make your own search more difficult and frustrating.

This point illustrates the old saying that “One hand washes the other.” Before you need to leverage your existing contacts, think about how you can help others in their own job searches. When you do, you will feel tremendous satisfaction at having done good for someone. And you’ll make it more likely that those persons will later help you in the same way.

ITWORLD
If you have any question then you put your question as comments.

Put your suggestions as comments