Friday 28 May 2010

Changing WCF OperationContract Element Names

Changing the root names of the request and response messages:

[OperationContract(Name=”RequestRootNameChanged”)]
      [WebInvoke(Method = "GET",
        UriTemplate = "/EntityData/{entity}",
        BodyStyle = WebMessageBodyStyle.Wrapped,
        ResponseFormat = WebMessageFormat.Json)]
      [return:MessageParameter(Name = "ResponseRootNameChanged")]
      List<ReferenceItem> GetSearchDropDown(string entity);

Removing the root names of the request and response messages:

[OperationContract]


      [WebInvoke(Method = "GET",


        UriTemplate = "/EntityData/{entity}",


        BodyStyle = WebMessageBodyStyle.Bare,


        ResponseFormat = WebMessageFormat.Json)]


      List<ReferenceItem> GetSearchDropDown(string entity);

Changing the child names:

Thursday 27 May 2010

Object Mapping Solutions

Imagine you have 2 sets of classes which have to be translated and mapped to each other (Source and Target):

Approach 1: Hard coding each mapping in Translator classes. One translator in each target class.

Approach 2: Using reflection to map the properties
This can be used only if the properties are exactly the same

Approach 3:
Using AutoMapper from CodePlex.

Wednesday 26 May 2010

SQL Server 2008

If you need to install SQL Server 2008, unfortunately you must uninstall all components of SQL Server 2005 if you already have them.

For other versions comparison check this: http://msdn.microsoft.com/en-us/library/ms143694.aspx


SQL Server 2008 Express Edition with Management Studio: http://geekswithblogs.net/campuskoder/archive/2008/10/08/125727.aspx

Monday 24 May 2010

Ways to Install a Windows Service?

Approach 1: Using Visual Studio Setup Project

In the Custom Actions section, you need to add the "Primary output from ..." to all the stages of Install, Commit, Rollback and Uninstall. Then your windows service will be installed.

Approach 2: Using InstallUtil.exe

Approach 3: Using sc.exe

Approach 4: Using WIX

to be continued...

Podcasts

Channel 9 Podcasts: http://channel9.msdn.com/Media/Podcasts/



Thursday 20 May 2010

Best Software Engineer Mindsets

Personality, General

Add Only Value
Only add value and add only value, don't do something that doesn't add value. Only say what adds value and helps, don't say something that doesn't add value.

Guard Your Tongue
Specially when you get very angry and emotional, it's when that you might say things and do things which will hurt yourself and others. Guard your tongue firmly and have a proper strategy to express your emotions in a more healthy and productive way.

Be As Accurate As Possible
Sometimes, we want to generalize things which is an easier way to get around things. If you're asked specific questions, try to be specific and give details accurately because you will be accounted for what you say. In emails, conversations and in all communications, be as accurate as possible.

Say I Don't Know and I Am Not Sure Carefully

It might be true that you don't know but if you keep saying I don't know and I am not sure, you will look junior and unprofessional.

Always, remember to be positive and add value so if you don't know something clearly or you have doubts about things, be accurate. Say I don't know but I can look into it or I guess it should be like this. I will check or do you want me to look into it?

On the other hand, one of the worst things which can harm your credit is to say I know when you don't know. Always give yourself time and gap to find out if you can.
  • I guess...
  • I presume...
  • I assume...
  • I'll look into it
  • I'll find out
  • not sure; let me check or I can check
  • Hold on, I'd need to refresh my memory
Prefer the Best/Quickest/Optimized Action
If there is a quicker way to do something, take that way and remind everyone to focus on doing the quickest/best way possible which adds value.

Always ask yourself "What is the Best Option Now?" and talk about best options always with the team.

Do Your Homework; Research
Always, do your own researching before expressing your opinion upon something unknown.

Strengthen Your Memory
This is another very important hint. I almost always try writing down important information but I figured out that it is not good enough. You need to memorize things. Practice every day to memorize information, telephone numbers, about your work, technology, name of people, etc.

This is vital if you want to be a successful Software Engineer. What you need to remember is that relying on writing notes, finding information from google are very bad practice and make your memory lazy.

