Monday, September 22, 2008

Using Binary Search To Debug Compiler Crashes

Have you ever faced a compiler crash experience before?! Do you have any idea about how to recover form this situation??

I've already passed with such an experience :D, and while I was searching for some help on the internet, I found this cool article. It's really great one, I liked the idea of using Binary Search in tracing the program to find out the error. I think it is a good way to trace any kind of program apart way from crashing ;)

Here's the article, enjoy!

Monday, September 15, 2008

How To Motivate Your Team

Motivation, motivation, and motivation!! Personally speaking, it's the biggest and heaviest load on leaders. Motivating people is not an easy job, and when a team works without any kind of motivations it becomes like machines!! Rusty machines !!!

I've been working in a charity organization and many volunteering communities since 2006. That let me live great experiences with too many leaders. Some of them ware amazing, others ware just carrying the title, but having nothing to do with its responsibilities!!! Also, those days I've been on charge of a great team (my graduations project team :D ), so I became more interesting in leadership in addition to my old admiration to management.

So, I found this great article titled with "
10 things you can do to motivate your team", and I liked it a lot. It sums up the most important things leaders should do to motivate their teams. So, please, enjoy :)

To get things done these days, working in teams is almost imperative. But how can you, as a leader, motivate a team to accomplish your objectives? How can you avoid common mistakes that can kill performance and morale?

Believe in your team's objectives

Do you believe in what you want the team to accomplish? Do you think your goals are realistic? If not, rethink your position, because your team will sense your uncertainty. You may say the right words, but your body language and overall demeanor will give you away. On the other hand, if you truly are dedicated and believe in your goals, your team will sense it and will react accordingly.

Model the behavior you want from the team

Don't be a hypocrite -- lead by example. You want your team to interact courteously and professionally with others, but do you do so yourself? If you ask them to put in extra hours, are you there along with them?

Keep a positive attitude
If you model a negative attitude, your team will pick it up. I know it sounds trite, but try to stay upbeat. Doing so doesn't mean being unrealistic. It does mean, however, that you try to look at the glass as being half full rather than half empty.
Instead of saying, for example, "This project will never succeed because of issues 1, 2, and 3," consider saying, "If we want this project to succeed, it's critical that we resolve issues 1, 2, and 3."

Be clear about your goals

It's hard for your team to accomplish its goals if those goals are unclear or unknown to them. More important, it's hard to get them even to agree with those goals if they don't know what they are. Make sure your team knows what you are expecting of them. If you can quantify your goals so that you can measure how well you did compared to what you expected, so much the better.

Get feedback from the team members

Unless you hear from your team members, you may have little or no idea of how effective or clear you are. Few of us enjoy hearing bad news or criticism, but if there's a problem in what we're doing, it's important that we hear it.
When discussing issues with the team, don't shoot the messenger. When listening to a team member, try to separate the message and issue from the person. Similarly, when someone is offering suggestions or discussing issues, try to separate your own self and ego from the discussion. If you do shoot the messenger, all you will have done is make your team even more reluctant to talk frankly with you in the future.

Set expectations

Make sure your team knows what to expect of you. If they do, there's less chance that they'll be unpleasantly surprised or disappointed. Suppose, from the previous point, you had a discussion with a team member, who made a few suggestions. Some of them are workable (so that you could act on them), but others aren't.
Before having this discussion, it would be good to let your team know that while you will listen to them, you may or may not adopt all of their suggestions. One would hope they'd realize this already, but it's best to be explicit. Furthermore, if you do adopt a suggestion, make sure everyone knows about it.

Avoid mixed messages

To encourage desirable behavior, there must be positive rewards for it. Conversely, to discourage undesirable behavior, there must be consequences that result from it. Believe it or not, some people mix up these two points.
Have you, as a parent, ever said to your child, "Any time you have problem, you can talk to Mommy or Daddy"? What happens when they do? You become irritated and yell at them, "Come back later! Can't you see I'm busy?!" If you send similar mixed messages to your staff, you will make it harder for them to act the way you want.

Know the difference between exhorting and belittling
It's fine and good for you to want greater and higher quality results from your team. However, be aware of the line between exhorting someone to do better and belittling them because they aren't right now. The latter might work, but the chances are greater that it might only create resentment and turn out to be counterproductive.
In other words, in keeping with the positive/negative point discussed earlier, focus on where you wanted them to be, rather than on the fact that they weren't there right now.

Correct in private

If personal issues of a team member are becoming a problem, address them with the person in private. Don't embarrass the person by bringing it up in public. Such issues include attendance and punctuality, dress, and general professionalism.

