I’m Ukrainian. I live in Austria. And I support Euromaidan! Here is why.

November 27, 2013 Personal 4 comments

My blog is mostly technical, but time-to-time I write about the life. I write this post to support people who fight for the future of my country.

image

Currently I live in Europe, Austria. I’ve been living here for almost 2 years and have some idea about life here. My daughter was born here. I’m happy about the life conditions. What I miss are my family, my friends and my Ukraine, place where I can truly feel at home.

Let me share few of my experiences when comparing to Ukraine.

Salary.

In the time when I was in Ukraine I used to work for outsourcing IT-company. I had salary close to 2K US dollars. I paid almost nothing in taxes. In 2011 this salary was 6+ times larger than what average Ukrainian was making. When I came to Austria I started with salary 1.6 above average. And I paid more than 40% in taxes and mandatory health insurance. It would probably make sense to live in Ukraine with my profession. Would it? Continue reading to figure it out.

Life.

You don’t get wealthy life with ~50K Euro salary, especially when almost half of that is immediately taken from you and when you also have to pay rent.

Instead what you get is FAIR life.

All your taxes go somewhere. For real. You can even know exact proportions from your salary spent on each of budget areas. It is virtually impossible to find roads as bad as in Ukraine here in Austria. Even the most rural village somewhere in the middle of Alps has perfect roads.

Transport is 10x times more expensive than in Ukraine, but quality is not comparable. Clean, no crowds, comfort inside, information availability, timing, and no people yelling.

There are plenty of possibilities to spend your free time in Austria. They charge money for everything, that’s true, but your money is exact reason why those attractions are maintained in perfect conditions. My wife has blog where she posts almost every time we go somewhere.

So why is it FAIR if it is so expensive? – Because people who provide those services for you are also people and they also have families to support. This is why I see it to be fair.

Health.

Huge amount of what you make also goes into health insurance. Sometimes I feel greedy and think that I’m paying much and don’t really use anything of that, since I’m healthy. Think again when you see disabled person on the street in Ukraine. If those guys have no support from families they are simply left behind with no help.

My daughter was born here. I left not even one cent in the hospital. My insurance paid for this. For 4-5 days sum was probably close to 4K Euro. Hospital got those money, doctors got those money. At the same time my wife got great treatment & care. My daughter got all she needed or more after birth and was all the time with her mother (+ me during the day).

It is complete myth that health services in Ukraine are free of charge. It is just nonsense. I understand that people in healthcare need money and they DESERVE, but not the way it works now. I would love if Ukraine could have another mechanism for health care. When people get good services and doctors are happy about their income.

Unfortunately you need to change your attitude and pay it forward. I know for Ukrainian mentality it is difficult, but I believe it is the right way and it is the way my country is choosing right now.

It is Schengen Zone after all.

There were few times when we just went to another country (Slovakia) for evening shopping. In 2012 we visited many places in Europe. Cheap flights work great.

There are many people from different countries. And it allows you to make many interesting connections. I worked in a team with Austrian, Italian, Spanish, Polish, Serbian guys.

When you have no borders you feel free! Why should Ukraine be closed country?

One of my current British colleagues says: “There should be no borders! People should live and work where they want.”

Police and few other things.

I had two big encounters with police. One in Ukraine and one in Austria. One in Austria was when I scratched rented car and had to bring police protocol to insurance company. It was Sunday. I filled-in paper with my accident info and went to police station. Policeman spoke English really well. He was happy to help, quick and efficient. I got the paper free of charge within minutes.

I’m ashamed about one in Ukraine but will tell you. When I was a student I went together with my friend and girlfriend (wife now) to Kharkiv. We were making pictures everywhere. My wife noticed interesting advert. in Underground so she decided to make a picture of. Immediately we were caught by local police. Accordingly to them we were violating rules. They said it is forbidden to take pictures in Underground because of the threat for the country. What? They suspected few students to be terrorists? No, wrong guess. – They wanted illegal money! They took us to their local office and kept there until someone gave them money as bribe. Shame! I’m very sorry something pushing them to do such things. I don’t want that. My wife and those guys have to be happy.

Dear Ukrainian police, guys who caught as that day, this is for you. See what could be happening in Ukrainian public transport one day: http://www.youtube.com/watch?v=PXglXeONApw (At one of Vienna train/underground stations).

As of road traffic police? – Guess what? I was never stopped in Austria by them.

Crime on the streets? – Almost none.

Governmental authorities? – Efficient/also strict. Information and most of forms/etc. are available online.

If Ukraine joins “big brother”, police and authorities will get even worse, much worse. I know that those guys are also human beings and are with their nation. Governmental people are aimed to care for their country and would do so if not the way things are now in Ukraine.

So why do I want Ukraine to be part of EU?

Living in Europe is expensive. But instead you get fair life and freedom. I would feel myself absolutely free if I could have the same in my home country. If my parents could have proper compensation for their work. If my father didn’t have to go to other countries to make money. If my sisters could get what they deserve and European possibilities.