Use your memory more, the more you memorize the more you can memorize. Spend every day to memorize and review things.

Email Is Worst/Most Dangerous for Communication
Best way to communicate is via face to face or phone. Emails can be worst type of communication. People misunderstand each other in emails and read emails in bad tone of voice.

Use emails only to give important information to others and write emails in the most positive way because unfortunately the truth is that people read emails in the most negative way possible. I paid this price several times until I figured this truth out.

Read your emails at least 2 times; once with your own eyes, and once with the eyes of recipients- don't say what is unnecessary and doesn't add value. don't add emotions in emails; they will be misinterpreted - ask yourself is it appropriate/necessary to say this in email?

Always Use Well-Chosen Words
It's specifically important for a successful software engineer to use only well-chosen and wise words in emails, conversations and meetings. Your words are powerful and carry meanings which might be offending or misleading to others so this becomes a significant factor.

If English is not your first language like me, you'd need make a double effort and program to improve the standard of your spoken and written English.

This is also highly vital in your progress and climbing the ladder to become Leader or Architect.

I can't say enough about the significance of this importance; always remember to use words wisely or you will face its consequences.

Help Others If You Can
There is more blessing in giving than receiving you have heard. This is also true for a software engineer. The more you help others, the more you learn and you gain credit at work. At the same time be wise not to forget your own works.
  • Hope it helps
  • Does it help?
  • How can I help?
  • ...
Don't Forget Meetings
It's bad for your credit not to attend meetings because you have forgotten. Basically, what you need is a system which helps you remember when you have which meeting. Best is to use a reminder application e.g. on your mobile that you're always reminded. IPhone has a free application called "aNote Lite" which can be used.

Don't forget meetings; have a proper reminder system.

Build Sense of Trust In Yourself

There are times that we don't know what to do and how to do things. Instead of panicking, build trust in yourself that you can handle it and you can and will find a way. Believe in your abilities and potential and have the confidence that you can figure that out. This doesn't mean not consulting with others when required but just means that you must trust yourself before anything else.

Technology

Become Member of Technology Forums
To gain advice and answers on your day to day challenges, join some good technology forums related to the area of your work e.g. msdn forum, stackoverflow, scrum forum, etc.

Develop Code Reading Skills
It's vital to be able to read other people's codes quickly and understand them so that later you can
  • Make a change
  • Fix a bug
  • Refactor the code
OK, how can you develop this skill?
  • Spend some time to read other people's codes; the more code you see from variety of people, the quicker you become to understand them. If you've been given the opportunity, become member of the code reviewing team in your Company.
  • Draw sequence diagrams and class diagrams for yourself if you've given a system which is very complex. In this way, you can easily understand what's going on and in your own language.
  • Use .NET Reflector or Visual Studio to analyse class relationships quickly; .NET Reflector has some good plugins for this.
  • Obviously reading articles and books would help also.
Do It Right The First Time
This might be an unachievable ideal but at least you should aim for it.

The reality is that you don't usually have time to change what you did initially or the budget is limited so make sure that you do it right in the first place.

So, always spend some time planning what you're gonna do and save future wastes. This requires that you master the requirements from the first place.

Automation:
Think about where you can automate things. Automated build, automated deployment, automated test, automated tools.

By automating things you make your life and your team easier.

Use TeamCity, or any other automated tool you're comfortable with, then configure your solution projects and tests to be built and run automatically. You can configure StyleCop to be built against too.

Commit Code into Source Control ASAP
Assuming you're using a source control such as SVN, you should be committing code as soon as it's tested. If you leave the code to commit late, you will have to sort out the conflicts with the other people codes. Folders might have been renamed or removed, etc and it can become complex and time-taking if you leave it too long.

Make all codes to be reviewed by one other developer before committing code into your source control
This ensures quality + many other things

Add Code Trace Log Always
You should be adding code tracing log to all your applications so that you can trace exactly when what happens. It's also great for debugging. There are tools which help doing so such as Enterprise Library Logging Application Block, Log4Net or native .NET Diagnostics classes (Trace and Debug).

Refactoring Techniques
Always there is space to improve the functionality and design of your code. Read articles and books about the techniques.