Praise in public

When someone does something right, you probably are happy and want that person to continue doing it. You also probably want to make that person look good in front of the others, and for the others to be motivated to improve their own performance. For those reasons, recognize good work in public, rather than in private.
However, praise alone still can motivate, as long as you're sincere and specific in what you're praising. Generalities are unhelpful. Rather, focus on the specific action, and how it benefited the group.

It can be rewarding to see a team come together and execute the way you want. It's even more rewarding to see people develop the way you want. However, try to be realistic.

Sunday, September 7, 2008

The .NET Solution Features

The solution proposed by .NET is “Change everything” (sorry, you can’t blame the messenger for the message). The .NET Framework is a completely new model for building systems on the Windows family of operating systems, as well as on numerous non-Microsoft operating systems such as Mac OS X and various Unix/Linux distributions.

To set the stage, here is a quick rundown of some core features provided courtesy of .NET:
Comprehensive interoperability with existing code:
This is (of course) a good thing. Existing COM binaries can commingle (i.e., interop) with newer .NET binaries and vice versa. Also, Platform Invocation Services (PInvoke) allows you to call C-based libraries (including the underlying API of the operating system) from .NET code.

• Complete and total language integration:
.NET supports cross-language inheritance, cross language exception handling, and cross-language debugging of code.

• A common runtime engine shared by all .NET-aware languages:
One aspect of this engine is a well-defined set of types that each .NET-aware language “understands.”

• A comprehensive base class library:
This library provides shelter from the complexities of raw API calls and offers a consistent object model used by all .NET-aware languages.

• No more COM plumbing:
IClassFactory, IUnknown, IDispatch, IDL code, and the evil variant compliant data types (BSTR, SAFEARRAY, and so forth) have no place in a .NET binary.

A truly simplified deployment model:
Under .NET, there is no need to register a binary unit into the system registry. Furthermore, .NET allows multiple versions of the same *.dll to exist in harmony on a single machine.

As you can most likely gather from the previous bullet points, the .NET platform has nothing to
do with COM (beyond the fact that both frameworks originated from Microsoft). In fact, the only
way .NET and COM types can interact with each other is using the interoperability layer.

Apress Pro C Sharp 2008 and the dotNET 3.5 Platform 4th Edition Nov. 2007, Andrew Troelsen

Wednesday, August 20, 2008

The Mono Porject

My first task in my summer training was to know what is Mono Project and how to install it on Linux Ubuntu. Sounds easy, like a bar of chocolate, isn't it?!

I felt so excited to know what is that thing called Mono. So I started searching at once, and where's what I found:
Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. Sponsored by Novell the Mono open source project has an active and enthusiastic contributing community and is positioned to become the leading choice for development of Linux applications.

The Mono Project's objective is to enable UNIX developers to build and deploy cross-platform .NET Applications. The project implements various technologies developed by Microsoft that have now been submitted to the ECMA for standardization.

The only thing .NET (Microsoft original framework) and Mono have in common are the idea. A central cross-platform development framework, and one is based on the other.

Mono allows you to write an application in a list of languages so you can use the language of your choice. You don’t need to learn something new in order to use it. Some of the languages currently supported in Mono are: C#, Visual Basic.NET, Javascript, ASP.NET, and others.

Considering that Mono is supported on Linux, UNIX, OSX, Solaris, BSD and Windows, you can write an application within one and almost instantly port it to the next. Assuming the other platform has the mono common libraries (which are included in Ubuntu and Windows for starters) and your application doesn’t depend on any platform dependent libraries. If this is the case you just wrote an application that can be used on Linux, OSX and Windows without any additional work.
See, as I said, just a bar of chocolate:D.

After about two hours, my CEO came to check my progress, and with a lot of excitement I told him:
- " I found what it is all ... I got it". In returns he said: - "Great! so tell me, which version of Mono works with which version of .NET??" - "Oh .. ah .. well .. I can't remember that I read something about that ... give me couple minute and I'll figure it out :D"

I've to say that it was a little bit embracing :"> ... I know Right-Brained people like me are big picture oriented, and that's why I miss small details :-S

Anyway, till this moment, the latest version of .NET is 3.5, and the latest version of Mono is 1.9. But (also for the current moment) Mono supports .NET 2.0 only!! Some of .NET 3.0 and 3.5 new features are supported, but still most of them under developing.

My references for this post, and for more details, check those links:
- Squashing A Few Myths About Mono
- Mono (Software) from Wikipedia
- Mono Project Website

Thursday, August 14, 2008

How To Configure ASP.NET websites On Ubuntu Localhost