Change is needed. Also in our minds. It doesn’t happen overnight, especially in country that had been for so long under influence and pressure of another country that always wanted to dominate. But I believe in Ukraine. I believe in my brothers and sisters.

We start with ourselves. People who protest in Ukraine made their mind about the way to take. It is already first step. Many more to follow. But over time people will get happier and more enthusiastic about their future.

Not only words…

I also went to local Vienna #Euromaidan with my baby (see pram wrapped in flag) and wife.

 

Ah! Almost forgot: There are no more gays in Austria than in Ukraine. Don’t worry ;)


4 comments


Book Review: “Give and Take: A revolutionary approach to Success”

November 21, 2013 Book Reviews, Success 2 comments

Give_and_take_cover_3DCan you be a big boss if you are not greedy? Can you move to higher positions if you spend you time giving to others? Isn’t it better to take as much as possible? And to grab every opportunity you have to get promoted? Why would you help others if you don’t get back more or at least equal?

This book argues with conventional view on how people succeed.

The book splits people into three categories: Takers, Matchers, and Givers. It could be that most of people are Matchers. We always try to pay it back. Entire world is build on that – you pay people. There are people who would smash you into the crap if you stand on their way. It is commonly accepted that these people get what they want. There is type of people who help others without second thoughts.

Adam Grant, the author, says that takers get to high positions quickly, but only givers stay there for long. Though it could happen that givers got trapped and become doormats or pushovers, the book brings some tips on this.

One of the reasons I liked the book is that it provides a lot of research information. Book is not written out of thin air it bombards with facts to support ideas. Studies and research results provided in the book are thought-provoking. Just reading them is very interesting and sometimes even exciting.

For example if you were to ask wife and husband to give a percentage of their contribution to their marriage life. Ideally it should sum up to 100% and be 50%/50%, but turns out everyone thinks that they contribute more so you get something close to 130%.

Or did you know that your name could easily affect your choices in life? People with name Dennis are more likely to be Dentist. At least this is something author brings as the fact. On the other hand I just googled why this might be not truth.

There are many more of similar studies and facts about successful people in the book. I enjoyed reading them.

Some are questioning if book is truly bringing new approach to success or it is just useless junk. I found this interesting question posted by Iryna:

Hi Adam,
While reading a book, I decided to conduct a research. I interviewed my friends and co-workers and asked them to pick four values and arrange them from most to less important. I used values from the list presented in Schwartz study.
I found out that all the men picked values from taker list. Wealth, power, pleasure and winning. The majority of women picked helpfulness, responsibility, social justice and compassion. So, according to my research, women tend to be more giving then men. (Was not surprised of course by this result). However, as you know the majority of executive positions are still occupied by men. The question is, does “take and give” approach work when it comes to gender? Or man who is a taker will always be a step ahead of a giving woman?
Thanks,
Iryna

It is very legitimate question. I also think that book brings some controversy thoughts. Splitting people just by givers and takers didn’t seem good enough to picture successful person, since many givers were and are not successful. Frequently because they were doormats/pushovers, burned out or just went unnoticed. I’m wondering if we could maybe come up with idea of successful person that also shares similar properties of giver, but also has what’s best from taker.

Let me try: I think the way to succeed is to give people something that they need and value more than it actually costs for you. Even though I used word “give” and it probably sounded like takers motto. But why would that taker be bad? He is just smart, and besides he is helping others by giving them what they want. Isn’t he? I think that supporting other people is very wise, since they will watch your back. Building solid social network is important and you indeed can only build it by sincerely helping. Giving credit and prising people is also very important and a must.

Important is to know what others need and what it is you can give them back.

I honestly love to give and help, but what I love even more is to get. When I was reading the book I though that I mostly fall into matchers/takers group and was a bit ashamed (since they are bad, right?). But I just took assessment on the website of the book: http://www.giveandtake.com/Home/ChooseAssessment

Here are my results:

image

Doesn’t look that bad, does it? What are your results?

Pay it forward is exactly what this book advocates for. This is what my former scrum master did when she gave me this book and one more book. I’m really thankful her for this. I should be paying forward as well.

Dear readers this blog post is my payment to you. I don’t know you – I just share thoughts with you, but sometimes this might help me. It did in the past, since blogging pays off.

Do I recommend to read this book? YES! Definitely. It worth reading even if in the end you will find yourself not agreeing with some conclusions.


See the book on Amazon or buy it using my my referral link below.


2 comments


Federal Information Processing Standards (FIPS) enabled and your .NET code

November 13, 2013 Errors, Security, Windows, WPF No comments

