What a developer should know

I’ve been doing quite a lot of interviewing lately for an ASP.NET developer position. I was surprised that a lot of the people I interviewed lacked the basic knowledge and understanding of trivial development and IT topics (most of them claimed to have multiple years working experience). So what are the things that I expect a developer (especially an ASP.NET developer) to know? And what characteristics should a developer have?

Object Orientation

You probably saw that one coming. It’s amazing (and a bit frightening) to know that some developers have managed to write and ship code without solid understanding of OOP. Most of the interviewees got lots of concepts confused. Difference between abstract classes and interfaces, static classes and the difference between overriding and overloading to name a few. Some know the concept but only as a textbook definition. Most fail to specify use cases for these concepts and some can’t state why object orientation was created in the first place.

Get to know your classes and objects, they are the building blocks you will use to create great software. This MSDN article explains the very basics, also check the “For more information” sections in the article.

Write “good” code

I expect from a developer with “over 5 years of experience” to transition from just writing code to writing good code. By good code I mean readable, extensible and maintainable code. The developer should know how to leverage OOP to loosely couple components and decrease the dependency between them. I also expect from an advanced developer to know how to organize source code to smaller reusable and manageable chunks. It saddens me to say that some “experienced” developers have never used or even heard of design patterns such as MVC.

The developer should also know how to make the best out of the development tools he/she uses. IDEs are there to make life easier, find out what they have to offer and how they can help you be more productive.

How the web works

No one can deny the importance of the internet in our lives, it’s everywhere. I expect from someone who writes applications for the web to actually know how the web works. Stuff like what happens when you request a page and what is the role of the browser should be no brainers. Every web developer should also know the basics of HTTP such as request and response formats and request types. I also expect from an ASP.NET developer to describe the page lifecycle, sessions, viewstate and caching, what IIS is and how it serves requests.

Oh and some ASP.NET developers seem to forget that ASP.NET is an abstraction layer so they don’t actually bother themselves with good old HTML.

Have some “under the hood” knowledge

This applies to every developer. If you develop .NET applications I expect some understanding about what .NET is, what it offers and what are its components. Things like CLR, MSIL and garbage collection should be known concepts to a .NET developer. Having this sort of under the hood knowledge will help you build better applications. You will understand the strengths and weaknesses of the technology you are using, things to use and things to avoid.

Get to know the terminology that is used for the technology stack you are using. This will help you when searching for resources on that particular area whether it’s for learning purposes or for when you’re in trouble and need someone’s help. I found that lots of developers can’t answer the question “what is an assembly in .NET” even though they use it all the time.

Also what I hate the most is a developer who doesn’t understand the basic underpinnings of computers and the operating system he/she is using. Stuff like setting a static IP address or formatting a drive should trivial (seriously I have seen developers who don’t know how to do that stuff).

Passion

I like being around passionate developers and I tend to take a passionate developer more seriously than someone who writes code just because it’s his job. You know a passionate developer from the way he talks about technology and code. A developer who is always up to date is also an indication of a passionate developer. I think a developer should be up to date when it comes to the technology stack he is working on. For example if you develop using Microsoft technologies you should know that Microsoft offers many ways to create services that can be consume over the web (WCF, WebApi … etc.). It doesn’t mean that you have to be a professional in all of them, but you should know what each one offers, what are its pros and cons, that helps you to choose the right tool for the task at hand.

“Not knowing” isn’t an excuse anymore, with internet access you can learn all you want. Nothing is further than a “search” away. Get to know professionals in the technology you are interested in, read their blog posts and follow them on social media. You will be amazed by the amount of stuff you can learn from other people. Happy coding!

My first use of the “dynamic” type in C#

Every once in a while when writing code I face a situation where I want to do something trivial, something that is usually done as a no brainer for a programmer. I start writing code and hit a wall immediately, it turns out it’s not as straightforward as it seems.

What I wanted to achieve

I am calling 4 different web services from 4 different methods. Each web service has a method that receives a request as an object and initiates a BizTalk orchestration. The request object is quite big, it has lots of properties that need to be filled. All 4 request objects have exactly the same properties inside (same names and types) but the objects differ in the class name and namespace. Have a look at the below class diagram.

Class Diagram
The properties are mainly primitive types

