December 29, 2013 YearPlanReport 2 comments
December 29, 2013 YearPlanReport 2 comments
Year 2013 became life changing for me again being the 3rd year in a row, when I say this.
At the beginning of the year I knew that we are waiting for the baby. I decided on changing my job and approximately at the same time when my daughter was born I changed my job. Now I work for UN associated organization and I started working on something interesting – an offline capable web application written with EmberJs.
My plan for the year 2013 was quite extensive and had 21 items. I’ve achieved more than half of that but still much wasn’t done. Interestingly things not done are mostly skills related, which should probably keep me alerted.
Now a bit on each item.
The best thing which could happen. My daughter was born on 10th of June. Here are few pictures.
Now she occupies tons of my time. But it is not an excuse it rather has to be reason to do more!
Travel a lot. We definitely travelled a lot year. Because now we have small baby at home we are somewhat limited in distances we could travel. Thus year was mostly Austria explorative. My wife writes a blog post for each of our trips to different attractions.
Buy a car. I bought Ford Focus Traveller with big boot. Now we need one. It is diesel car so driver experience is somewhat different, but on other hand car proves itself great for long trips. Also I already took car for 5 times to Ukraine this year.
Ski high in the Alps. Not that I skied much this year. But I have a picture that proves that I skied in Alps at hight altitudes. Taken in Obertauern.
Learn German for real A2. I think I’ve failed here. No real need in communication in German. But I’ve attended A2 course so maybe I’ve learned something. At least for sure there is improvement when comparing to 2012.
Improve English fluency by applying more synonymous and idioms. Maybe. Now I work at UN where I have to collaborate with different people from all over the world in English, including native speakers.
Perform well & keep being challenged at work. I’ve changed my work. Now I’m self-employed and work by contract for UN associated organization through the other company. I’m happy that I’m quite challenged now, mostly thanks to interesting project and Iraqian boss.
Contribute to open source. Fail. One gist doesn’t count.
Deliver many technical presentations. None delivered. Instead I performed quite few presentations to our users. I even had to wear suite.
Extend social network at work & outside. Mostly failure here. My exposure has changed now. I feel myself somewhat in very closed community of developers.
Write some web project. I do this now at work all days long.
Do programming in other languages than C#. Yes, now I mostly program in javascript.
Take part in one or few programming contests. Fail, except of some TC single round matches.
Visit one or few conferences. Fail.
Improve blog quality. Fail, since nothing has changed on this blog and post frequency is low.
Write at least 41 blog posts. Fail.
Increase community visibility. Fail.
Read as many books as I like. Well, this couldn’t have been a fail.
Consistently do exercises. Fail.
Reach 2013 reputation at stackoverflow. Fail.
Earn 2013 euro outside. Since now I’m self-employed and earn significantly much more than before. I would say that here I’ve oversucceeded here.
Generally it was very good year. I’m very happy because of my born daughter. She is great. Next year we will start learning programming and travel a lot together.
Unfortunately it is very likely that whatever I say is just like on the picture below:
Nevertheless, I wish you all
HAPPY NEW YEAR!
December 7, 2013 EmberJS, JavaScript, Web No comments
I would like to show you how Chosen can be quickly integrated into your EmberJs application together with Twitter Bootstrap.
If you just want a solution, here is my gist: https://gist.github.com/andriybuday/7849057
Otherwise read a short story with some comments and “excuses” from my side.
I’m currently working on web application. We use JavaScript MVC web framework called EmberJs. It is very cool framework, and I will write about it more in the future. Ember has small set of views and input-helpers. Just using them is not always enough to build solid and rich application. Fortunately there are tons of controls available online, and it is quite easy to write your own controls with Ember.
Most of online available controls/plugins are based on jQuery (no surprises, of course) and they use plain javascript objects. Ember wraps javascript objects into Ember.Object, so it allows for data binding, data tracking and other advanced features, but on other hand it makes impossible to use vast majority of web components right away. You need to adapt them in order to to use them with Ember.
Having component created with Ember would result in application-specific html-tag, that would use JavaScript logic defined by you. Something like: <my-own-html-tag… that does and shows what you want.
Chosen. One of the controls we wanted to use was Chosen. “Chosen is a jQuery plugin that makes long, unwieldy select boxes much more user-friendly.” It allows you to have nice multi-selects that look like one below:
I’ve found a quick way to integrate chosen with Ember. As per me easiest way would be to utilize existing view called Ember.Select. You can embed it into your new component.
To be completely fair, my solution is not perfect, since I needed to hack html generated by Ember and manually handle selection/deselection of elements from the list, but solution below allowed me to achieve results fast without much code.
(Other option would be to avoid using Ember.Select and then play a lot with defining proper view for your component.)
If you are one of my constant readers, it might be bit surprising that I’m writing about web, and not even from .NET perspective. But believe me, you can expect more. I wanted to do more programming in other languages. This is why I struggled to try many programming languages. But thanks to some coincidences I currently code in javascript most of my time.
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.
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.
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.
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.
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.
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.”
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.
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 ;)
November 21, 2013 Book Reviews, Success 2 comments
Can 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:
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.
November 13, 2013 Errors, Security, Windows, WPF No comments
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
|
Dell Studio XPS 1647(+upgrades) |
Dell XPS 13
|
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?
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.
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.
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.
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.
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.
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.
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!
June 23, 2013 Book Reviews, Career, Success No comments
“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.
“ 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. ”
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? :)
May 26, 2013 .NET, C# No comments
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 TimeYou’d better stick with UTC.
Conversion itself can be done utilizing class TimeZoneInfo (same link again):
And please be careful. You would need some exception handling and be ready for not-existing or ambiguous time. For example, see how this:
would throw an exception. Reason is that there is no such time as 1:30AM on 31 March 2013 in London.
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. :)