Have you ever run into this error?
“This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.”
FIPS is what US government came up with to standardize some of the aspects of processing information. FIPS 140heavily affects cryptographic area. For example, MD5 or SHA256 is not FIPS compatible. That’s why you would get an above error if you were using MD5, SHA256 algorithm on Windows with FIPS enabled.
If you are developing some governmental application (international in my case) there is high chance that this feature is enabled on target environment.
To enable FIPS locally for testing purposes do the following:
Start Local Group Policy Editor via “gpedit.msc” and go to: Computer Configuration –> Windows Settings –> Security Settings –> Local Policies –> Security Options –> System cryptography: Use FIPS-compliant algorithms for encryption, hashing, and signing.
image_thumb-25255B5-25255D1
Or just HKLMSystemCurrentControlSetControlLsaFIPSAlgorithmPolicyEnabled if you are running Win7.
Be aware that this settings changes lots of things in your system. Especially old stuff. Read: http://support.microsoft.com/kb/811833, and for how MS tries to be compliant with FIPS http://technet.microsoft.com/en-us/library/cc750357.aspx.
Back to your .net code. These would be alternative hashing algorithms: HMACSHA1, MACTripleDES and few more, but I would go for one of SHA algorithms by using CryptoServiceProvider. For example SHA1CryptoServiceProvider. Except of hashing some of the encryption algorithms won’t be compatible as well, so you will need to figure out what works. Unfortunately MSDN doesn’t state it explicitly.
After I enabled FIPS to test the app I wasn’t even able to compile the solution. Visual Studio started to complain about xaml files. I found that I’m not the fist to see that problem. Strange, since I thought that I had required updates. Nevertheless fix is to put this: <enforceFIPSPolicy enabled=”false”/> into your msbuild.exe.config or denev.exe.config
I wonder how much unknown and strange stuff is hidden under the hood of operating system. Recently I’ve started discovering a lot of such things.


No comments


My new Dell XPS 13 ultrabook

November 12, 2013 Devices No comments

My wife desperately needed new laptop, which she mostly needs for writing her blog, browsing net and some photo editing. Doesn’t sound like much, but doing that on slow netbook is a pain.

We had two options. One of them was to buy her something reasonably priced but just enough for her needs. The other one was that she starts using my laptop and I buy myself something new. In either of those my sister gets my wife’s netbook, which btw was marriage present in the first place.

I think you guessed that idea of buying something new sounded very appealing to me. Well, isn’t it always very pleasant to get new toy/work device? But that’s not the whole story. You might have noticed that I’ve changed my employer if I even can say so, since it is contract based work. Now I need to carry laptop almost each day. And my dell xps 16 isn’t light at all, especially when you put charger in the backpack.

So I bought myself Dell XPS 13 FullHD. I just googled this picture:

I would give it such a description: It is thin as “Mac Air” and powerful as “Mac Pro” but costs less.

Surprisingly it is close to truth. It is very high quality made with aluminium cover and carbon-fibre back. Really thin and light. Runs cool. I’m just enjoying carrying it. It is even possible to lift it up lid open with two fingers. Specs-wise: i7, 8Gb, 256 SSD, great FullHD screen, runs on battery for good 4+ hours (Dell declares more). So again if you compare it to Mac, screen and battery are probably only things better in Mac Pro. I’m not sure though what advantages Retina brings on 13’’ screen over FullHD, and what about resolution pain with some of apps. Of course it is great if you can run laptop for longer on batteries. If it is primary reason for ultrabook than go for newest Air.

Nevertheless, I bought the laptop directly from Dell and paid 1300 Euro. Here in Austria it is 200 Euro less than  Mac Pro 13 Retina. It took approximately 2 weeks until it was delivered by DHL. Also just an advice – always check exactly all of the components you get. I didn’t do so and thus got “qwertz” German keyboard. Fine for me but might not be for everybody. It should be enough to call Dell and change keyboard or operating system if you like. Btw XPS13 comes with Win8, which can be upgraded to 8.1 for better desktop experience.

If you are interested to know what are downsides. I would say that probably I’m missing some of the ports. It is natural for thin ultrabook, but having one audio, one video, two usb (3.0btw) feels not enough and bit annoying. Also would like to have few more keys available, but again – size related and something you can get used to. In some of the reviews I read people having issues with touchpad, but I never experienced any.

For my own reference below is table with laptops I owned. All of them currently work and I’m completely happy about decisions I made about buying them.

Dell Studio 1535

DellStudio1535

Dell Studio XPS 1647

DellStudioXPS

(+upgrades)

Dell XPS 13

 

image

Processor Intel® Core™ 2 Duo T5850 2.16GHz Processor Intel® Core™ i7-620M Processor 2.66GHz (3.33GHz Turbo Mode, 4MB Cache) Processor Intel® Core™ i7-3537U Processor up to 3.1GHz, 4MB Cache
Display LCD(1280×800) LCD Panel Edge-to-Edge FHD Widescreen 15.6 inch WLED LCD (1920×1080) W/2.0 MP 13.3in Hi-Def (1080p) True Life WLED Display W/1.3MP
CD ROM/DVD ROM DVD Super Multi CD ROM/DVD ROM 8X Slot Load CD/DVD Burner (Dual Layer DVD+/-R Drive) –
Memory 2GB DDR2-667 Memory 8GB Shared Dual Channel DDR3 at 1333MHz Memory 8GB Single Channel DDR3 at 1600MHz
Hard Drive 320GB 5400

Hard Drive 256Gb SSD

Hard Drive 256GB SSD