Each object is going to be filled in it’s respective method and since all classes have the same properties there will be redundant code in all 4 methods. I want to extract the code that fills the object into a separate method that will take the request object and all it’s values as parameters and assign the properties with their correct values. This method will be called from the 4 places where I want to fill the request object.

The problem

In order to access the properties of any of my request classes I must have an instance of that type. The issue is that the method I want to create doesn’t always receive the same type as a parameter. It could be any one of the 4 types shown in the diagram.

You might say why not change the parameter type to “object”. The  problem with this is that I have to cast this object to one of the above types and hold a reference to it in order to fill it’s properties.

The solution

The solution was changing the parameter type to “dynamic”. After all this parameter may have 4 possible types.  The caller of this method will then be responsible for casting back the dynamic object to the type it requires.

This is what the code looks like without using “dynamic”


Type1 type1 = new Type1();
type1.Prop1 = 1;
type1.Prop2 = 2;
type1.Prop3 = 3;
type1.Prop4 = 4;
type1.Prop5 = "a";
type1.Prop6 = "b";
type1.Prop7 = "c";
type1.Prop8 = "d";
type1.Prop9 = true;
type1.Prop10 = true;
type1.Prop11 = false;
type1.Prop12 = false;

Remember that I have more properties than this and that this code will be duplicated 4 times.

This is what the method that will fill the objects look like:

 public void FillData(ref dynamic request, int prop1, int prop2, int prop3, int prop4, string prop5,
string prop6, string prop7, string prop8, bool prop9, bool prop10, bool prop11, bool prop12)
{
request.Prop1 = prop1;
request.Prop2 = prop2;
request.Prop3 = prop3;
request.Prop4 = prop4;
request.Prop5 = prop5;
request.Prop6 = prop6;
request.Prop7 = prop7;
request.Prop8 = prop8;
request.Prop9 = prop9;
request.Prop10 = prop10;
request.Prop11 = prop11;
request.Prop12 = prop12;
}

The following code will call the above method, this code will be called in the 4 places where I need to fill my request object. Each time the appropriate type will be used.

Type1 type1 = new Type1();
dynamic dynamicType = (dynamic)type1;
FillData(ref dynamicType, 1, 2, 3, 4, "a", "b", "c", "d", true, true, true, true);
type1 = (Type1)dynamicType;

At the end

You’re probably saying to yourself that I am over thinking this and that it’s too much fuss just to avoid duplicating code. Perhaps you are right but small things like this annoy me. I am always trying to find the most optimized way.

I’d love to hear comments and  improvements or if I can achieve the above in a different way.

How my brain categorizes bugs

As developers we spend most of our time debugging code we wrote (or others wrote). The debugging process is time consuming, frustrating and a pain in the neck but very rewarding when you solve a tough bug. I take bug fixing very seriously and tend to get attached a lot to the code, so much in fact that my brain automatically categorizes bugs. Here are the categories as proposed by my brain:

  • The Business Bug: These kind of bugs are related to the business or logic your are implementing, if you are familiar with the implemented logic this should be an easy bug to fix.
  • The “Time Bomb” Bug: These bugs are hidden away under layers of code and logic, they have been there for an unknown amount of time waiting for the appropriate moment to pop up. The appropriate time for this bug to show up is always the most inappropriate time for the developer.
  • The Pregnant Bug: These bugs are mean !!! Solving a bug of this type will trigger the bug to go into labor and give birth to other bugs.
  • The “Chain Reaction” Bug: These are my favorite bugs, they are the opposite of “The Pregnant Bug”. Solving a “Chain reaction” bug will automatically solve other bugs along the way.
  • The “Peek-a-boo” Bug: These bugs are shy, they will show themselves briefly and then hide away. Sometimes these bugs are a one time occurrence, but most of the time you will have to play hide and seek with the bug.
  • The Environment Bug: These bugs are related to the environment where the code is developed or deployed. These bug often come as a relief to the developer since there is nothing wrong with the code. But beware these kind of bugs can turn out to be tough suckers to solve.
  • The Hybrid Bug:  Most of my bugs fall into this category. You can mix and match any of the above categories to produce a new category. For example you can have a “Business Time Bomb” bug or a “Pregnant Environment” bug.

These are the categories that I can squeeze out of my brain now. If your brain assigns your bugs to other categories please share them Smile