Don't be afraid of making changes.

Have Immediate Access to Technology Resources
Searching in Google doesn't give you the best results always.

Make sure that you have some websites (such as codeproject.com and microsoft msdn) or pdfs (C# 4.0 features) that you can access quickly. This would be needed when you want to develop something that you're not fully sure or have forgotten.

Design Patterns
Learn about a new design pattern every month; when all are finished (which is never reached) review them all. See where you can use a design pattern in your code to improve it not to complicate it.

Read Books
Always have a technical book to read about the area you're working in.

Read Blogs/Articles
Every week spend time to read few relevant blogs and articles.

Object-Oriented Design Principles
It's highly important to develop your OO design skills further so right now you can set SMART aims! There are SOLID principles and some other important practices you must be a ware of. It helps you design your application in a more maintainable way and also it's important in interviews.

Process Best Practices

Sign Off the Requirements
No matter what methodology or process you use, one thing must be done initially. Gather the requirements, document them in a "Project Acceptance Template" and get the client or manager sign that off.

This must be done before any coding/design takes place otherwise there can be serious issues.

Always Record / Track Issues
Always use a bug tracking tool such as SmartTrack, BugZilla, etc to track all issues.

Follow In-House Coding Standards
Wherever you work, at a client site or your own company, they have coding standards; find them, read them and follow them.

Reduce Key-Man Dependency
Get people who know most about the project, document their knowledge so that if they leave, you have those information available. It can never be perfect but it's important to emphasize on documenting the knowledge handover or assigning more than one person to key tasks.

Setup Dev and Test Environments Like Production
Otherwise, there is a high chance of issues occurring on production which could be identified in advance in Dev or Test.

Presentation Skills

Develop your presentation skills, you are expected to provide presentations in your job. This will be more important as you climb up the ladder to become more senior or leader:
  • Learn well how to use PowerPoint
  • Provide videos; you can capture video screen shots easily
  • Be organized, prepare in advance
  • Have a Presentation Template in PowerPoint
  • Use technology
  • Practice Practice Practice and Get Feedback, Improve Yourself, then Practice Practice Practice
  • ...
Communication and Relationships

Your Networking skills are as important as Your Software knowledge
No matter how knowledgable you're and how many books you've read, without the support of others you barely can get anywhere. Any promotion, help for your issues, supports you need require other people's willingness and attitude to help you.

If not more important, your networking skills are as important as your coding skills.

I'm going to write a separate article about how to build networking skills as a Successful Software Developer.

Know the Personality and Expectations of Your Manager

The fact is not everyone is the same so not everyone has the same expectation. You are responsible to make an effort to understand your manager and his expectations. Some are good with emails, some hate emails and you should get hold of them using face to face communications mainly or phone calls.

Know The Key People
Know well who are the decision makers where you work; managers, architects and leaders

Be Clever in Extracting the Information You Need

To do your job, you need information and that information is not completely clear often so you need proper strategies to get information from others.

It's a skill how to extract information from others.

1. List what you don't know as Questions and send email to people you think might know their answer.

2. Chat informally with other people to get information; this would look less like a formal request of information and people are more open to answer in this way.

3. Any important information must be confirmed in email otherwise people might change their words and thoughts

4. If you have time, read documentations, wiki notes, etc.

5. Build personal relationships with colleagues that are more easy going.

Don't Be Lonely
Find at least 1-2 friends with whom you can build personal bond - If you're lonely, you will be very weak and others might want to kill your credit/personality! Numbers are important - Build personal bond with least 1-2 colleagues, have fun and avoid gossips. We're stronger together.

Numbers count and give you more power, so build your network of colleagues.

If you feel everyone dislike you at work, find 1-2 people who don't dislike you as much as others and build your network with them; have fun and avoid rumours.

Resolve Conflicts by Arranging Personal Meetings
You might feel annoyed by someone at the office or perhaps you feel others keep gossiping about you. The best approach would be to have the courage to arrange a kind meeting with that person and discuss the concerns you're having. Use your negotiation skills to make sure that everything is communicated properly in a calm and friendly atmosphere.

If you keep put things under the carpet, it will certainly come out one day and when it comes out it might not be so nice for you. So take control and the initiative. Invite that person for a coffee :)