Video Card ATI Mobility Radeon™ HD 3450 Video Card ATI Mobility Radeon™ HD 5730 – 1GB Video Card Intel HD Graphics 4000
Sound High Definition Audio Sound High Definition Audio 2.0 with SRS Premium Sound Sound Wave Maxx Audio
Wireless Dell Wireless 1397 WLAN Mini-Card Wireless Intel® 5300 WLAN Wireless-N (3×3) Mini Card Wireless Killer Wireless-N, 1202 for Video & Voice w/ BT 4.0
Battery 56 Whr Lithium Ion Battery (6 cell) Battery 85 WHr 6-cell Lithium Ion Primary Battery Battery 6-cell 47W/HR LI-ION

After all these are just devices, but even proper stone knife without fractures made a difference in longer run. What laptops do you use to kill a mammoth? Large super-powerful or light and just powerful as one I just bought or maybe a combination of laptop/desktop?


No comments


Leaving my second job – it was time of new experiences and joy

June 27, 2013 Career 4 comments

*** NOTE/DISCLIMER: The opinions expressed herein are my own personal opinions and do not represent my current employer’s or any of its employee’s view in any way. I also won’t mention complete names of my colleagues or company names, you have to guess or just know ***

Today is my last day with my current employer. I worked for this company for almost 1.5 years. Not much, but during this time I worked with many great people and I gained unique experience. I just read my post on leaving my first job and I actually enjoyed the structure in which it was written. In this post I will express my thoughts and impressions of working for this company.

I BEFORE

In summer 2011 one of my former colleagues who had left SS years before me wrote a mail asking if I’m not interested to move to another country. He said that he remembered me as a good developer so he wanted to recommend me for a position in Austrian company where he worked at the time. Now he works for MS. Since I felt myself young and limitless I agreed. I had first interview over Skype. Not sure if I impressed interviewer, since I wasn’t strong in my Web skills, which has probably decided on the team to join. But seems that he liked me. Around that time I got married and we were heading for Europe for our honey week. Next interview was scheduled for the time when we planned to be in Vienna. This was the first time when the company saved money on me. This interview went much smoother and I’m sure I have impressed guys.

One of the most toughest questions was salary expectation. It is obvious that estimating salary expectation for living in another country you have no clear idea about is hard. Forums/government papers and reports help but not extremely much. I made my number and it fitted into company’s rage well since I got an offer with exactly that number.

BUT it definitely wasn’t the reason to move. I knew that cost of living in Western Europe is high and for money I got in Ukraine I can buy lots of goods. You know what? Higher cost usually means higher quality. This is absolutely true for Austria. But even this wasn’t complete portion of my decision. I guess primary reason was to try new experience and plus it was a time to change my learning curve as well.

II THE BEGINNING

Unfortunately it takes ages until Austrian government issues long term visa for 3rd world country. I had my interview in Summer, but started to work in Winter. I didn’t know what to expect in Austria and knew very little about the company I was joining. Whole move was very exciting time. Our parents had tears in their eyes while we were waiting for the flight. I understand them – it was not possible to know if we were going to return back or stay living there. It is still not known.

This time was very much different from anything I would have had if I stayed in Ukraine. Me and wife had great chance to travel across Europe and we have a daughter being born here. I anyway plan to have a blog post on how it is to be foreigner (developer) in Austria, thus wait for it. Now I will concentrate more on career.

On my first day I was assigned a bug in search engine. But since I didn’t have credentials to most of the systems and tools and I knew nothing about the domain I have fixed only 2 days later. Fix was one line change in the config. I remember how Sebu helped me right from the beginning. This was colleague support you can only dream about. Managers wanted to try me out, thus assigned a project with middle importance and priority. When I finished with it I remember none was really expecting it to work completely properly right away. But project itself turned out to be a success. This is how I proved myself to be reliable worker producing quality software.

And I started to enjoy it. Every piece of code I was assigned to write received lots of my attention. I cared for the code quality much. I even tried to have my code 100% UT covered.

III CORE

The company I joined is specialized in online entertainment, and I started in sports betting section of it. Biggest difference to what I had to do back in Ukraine is that this company is product company. We produce our own product and make money for ourselves.  Team which I joined is responsible for developing/extending/maintaining whole bunch of services (maybe 40 or more) within enterprise SOA architecture.

It is pretty normal that there was room for learning when you start in new company. I definitely gained new experience in tools and the way how software is produced and deployed to production. Plus it was a move to more “webby” things for me. My team is doing production rollouts almost each weak. Millions people use our web site and we change something behind the scenes at the same time. Great.

I didn’t change my team for the entire time in the company and I don’t regret. I know that there were people who got tired or stopped enjoying their work or there was something they didn’t like. But I like the team very much. Every developer in the team is highly skilled and experienced.

Sergey, Sebastian and Simone are three developers from whom I gained the most knowledge and have taken something from them. Other developers Predrag, Lukasz, Alex, Raphael and Vladimir were very kind to me and it was pleasure to work with all of them. Some just joined the team, some left and for some big career journey just started.