To those who are interested in developing ASP.NET websites on Ubuntu operating system and mono platform, here's the steps to configure your website to the localhost.

1- Install Apache web server on your machine (you may use the Synaptic Package Manager for that).
2- Install Mod-Mono module, the Apache module responsible for serving and rendering ASP.NET pages.
3- Develop your website normally using MonoDevelop IDE.

Now, your application would run normally by the MonoDevelop. But, it still not configured on the localhost. So we need to create a " virtual directory" for the new website to be hosted. Virtual directors are made on 5 main steps. Let's assume that the new website we wanna to add in the local host is named "new_ASP_Solu", and the path of the default.aspx file is "new_ASP_Solu/new_ASP_Solu"

Step 1: Copy your solution in the /var/www directory
  • Write in the terminal the following command line:
$ sudo cp -r Desktop/new_ASP_Solu /var/www
  • sudo => is short for "superuser do", it allows a permitted user to execute a command as the superuser or root user.
  • cp => is short for "copy", it copies only on single file.
  • -r => an option added to some Linux commands to make it execute recursively. That's why we're using it here, to copy the whole directory :D
  • Desktop/new_ASP_Solu => the path of the solution. (It's just an assumption that it exists on the Desktop)
  • /var/www => the distention path, where we're coping the new website.
Step 2: Add a new virtual directory to the "Default"
If you opened the /etc/apache2/sites-available directory, you'd find one single file called "Default". This is where you should add the new virtual directory.
  • Open this file using this command:
$ sudo vi /etc/apache2/sites-available/Default
    • vi => is Linux text editor, use it to edit any file you wish.
  • Append the following code between the two tags <virtualhost> and </virtualhust>
<directory /var/www/new_ASP_Solu/new_ASP_Solu>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
SetHandller mono
DirectoryIndex Deault.aspx index.html
  • /var/www/new_ASP_Solu/new_ASP_Solu => the path of the default.aspx file.
  • SetHandller mono => determines the Apache module that will render this solution pages.
  • DirectoryIndex => it determines the website default (or starting) web page. In this case it's the Default.aspx, and for HTML it'd be the index.html.
Step 3: Create a file named "new_ASP_Solu.webapp"
  • Create a new file in /etc/mono-server2, with the same name of the solution, but the the extension .webapp
$ sudo touch /etc/mono-server2/new_ASP_Solu.webapp
    • touch => command creates an empty file.
  • Open this new empty file
$ sudo vi /etc/mono-server2/new_ASP_Solu.webapp
  • Add this code in it:
  • name => just give a name to your new web site.
  • vpath => the virtual path of your web page on the local host. In this case, if you typed in your web browser "http://localhost/new_ASP_Solu" it will open your solution.
  • path => the local path of your solution on your PC.
  • port => determines the port number to use.
Step 4: Add the new virtual directory in httpd.conf file
  • Open the httpd.conf file
$ sudo vi /etc/apache2/httpd.conf
  • Append the following:
MonoApplications "/new_ASP_Solu:/var/www/new_ASP_Solu/new_ASP_Solu"
<location /new_ASP_Solu>
SetHandler mono

Step 5: Restart Apache
This step is mandatory to run your website correctly.
$ sudo /etc/init.d/apache2 restart

Now, go to your web browser, type "http://localhost/new_ASP_Solu" in the address bar. Yep! It works!! ;) :D.

Monday, August 11, 2008

Error With MySQL Connection With C#

While I was trying to compile a simple C# program that connects to a MySQL database, I got a compilation error about a missing file called "libmono-il8m2.0"!!! Take into consideration that I was on Linux/Ubuntu operating system, using Mono Project platform, and MonoDevelop IDE. So, here's the steps I tooked in order to get out of this trouble:
  1. Searched about that file (it's full name is "libmono-il8n2.0-cil")
  2. Installed it:
  • Using the Synaptic Package Manager.
  • OR, from terminal: $ sudo apt-install libmono-il8n2.0-cil
  • If you've been asked for a passowrd, enter the passowrd of your PC.
3. Recompile your solution again from the MonoDevelop or from the terminal, it'd work prefectly now :)

Sunday, August 10, 2008

Connect To Server Through FTP Command

To connect to a server using command prompt (for Microsoft Windows) or terminal (for Linux), use the "ftp"' command followed by the server IP-address.

Say, for example, that the server IP address is "", so you'd write the following on your command prompt:
$ ftp

Then click enter.

After few seconds you'd be connected directly to your server and can brows it using usual commands such as cd, get, ls, etc.

And in order to log-out or disconnect from this server connection, just use the command "quit"
$ quit