November 2010 - Posts
Building N-Tier Applications with Entity Framework 4 Slide Deck
I just finished my session in Teched Israel 2010.
The subject was building N-Tier applications with Entity Framework. I want to thank all the attendees who joined me at this morning after yesterday’s party. The subjects that I covered are how to build N-Tier applications on top of Entity Framework in three different approaches – Self-Tracking Entities, Data Transfer Objects and POCO. If you are interested you can download the slide deck and demos from here.
Enjoy!
Improving Your Developer Skills
I’ve been asked twice this week by two different colleagues from where to
start in order to improve yourself as a developer. This question is very tricky and probably you’ll hear a different answer from every person you ask it. Also, in reality the “recipes” you get won’t necessary work for every person but they can be guidelines for improvement. This is a short version of my recipe and what I told my colleagues.
Read Books
This is an important thing to do when you want to improve yourself. If you want to learn something, a book in that area can help you to find all the details in one place. The problem is finding a good book to read which can become a very difficult thing to do. If you have friends that can recommend a book then probably it is a good one (cause you trust your friends (-: ). In the last half a year I read six different development books and they contributed a lot to my skills.
Test Yourself
One of the things that lead me to my current position and knowledge was my MCPD certification. Since I wanted to test my knowledge, I went to those certification exams. I’m not saying that it’s a must for everyone but signing to an exam can force you to sit down and to learn the materials. Of course if you use brain dumps you will gain nothing out of the test and I didn’t use brain dumps in the learning process. When you pass a certification you can be sure that you understand some portion of the materials the exam checked.
Hands-On
Practice can lead to perfection. This statement isn’t a joke. If you don’t practice what you are learning you gain nothing. One part of my current job is a .Net instructor in Sela College. When I’m delivering a course I’m giving a lot of weight to lab practices. In the last course I delivered, when the labs started a few of the students just picked up their stuff and went home. When the course’s test came they failed and the students that stayed and practiced passed. The moral of this story is that with no hands-on (and of course with no study) you can’t succeed in the real world tests.
Blogs, Magazines and Development Sites
Every day I’m reading a few Blogs that I like. Also, if I can I read an article in on-line magazines and development sites. This is helping me to stay updated with technologies and with other people suggestions and thoughts. The problem is finding the better ones from the flood of sites and blogs in the internet. In that case again you can ask your colleagues what they are reading.
Summary
There are many other things like taking a mentor, working in a supporting company environment, lecturing and instructing (which force you to learn a lot in order to know what you are talking about) and more which can help you to improve your skills. When you start doing those things it won’t guaranty that you improve in the short time but it will indicate that you are passionate for your profession and in the long run you will gain a lot.
Back to Basics – Null-Coalescing Operator
Yesterday during an EF4 course that I’m giving at a customer I showed an example for a property that is set
using the null-coalescing operator. Since some of the students asked me what is this operator, I gave a small explanation and thought that it’s something that I can share here in the blog. So here it goes…
Null-Coalescing Operator
The null-coalescing operator or ?? can be very useful when you want to check nullity of a reference type or nullable types. When it is used, it returns the left-hand side of the operator if it is not null. If the left-hand side is null, it returns the right side. Here is an example of how you can use the operator in a property to get a lazy initialization of the property:
public ObjectSet<ContactDetails> ContactDetails
{
get { return _contactDetails ?? (_contactDetails = CreateObjectSet<ContactDetails>("ContactDetails")); }
}
private ObjectSet<ContactDetails> _contactDetails;
This property is taken from an
Entity Framework generated
ObjectContext. When the getter is used, first there is a check whether _contactDetails is null and if not the getter will return its value. If the _contactDetails is null then the right side of the operator will be evaluated and the CreateObjectSet method will run and create the ContactDetails object set. The result of the evaluation will be returned by the operator.
There are other scenarios to use the
null-coalescing operator such as checking whether a nullable type is null in order to set its value if exists in a simple type and if not to set a default value. For example:
int? x = null;
int y = x ?? -1;
The example shows the use of the operator in order to determine whether x is null. in the example y will be equal to x, unless x is null. If x will be null y will be set to -1.
Summary
Lets sum up, the null-coalescing operator is a very simple operator that can be very helpful in null checking scenarios.
My Teched Session (or Why I’m Not Blogging Lately)
If you are a reader of my blog probably you have noticed that I didn’t write posts for a while.
The reason is obvious… I’m getting ready for my Teched session.
My coming session isn’t going to be an introduction to Entity Framework. This time I’m going to talk about considerations and approaches for building N-Tier applications with Entity Framework. I wrote a teaser Hebrew article about the subject which was published in Newsgeek and you can read it here.
I hope to see you at Teched!
Feature Detection for Better Compatibility in Web Development
One of the things I talked about in the session I had about what’s new in IE9 for web developers was how to make your web site/application more compatible. In this post I’ll try to give the highlights from the session.
Same Markup
When we develop web sites/applications we need to strive to use features that give us the same markup in every browser. When we know about a feature that is compatible in every browser we can use it without any fear that it will break our layout. For example using most of the Html elements such as input element for example will look the same in every browser. On the other hand, using the new HTML5 video element isn’t supported currently by most of the browsers.
Browser Detection
In the old days when we wanted to make our site compatible to every browser we used to detect the browser and then apply the relevant style/features/javascript in order to create our site appearance and behavior. This detection was made on the false assumption that we know how the next versions of the browser will work. A wrong assumption like that could break the site when new versions of the browser were released. This way of thinking is slowly disappearing and being replaced with a better method – feature detection. The only place that you should use this method is to make assumptions about older browser versions. The following code shows such assumption:
// Target legacy only
<!--[if IE lte 7]>
// Legacy browser-specific code
<[endif]—>
In the example we check that we are in legacy IE such as IE6 and the apply some legacy browser specific code.
Feature Detection
The feature detection is a good method to use in your site when you want to make sure that your site compatible to most web browsers. In this method you look to see whether a specific object, method, property, or behavior exists in the browser. If you detect standards first it will ensure you're getting your best experience in newer browsers (which will probably support the standards). Also, standardized features tend to be more stable and more interoperable across most of the browsers. So how does it work? the following example can show you a way to use feature detection:
if( window.addEventListener )
{
// Code for browsers with addEventListener
}
else
{
// Code for browsers without addEventListener
}
This check will pass in IE9 that has implementation for addEventListner but in IE8 and lower versions of IE it will go to the else statement and probably you’ll use the attachEvent method. The feature detection method is widely used in javascript frameworks like jQuery.
Summary
When you want to make your site compatible with browsers you should look first for features that all the browsers give you the same markup. If you target legacy browsers you can use the browser detection method. Otherwise use the feature detection method. Also, remember to test for standards first in order to give the best experience to your users.
IE9 for Web Developers Slide Deck and Demos
Yesterday I had a session about what’s new in Internet Explorer 9 for web developers at Microsoft office, Ra’anana.
I want to thank all of the attendees who came to hear the session about the new Microsoft browser. The agenda for the session was:
- Introduction
- Focus on sites
- Same markup
- All around fast
You can download the slide deck and demos from here. Pay attention that I removed the video and audio files that I used for the demos about HTML5 video and audio elements.
Enjoy!
P.S – The same session is going to be delivered by Shlomo and me at Sela office at the 22 of December. It’s a free session that you can register from here.