For sure I improved my English, but there are two other languages I improved, like German and Russian. Before this company I never spoke Russian. But things turned in a way that I’ve significantly improved my verbal Russian skills in Austria. The most collaborative with me was Sergey. It was eye opening how frequently he has new ideas and knows about new features and tools. Thank you.

I would like to thank all developers with whom I worked and also our testing team. Without testers we wouldn’t be able to produce quality software.

It was also a pleasure to work with product owners, delivery managers and other departments of company.

Special memories will stay with me about the DB dev team. It was joy.

IV OTHER THINGS

I will definitely miss Friday lunch walks to Greek restaurant. It might be surprising but except of improving my dev skills I’ve learned how to play table soccer. Not that I play like a pro, not even comparable to guys who work here for years, but quite acceptable. I think you can even tell how many years person worked here when you look at his/her wuzzler skills.

Also I will miss this year’s action day and numerous parties throughout the year. I say I “will miss” since I will work in place where people probably don’t like parties, sport activities that much, but I have to try before claiming anything.

V THE END

If you read my post on leaving my previous job you will understand that I left not because of money or dissatisfaction but because of new experience and new opportunities. I’m very happy about my current team and satisfied with work I do. On the other hand things have changed for me. My daughter is now 18 (… Days!) and understanding that I will have to support her (and likely her sibling) changes the way I think about money.

Nearly 3 months ago I was contacted by some UK company looking for .NET developers for work here is Vienna. They titled e-mail with solid salary number, which was so attractive it would be silly not to try.  First interview I had on the phone with some Indian interviewers. My questions on what this is about were somehow avoided. True conspiracy. But after they were much satisfied with my skills all the cards where turned. This company is just man in the middle connecting me with something big.

VI THE FUTURE

After some negotiations with man in the middle and and direct interviews at UN I was offered a job as a contractor. I’m officially starting my own business from 1 of July being registered here in Austria. I even have my own European VAT identification number. And can accept business opportunities from whoever I want. Well, not that I will have much time, but it is just nice to realize this.

I was in healthcare and then moved to gambling and now will dig into atomic energy. There is a rumor flying around about how depression it is to work for those guys and how it is difficult to change bureaucracy things. I see myself as a changing force aimed to make more things being done. And I’m looking forward to it!

It was great time to work for the Company.

I miss you all!

For me it is time to bet and I hope to win!


4 comments


Book Review: “So Good They Can’t Ignore You: Why Skills Trump Passion in the Quest for Work You Love”

June 23, 2013 Book Reviews, Career, Success No comments

SoGoodTheyCantIgnoreYou Recently one of my colleagues got so inspired by two books she read, so that she decided to simply start giving them away. She was guided by the “Pay it forward” concept, which “is asking the beneficiary of a good deed to repay it to others instead of to the original benefactor” as per wiki. Basically, if I like books she bought for me (hard copies) and if I like the concept I can continue buying books for other people, so they can spread the ideas and books even more.
So far I read only one of two. The short one, called “So Good They Can’t Ignore You: Why Skills Trump Passion in the Quest for Work You Love” by Cal Newport. It doesn’t talk that much about giving things away, so you probably should wait until I write another review, but continue reading for something more closer to our working lives – to our careers.
“Be so good they can’t ignore you” is a quote from comedian Steve Martin that captures what is needed to build a working life you love.
Cal, the author, takes us though dozen of different examples of people who achieved success and who have failed. He starts his book with groundbreaking statement that following your passion could be an epic mistake. He says that since decades books on success tell to find something that is the most appealing to you and simply follow it, they tell you cannot achieve greatness without doing what you love. But many examples Cal brings to the table prove this being wrong. My vision and what Cal also says is that people simply don’t know what they want. They have to try things, but trying all the things around could just easily be waste of time. Lot of things require efforts and work until you really start taking adult steps in it and can do something meaningful, and even more – understand if you really like it or if it was just a play.
As opposite to passion mindset which focuses on what world can offer you, Cal says that you can armor craftsman mindset, which focuses on what you can offer the world, because “regardless of how you feel about your job right now, adopting the craftsman mindset will be the foundation on which you’ll build a compelling career”.
“ The career capital theory of great work […] provides the foundation for all of the ideas that follow it in this book. It claims that the key to work you love is not to follow your passion, but instead to get good at something rare and valuable, and then cash in the “career capital” this generates to acquire the traits that define great jobs. This requires that you approach work with a craftsman mindset and not a passion mindset. ”
Do you know about 10,000-Hour Rule? It says that excellence at performing a complex task requires a critical minimum level of practice. I think it is understandable that sometimes it also requires talent in addition and [EDIT] not every way of spending those hours adds up. Regardless here is my question: how many 10K hours do you have in your life? On normal pace it is close to 10 years. So doesn’t sound like we have capacity to try lots of things in the world and simultaneously be good at them.
At some point in time Cal convinces us that if you have enough career capital and some rare and valuable skills you can push it towards great achievements and this is much better choice than looking for mysterious passion. In the book he also shows how he made decisions and followed “rules” described. I wish him good luck.
As my personal note I would say that book indeed inspires to put more efforts into improving skills I have at the moment. I consider myself quite good in what I do now, but it would be a self-robbery not to continue developing skills and not trying to push them forward. Jumping to something completely else might destroy all I have, instead I’m advised to take little bets.
The book doesn’t take much time to read, thus for some additional inspiration I would definitely recommend it, unless you are now reading some stuff to be so good at what you do, so that they cannot ignore you!