Ask their expectations clearly, listen well and express your expectations with caution always. Be ready to compromise on what can be compromised.

This is the best approach ever rather than keeping it to yourself and hurting yourself; also in this way, you will help the other person too because most probably the other person is hurt from you too and this would give a chance to sort things out like 2 mature friends who care about each other and the quality of their relationships.

Perhaps 90% of problems are misunderstanding because people are different in personality, thought process, understanding, education, background, etc.

Record any Important Information from your Communications with Your colleagues
People deny what they say; perhaps they forget or change their mind. So make sure that any important information is communicated via email.

If necessary sum up what they say and send them an email to confirm that is what they said. it has another benefit that you can make sure what you have understand is correct.

Make the environment easy; e.g. say I just want to make sure I've understood correctly.

Be Proactive in Communications
This is very important. Don't wait until someone asks you something to answer. Don't wait unless another person introduces himself/herself to you, don't wait until others invite you to pub, etc. Be proactive and be initiative in your communication whether it's about building new connections or maintaining existing ones.
  • Invite others for lunch, coffee, tea or a walk; at the same time accept other people invitations openly if you can.
  • Express your comments about what others say even if they're not directly speaking to you - 100% opposite to my background culture!
  • Arrange social events yourself
Be aware of your environment
Listen to what other people say around you. That's part of your job; be aware of your environment. Notice what changes are occurring around you and add valuable comments if you have.

Don't be isolated in your cave and just work hard. Only Working hard and coding is a very bad practice. Work hard and Smart.

Develop Debating/Negotiation Skills

You need to develop debating skills and know how to challenge others and how to respond properly when they challenge what you say. How to convince others and how to be convinced gracefully. Know with whom you can negotiate and how. Aim, purpose of the debate or negotiation should be clear for you.

Research about the topic and practice. It's also a very sensitive matter because no one enjoys to be proved wrong.

See The World From the Other Person's Point of View

When dealing with other people (Manager, Client, Colleagues, etc), always spend some time forgetting yourself and instead understanding the other person's desires, views, goals, aims, point of view, expectations, etc. This would enormously help you make the best decision what to do or say.

This helps you be tactful more easily because you understand how the other person might perceive you, therefore you speak only what is necessary; short and polite.

Supporting Your Future Career

In this section, I'd write what you'd need to be aware of to support a prosperious future.

Setup a Professional Online Presence

Personal website, LinkedIn presence, blog.

What is the purpose? Remember the purpose is solely to help you find the next job easier, remove all other contents which wouldn't serve this purpose directly.

Keep in Touch With Ex-Colleagues and Your Connections

Both you and them would probably benefit from this. Also, support your colleagues.

Have Your CV and Profile Always Up-to-date!

Your CV and online profile should always be up-to-date so that you can respond to opportunities immediately, otherwise the opportunities might be gone quickly.

This means that e.g. every other week while you still have a job, you should be updating your profile accordingly with the latest changes.

To be continued...

Thursday 6 May 2010

Service Locator Pattern

  • It's a design pattern for simplifying dependency injection
  • The ServiceLocator class would be a singleton class whose object contains a dictionary of all dependencies in the project
  • the main point of using ServiceLocator is to make the dependencies easily replaceable at runtime
  • It can be used along with other IoC containers - IoC containers are good to initialize dependencies whereas service locator can help replacing the dependencies at runtime after initialization when needed

http://simpleservicelocator.codeplex.com/

The problem with this is that if there is any ref-type property, this doesn't work. Which means every ref-type property must implement its own Equals.

Disk Drive Analyzer

JDiskReport: http://www.jgoodies.com/freeware/jdiskreport/

Sunday 2 May 2010

VPS Hosting Solutions

Service:
  • VPS Hosting Solution
  • Windows-based; to host asp.net applications
  • SQL Server support
Service Providers:

http://www.serverintellect.com/virtualservers/
  • $20 a month; not sure it is reliable
  • £21 a month
  • Supports only 2 dedicated ip addresses; £20 a year per additional ip address
  • £21 a month
  • same as webhosting.uk.com