No comments


How to consume WCF service in .NET

May 27, 2013 .NET, WCF No comments

What? I must be kidding. This is not blog for kids trying to play with .NET. Every professional .NET developer knows how to consume WCF. Don’t they? There is nothing more easier than that.

Well, not that long ago I realized that the way I like to consume WCF services is not 100% correct.

What I like to do is use of “using”:

using (var client = new SomeServiceClient())
{
  var response = client.SomeServiceOperation(request);
  //return or do something
}

While this looks nice, here is thing which even kids won’t like: Dispose method for the client is not really implemented correctly by Microsoft! It could throw an exception if there is network problem therefore masking other exceptions that could have happened in between. You can understand the issue better if you have a look at WCF samples (WF_WCF_SamplesWCFBasicClientUsingUsing).

MS proposes their own solution (read it here):

var client = new SomeServiceClient();
try
{
    var response = client.SomeServiceOperation(request);
    // do something
    client.Close();
}
catch (Exception)
{
    client.Abort();
    throw;
}

While this is correct way it is too much code, especially if you put catch blocks for Communication and Timeout exceptions as recommended by MS. Guys over internet propose other solutions, like wrapping the call or extension methods.

Here is my solution, which is nothing new, but just slightly modified version of best proposed answer on SO:

Elegant example of usage with return statements:

return Service<ISomeServiceChannel>.Use(client =>
{
    return client.SomeServiceOperation(request);
});

And the solution itself:

public static class Service<TChannel>
{
    public static ChannelFactory<TChannel> ChannelFactory = new ChannelFactory<TChannel>("*");

    public static TReturn Use<TReturn>(Func<TChannel, TReturn> codeBlock)
    {
        var proxy = (IClientChannel)ChannelFactory.CreateChannel();
        var success = false;
        try
        {
            var result = codeBlock((TChannel)proxy);
            proxy.Close();
            success = true;
            return result;
        }
        finally
        {
            if (!success)
            {
                proxy.Abort();
            }
        }
    }
}

And some bitterness for the end. It doesn’t look like Microsoft is in a hurry to fix Dispose while they should accordingly to their own guidelines. But even knowing this I still like “using” and will probably be stick to it for smaller things. You see, my problem is that I have never-ever experienced inconveniences or issues because of this.

Is it same for you or do you have a story to share with me/others in your comment? :)


No comments


GMT vs. UTC and Time Zones in .NET

May 26, 2013 .NET, C# No comments

Recently I had correspondence with HR from Great Britain. In one of the e-mails I wrote “16:00 CEST (UTC+2) would work for me” which confused the guy, so he asked what GMT UK time it is. If I was too much pedantic I could have replied that GMT is ~same as UTC and that in GMT it is 14:00. But of course it would confuse him even more. I replied with “3PM” as it was corresponding time in UK.
Problem is that 3PM (or 15:00) is not GMT time, but rather “GMT Standard Time + Daylight Saving Time” and when you look it up it is better called BST – British Summer Time. On the other hand I also understand that for many people it is much easier to refer to their time zone as GMT (maybe for historical reasons).
I wouldn’t write this blog post if confusion was only in heads of ordinary people. Unfortunately big enterprises and small startups still frequently fail to write proper time zone handling in their applications.
Lets start with this: We no longer argue whether Earth is orbiting Sun or the other way around, the same way we no longer depend on some astronomical events to measure time, although none would like if at 1PM it was night. There is atomic clock invented which is ultimate truth of time, but since Earth is not spinning that precisely Coordinated Universal Time (UTC) has been developed. GMT is historical term and it would be great to leave it aside.
If you want to understand modern time measurements I would strongly recommend to read these two articles: Coordinated Universal Time (UTC) Explained and GMT and Other Time Systems Explained.
Now bit more for not so ordinal people
When it comes to source code things are not getting much cleaner. Answer to question “Difference between UTC and GMT Standard Time in .NET” at SO:
GMT does not adjust for daylight savings time. You can hear it from the horse’s mouth on this web site. Add this line of code to see the source of the problem:
Console.WriteLine(TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time").SupportsDaylightSavingTime);

 

Output: True.
This is not a .NET problem, it is Windows messing up. The registry key that TimeZoneInfo uses is HKLMSOFTWAREMicrosoftWindows NTCurrentVersionTime ZonesGMT Standard Time
You’d better stick with UTC.
And I partially agree that it is Windows messing up for few reasons. If you look at corresponding to registry entry “GMT Standard Time” UI:

image 

you will notice that it is displayed as UTC, but it is also DST adjustable. Now when you read this MSDN page about TimeZoneInfo, you will get an impression that “standard times” are not DST adjustable, but when converting in .NET it actually takes daylight into account. Concluding I’m afraid that when dealing with time zone conversions we have to be very cautious.

Conversion itself can be done utilizing class TimeZoneInfo (same link again):

 

TimeZoneInfo GMT = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
DateTime postDateUtc = TimeZoneInfo.ConvertTimeToUtc(dbRecord.PostDateInLocalLondon, GMT);

And please be careful. You would need some exception handling and be ready for not-existing or ambiguous time. For example, see how this:

TimeZoneInfo GMT = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
DateTime notExistingInGmtTime = new DateTime(2013, 3, 31, 1, 30, 0, DateTimeKind.Unspecified);
DateTime dateInUtc = TimeZoneInfo.ConvertTimeToUtc(notExistingInGmtTime, GMT);

would throw an exception. Reason is that there is no such time as 1:30AM on 31 March 2013 in London.

How to work with Time, Dates and Time Zones in .NET
Everything starts with basics. If you get them wrong how do you expect to write quality code? It is not a shame to read again about DateTime or even Boolean. Deep inside there is always something hidden – it just depends on depth.
In my career I’ve experienced quite many (as for such fundamental concept) different problems and inconveniences because of incorrect handling of time.
My rules of thumb:
  • Always persist date and time in UTC, otherwise save offset, but never-ever local time
  • Use DateTimeOffset – it is DateTime v2, otherwise at least make sure to avoid DateTime pitfalls
  • Be explicit about TimeZone used, in APIs I would also call date&time fields with suffix “Utc” (ugly?)
  • Convert to local time just before displaying
  • … and check for best practices over internet
Before finishing this post I would like to mention I have a task for myself as well: exploring Noda Time. If you haven’t read What’s wrong with DateTime anyway? you should!
… and, sorry but had to copy one final issue…
If it is Coordinated Universal Time, why is the acronym UTC and not CUT? When the English and the French were getting together to work out the notation, the french wanted TUC, for Temps Universel Coordonné. UTC was a compromise: it fit equally badly for each language. :)


No comments


NDepend – a great tool to know more about your code

April 12, 2013 Tools 4 comments

I’ve always been working in enterprise projects. They usually involve tons of code and sophisticated extensive dependencies inside of code base.

On the other hand I’m keen on keeping code as clean and simple as possible. But how do you find problems quickly within huge set of solutions/projects/assemblies when lot of teams work on those? You have no idea who writes good and who writes bad code or where to look for potential bugs or ugly design.

When you have to analyze a lot of code there is no better static analysis tool than NDepend. There are quite a lot of tools which could perform some analysis here and there, but biggest advantage of NDepend is that everything is in one nice package.

Probably the most exciting feature of NDepend is Code Query LINQ. It allows you to write your own customized queries. Want to see all methods that have cyclomatic complexity higher than 5 and with more than 15 lines of code? Not a problem. Just run this:

from m in JustMyCode.Methods where 
  m.NbLinesOfCode > 15 &&
  m.CyclomaticComplexity > 5

select new { m, m.NbLinesOfCode, m.CyclomaticComplexity} 

As easy as that. Double click on a method and you are already editing it in Visual Studio.

I also like that tool provides analysis on different levels of details. On bigger scale you can identify problematic assemblies. For this purpose there are couple of features. One of them is “Abstractness vs. Instability”. It generates great image with distribution of your assemblies.

Image below was generated for one of projects I’m working on. If most of your assemblies fit into green zone than there is a good balance between abstractness vs. instability. I’m proud to say that code which I write always is in “green zone”.

image

I went through few of our projects and indeed projects with problematic code base is usually close or is in orange zone. It can be considered bad if you are in “Zone of Pain”. Scott Hanselman has nice post on this and NDepend in general called “Exiting The Zone of Pain – Static Analysis with NDepend”. Check it out.

Another high-scale features would be “dependency graph” and “dependency matrix”. While first one is something that comes with VS (well Ultimate), second one is more sophisticated and not found that frequently in other tools.

image

This feature gives you complex matrix of all dependencies all the way between assemblies. You can expand it to classes and even methods. On the picture above a dependency cycle is shown. What is great about NDepend is that it always explains in plan English why and what is shown. In this particular situation there was cycle dependency because compiler generated help class for linq query, so I ignored it as I cannot do much about it. But you never know, next time you might have a problem with your code.

When you run analysis NDepend would check against built-in code quality queries. What you get is something as below:

image

When you click on items on the right you get detailed list of matched classes/methods so you can go through them and verify if anything has to be changed. To be honest even that I’m very scrupulous when it comes to code quality, I discover a lot of new things for myself.

For example I got this in section “.NET Framework Usage”: Collection properties should be read only with an explanation from MSDN:

// A writable collection property allows a user to replace the collection with

// a completely different collection. A read-only property stops the collection

// from being replaced but still allows the individual members to be set.

// If replacing the collection is a goal, the preferred design pattern is to

// include a method to remove all the elements from the collection

// (with a call to the ICollection.Clear() method) and then re-populate the collection.

Of course it makes sense, but I just never thought about it. And there are many-many other things which you can learn from the tool only by using it.

During my working experience I started to think that people tend to create too many projects in VS when they finally feel comfortable with doing so. I like when there are as few assemblies as possible. Folders/namespaces are very good logical separation of code, there is no need in assemblies A, B and C if they always run in same application domain and depend on same stuff. NDepend team advices this and also reasons about it. You can read their “white-books”.

Other cool thing about NDepend is that it can be integrated with Visual Studio and Reflector. When you run NDepend it provides you with start page which proposes these add-ins for you. This is very handy.

It is natural that NDepend has console so you can run it from you scripts.

You can see complete list of NDepend features here: http://www.ndepend.com/Features.aspx

I’m afraid that my thoughts were somehow not well structured, I just picked some of the capabilities NDepend has and did not talk much about different use cases, but don’t worry. You will find answers to all your questions on web site: www.ndepend.com/

In my current company NDepend is integrated in build process, in my previous company I used it occasionally to see how we progress over time. Big companies usually take code quality seriously as smallest design flaws now could mean a lot of money leaks in future. Of course everything boils down to employees, but if they have right tools at their disposal you are protecting yourself. This great tool has a price that for sure doesn’t break the bank especially for company that claims to ship high quality software.


4 comments


IIS Logging hints: (Log Parser + Log Parser Studio + IIS Advanced Logging)

February 18, 2013 IIS, QuickTip, Tools 1 comment

Rather than starting this blog post with first excusing about me being not much into IIS. I will share very simple but extremely powerful toolset to be aware how your web application is living its life.

Of course any good application has exception handling and logging in place therefor you know when “shit happens” and possibly able to dig into it, find root cause and fix. Great! But what if you want to know more? What if you want to see some graphics showing distribution of users, their favourite features, pick hours, etc? To some extend Google Analytics could satisfy your needs. I use it for this blog and it is absolutely brilliant there.

You could have better tool in your hands? Plain simple. Plain power.

First. Enable your IIS Logging

To enable IIS logging use this boring step-by-step explanation. Or find this self-explanatory nice pictogram

image

in IIS manager. After enabling it in actions section your logs will be collected accordingly to configuration. (Say for application with high load you might want to change configuration to generate a new log file for each hour.)

Second. Analyse what’s inside

Well, first step could be considered as waste of keystrokes for some of you as you find it natural to have IIS logging enabled. But I also know that there are applications running for which no one ever collected any logs and have only preliminary idea how their applications are used and what is happening at all.

Here is bit of my story: We develop HTTP API used by various front-ends. Now we rewrite one of our heavily used endpoints. Therefor it was needed to know usage patterns (GET method parameters) and picks. I was able to quickly find everything out. The most time consuming was to download all those gigs of logs. But as soon as they are easily accessible, everything is piece of cake. Just continue reading…

You would need some tool to start analysing your logs.

Best fit would be Microsoft LogParser. Download it. It is console application which allows to query stuff with SQL-like queries. I said “stuff” because it is not only logs. Have a look on this LogParser architecture diagram:

logparser_architecture.gif

Output could be also charts (though there is dependency on MsOffice). For example this could be chart of non-200 status codes:

clip_image001

You can utilize this to to build nice reporting system with graphics to be sent to development team and/or managers.

Log Parser Studio

What if you want to quickly analyse something without bothering with console app?

There is Log Parser Studio – an excellent and handy tool.

image

When you just started it library of different queries is shown to you along with possibility to search among them. So you have a great starting point for your custom queries.

For example here is simple query I just used:

SELECT QUANTIZE(TO_TIMESTAMP(date, time), 60) AS Minute,
    sc-status,
    COUNT(*) AS Total
FROM *.log
WHERE (cs-uri-stem like '%SuspicionsEndpoint.svc%') and (sc-status = 500)
GROUP BY sc-status, Minute
ORDER BY Minute

I have found this page to be extremely useful as reference for functions in LogParser.

Be aware that LogParser doesn’t support everything available in SQL. When I tried to write something bit more complex like distinct count with grouping it complained. At least LogParser provided meaningful explanation so I knew that feature isn’t implemented. I had to use temporary file to achieve what I wanted.

Third (if you want more from IIS). Install Advanced Logging

You might be in situation when default logging fields are not enough for you:

image

For example, some token information is supplied in http header. No worries – Install IIS Advanced Logging extension. Now you look for this pictogram:

image

Setup and configuration is somewhat more complex.

Here is great step-by-step with pictures: http://www.iis.net/learn/extensions/advanced-logging-module/advanced-logging-for-iis-custom-logging

And here is mine shorter example. Say you want to include custom http request header:

  1. "Add Log Definition…”
  2. Configure it and include few common logging fields and save
  3. Navigate back to “Advanced Logging”, select your definition and hit “Edit Logging Fields…”
  4. Add logging field:
  5. image
  6. Use it in your definition
  7. Enable your definition for web site (if not yet enabled)

There you go. At this moment you can analyse even more information with Log Parser or nice Log Parser Studio.

Hope this post is of help for those who want to know more about their application!

Quick links:


1 comment