August 29, 2010 NHibernate No comments
August 29, 2010 NHibernate No comments
Few days ago I’ve faced with duplication of data in XML we send to vendors and it leaded my to basic understanding how fetching works within NHibernate.
Database
So to make things clear we will start with ever simplest database layout and few datarows as on picture below:
I’m using following code to test our activities.
It fetches Customer with passed in FetchMode and then uses Orders to examine how lazy loading works.
Then I’m calling method for each of the FetchMode in separate sessions like below:
Mapping of the Customer
Generated SQL-s
NHibernate can generate two types of fetching: either join or either separate select statements. So our code generated three join statements for Default, Eager, Join. Also two calls to database with two selects for the Lazy and Select. So all FetchMode except of Default are overriding our Customer mapping.
Join SQL
There is one thing you should remember about such kind of fetching – you will get duplication of the entities in your collections. You should apply joining when you are going to have some specific restrictions in your query.
Duplication of entities:
On the picture above you see two customers, which are the same references and represent same customer with same id = 10. To eliminate this issue you should apply one of the fixes: use distinct, use subquery or filter entities in client code. This article should make this more clear.
My recommendation is never use “.FetchType.Join()” in your One-To-Many relations as I did that. Better let NHibernate do it by default. Nhibernate applies Join to Many-To-One relations and Select to One-To-Many.
In my case better use following:
The less you write code – the less mistakes you do. :)
Two SELECT-s
This type of query is generated if you have Select() fetch type. If you have LazyLoad in your mapping second select will be executed only on accesing of the Orders property of Customer. In other case (Not.LazyLoad) it will be executed immediately on fetching Customer.
Hope this brings some light. At least for me it does.
August 25, 2010 TDD, TeamWork, UnitTesting No comments
Few days ago I worked few hours on Sunday, so there were only me and one of my co-workers in the room. He is Delphi guy, but likes to learn .NET. He had to implement some custom resizing logic for the report and he asked me if I can help to think on the logic. We had spent maybe couple of minutes before we got some preliminary ideas.
Let’s do Pair Programming
We decided to implement some prototype/logic within .net. I suggested pair programming with TDD: “I will be writing tests – you will be implementing logic to make them work”. BTW, do you know how do we call this particular programming pattern? – It is called “Ping-Pong Pair Programming“.
So after I created basic test project and wrote a test that simply has something like “var report = new Report();” and then “report.Draw();“, which of course is failing UT, he proceeded with creating class for Report and putting in place stub method Draw. Then I added functionality that allows adding report columns, then sizing of them, desiredMinimalWidth and delimiting width. Then UT that verifies if we correctly resize columns, if they fit or do not fit into report. Misha was performing extremely well in implementing logic, we had been thinking on. At some point of time he got stuck, so we continued together on making latest UT work.
I enjoyed this try of doing Pair Programming along with TDD.
What are benefits of doing PP as per me?
Are there disadvantages?
It might happen that PP will not be feasible, especially in situations when problem they are trying to solve is trivial or when one of contributors is not interested in going great job. You can read lot of discussion over the internet about the time PP consumes and the quality of the work. Most commonly you will hear that when doing PP it takes +15% of time if two developers work independently and produces 15% fever bugs.
What are preconditions on doing Pair Programming as per me?
In my further professional growth I will try to involve more people in this practice!
August 24, 2010 Career, Success 21 comments
I’m confident that every smart human should have a plan for life, part of which is a career plan. Most of us spend more than half of our lives working. Did you ever think about that? We spend hours working on some projects, solving some problems, interacting with colleagues, creating and modifying things. Are you dedicated to what you do? If no, I have a question for you: Why do you work on xyz? Really! You may say that you could possibly work with more pleasure on another job. If that is your answer, why don’t you plan to change your job?
If you are dedicated to your work, I would assume you want to grow. Right? Do you have an idea on how you should proceed to reach your goals? Do you know exact steps to take and your knowledge gaps to overcome? No? How then can you be sure that you will grow to more respectful position, a position in which you are recognized and admired?
I always ask people about what motivates them and what they would recommend me to do to motivate others. Answers I get are different in formulation, but they all have the same core elements behind: possibility of career growth, recognizing, achievements, possibility to chief. Main question to you is this:
What do you do to reach your professional and life goals? Do you have a plan?
If you are not sure about what you do or what you should do, it is exact time to build your career plan.
Career plan is list of positions and actions you should take in time to reach your short- and long-term career goals.
First of all, building a plan is a great exercise and a process of establishing steps you should perform. The process itself allows you to have a critical view on your current career situation. You should know where you are right now, where you want to be and what are your abilities/skills. Answers for those questions are prerequisites for building a good career plan. If you have no clear vision on where you want to be, don’t be upset. Work on that. Try to write a few words that describe you after you as if you already reached your goals. How you see yourself in future might change, but at least you have some kick-off list. For me the list is something like “MVP, Consultant, Architect, Author, Community developer”. Also thinking out loud: “own company, another country, being manager, etc”
After you have some preliminary plan, you can refine it by removing less important items and by adding some additional ones. Also you can rethink some things and then rethink again and rethink few more times. In the end you will have some kind of more or less good plan. But do not expect it to be you final plan. I would say that you should always take a look on it and consider if anything requires improving.
After creating your personal career plan you will be different from your co-workers, who just continue to work blindly. There are people who work just to get enough money for a living. This cannot be considered as success, clearly not for me and hopefully not for you. Some other people probably think that simply working hard will lead them to success. Hey guys, just don’t think so! Yes, you are right that hard work is needed and respected, but there are definitely other things you have to add to bake a cake!
Once you have established where you want to be it is time to understand the path.
Normally positions for Software Engineer start with these three:
This is the most general part of a path I see in all software companies. What do we have after that? It really deviates from company to company, but generally speaking this depends on the factor of your interaction with other people, with technology and with the company.
The more you interact with people the more you become leader of team, say Team/Tech Leader. The term might differ, but I like the “Technical Team Leader” one. Even more, if you would like to take more responsibilities you can switch to managing positions and become a Project Manager right after being Tech Leader or Senior Developer.
The less you interact with people the more you become an expert (it is even possible to have such position officially in tech industry). Expert is the person with whom others consult and get advise from.
The more you interact with a company the more you become CEO, but depending on your company’s size you might have few more steps here. Of course, position’s title can differ as you climb the career ladder.
Summarizing, your further steps are in one of the following areas:
Why did I say “positions path”? Because this is not whole representation of the path. A good path should also go through you own personal ambitions related to your job to lead you to the established goals. What do I mean by this? Since I want to be recognizable community developer and known over the world, I should commit a lot of efforts in maintaining this blog, in speaking at events, etc. This has no explicit impact on my career growth, but believe me it has huge and tremendous indirect impact. Also, I would love to write a book and I’m planning on it. I still do not have a clear idea on what that book will be about. I only imagine something either on tech or on success. What matters is that I’ve planned it and I’m proud of it. Some remark goes here. I mentioned about this to my friend and he was laughing at me because I want to write a book and planned it but I do not know what about. I can express my arguments against it here, but would love to hear from you. [Edit 2015-Sep-16: I’ve released a free e-book on design patterns in my native language in 2012.]
My company as one of the leading outsourcing companies in Ukraine is trying to make employees happier with helping them in their careers. They create more positions and they also establish processes that allow employees see where they can move. (I hear you scepticism here…)
It is well known that one of the biggest motivation engines is visibility of a career growth. Since I’m considered to be a perspective employee (at least my employer thinks so), me with my company almost finished building my personalized Career Plan. It is the path with steps I should take to move from one position to another.
Of course, the company doesn’t care about my non-career goals even if they are dedicated to my personal improvement. It is the reason why the company has only included official positions in my career path. Highest position they’ve planned for me is to be one of the tech chiefs of one of the divisions. Highest position means a lot of interaction with clients and huge responsibilities in developing and advising on solutions. But it doesn’t include any of my desires to become community developer and stuff I would like to do to achieve my other goals.
So here I will present my own Personal Career Plan that also includes a lot of other things. I would recommend you to build something similar. On the left you can see path I built combined with some positions, certificates (officially needed for those positions). On the right side you can see my table of “Where do I want to be in a year“. List of “where I want to be” is really powerful tool if you keep doing it year after year. (here is list for 2010 & here is list for 2011) [Edit 2015-Sep-16: To see complete list of year plans click here.]
You must be thinking now: “Boy, hold-on, hold-on! It is way too optimistic path. Are you kidding?“. I would answer “Shut-up! I know my path and will do my best to stick to it. And, btw, where is your plan?”
Even I realize there is some overestimation of my possibilities/skills/efforts I would love think I can do all of this. Thinking in such a way is movement to The Success!
[Edited 2011-Jan-10: grammar fixed and few links added]
[Edited 2016-Jan-20: some grammar fixed]
As this post receives a lot of traffic, I decided to fix some grammar. I’m not changing the story though. I want to keep it the same so I can compare my old plan with my current achievements. Probably it is something you would like to know as well. Therefore I’m planning to write a follow up post in coming months.
Just for fun, here is my 2021 career update: I’m a Senior Software Engineer at Google working in Vancouver, Canada. Before Google I worked for Amazon as SDE3. I don’t know if this is an indication of any success or progress. I definitely had greater plans for myself in 2010. My ambitions subsided significantly and I tend to appreciate diversity of life much more than before. I feel like I probably need a new plan.
August 23, 2010 Book Reviews, Success No comments
I read this book on the fly. Couple of hours and done. Book is written in very specific way, that allows to read it quickly. It spreads very interesting ideas.
One of the main concepts is that you are General Director of your life and your name’s company and that is real place where you must do the best. You should have something like a new title of your current position in Company-You, like “Catalyzer of progress”.
Book just throws into you lot of gripping mottos that make you double think if you do the right things and if in right way.
Book’s author is “COOL” and he wants you to be “COOL” as well. You should make yourself a “dude with power” and then sell yourself with high price.
For some reason book is also concerned about building professional network. Intent is to be aware of the best people around you, so this could help you move forward. Few weeks ago I started looking around for cool people to have lunch with them. During lunch I’m trying to familiarize with that person and understand what does he thinks about the job. Mainly I talk with Software Developers. To some extent this helps me be known and get interesting information from them. Probably it worth to consider meeting with people of other professions.
Regarding what it talks about your job, ideas are great and are very applicable to my current position and current team work. I would love if we use following motto: “Work with what you have, and make it awesome‘. There is no room for complains, there is only room for getting it done.
Be the best!
August 21, 2010 CodePuzzle, CodeReview 1 comment
Today, I’ve been reviewing some piece of source code, and found way too interesting exception handling approach.
In following code snippet we are trying to wrap existing exception with new one having more descriptive message and saving the stack trace of the original exeption. The way how it is done is just amazing:
I’m not trying to blame someone. But sometimes people see so much more complicated and sophisticated solutions to problems that could be solved with one-two lines, that it makes me think, what we also do such things but on another – higher level.
Developer who wrote this code is trainee, so doesn’t mean low quality of our code, simple he needs more experience. My point is that we are also trainee, but on another level, and we might not see simple solutions as well.
So who will write me one-or-few lines of code that can do the same? Please do not hesitate :)
August 19, 2010 DevMeeting, Presentation, Success, WCF 1 comment
Hello, today I performed presentation on Windows Communication Foundation and it went extremely well. People were interested in topic and it smelled in the air.
Why am I happy with this meeting?
People were listening very-very attentively! It is the best gift to the speaker. Many thanks to today’s attendees! You made this presentation awesome!
What was the agenda?
For today I planned to have “Getting Started” session, where I decided to talk in general what is WCF and then proceed to basic concepts of it, like ABC.
In DEMO 1 (Damn it! Let’s write some code!) I created ever simplest WCF library and simple Contract that exposed todo list functionality. Then I brifly showed configuration and we started wcftestclient.
In DEMO 2 (Damn it! Let’s configure it!) I talked a lot about endpoints and how we can configure them. After I created a lot of them it was highlighted that changing the way how our service works by configuring and not changing the code is the key feature of WCF. WCF is indeed unified framework that allows us has one logic, but different exposing to the real world.
In DEMO 3 (Damn it! Let’s use & host it!) I created very simple console application that was able to send todo item to the service. It went with some exceptions thrown into console, but people liked it and besides after that I created SuperTodoServiceClient and it worked well. Also we voted were do we want to host our service for the long time. Most decided to host it under IIS. Till the actual hosting all went well, but then suddenly it didn’t work under IIS. Reason was very simple – since my machine has brand new OS, IIS was not configured properly.
What’s next?
Also I’m planning to have another meeting on the WCF. This time it will be “Advanced”. In that session I would like to show some real-world examples. Also I’m going to prepare to the 70-503 exam (on WCF), so I might get some interesting topics from the training kit to show on the meeting.
Presentation
More and more I start disliking ppt files. But anyway to have some visual appearance of presentation I created ppt file (maybe finished with it at 5:30 am so don’t kill me if it is “poor”). Btw, having ppt has some plus – I can put my blog’s logo and URL :)
Guys, looking forward to hear from you! Will appreciate any of your comments.
August 15, 2010 Book Reviews, Success No comments
So far I read another book on business and management. Now it is called “It’s Not Luck”, and is written by the author of “The Goal”.
Honestly, I liked this book, less than “The Goal”, because now I knew what to expect. I knew that all of the problems will be solved and that the hero will be promoted to the general director of Uni-Co.
The main and huge difference is that in this book author represent to us new way of thinking to resolve issues.
I will try to summarize it here from my perspective and my understanding.
So, first of all you have some conflict. You write it down with good formulation – that is the main thing you need to resolve. After, you should build some tree of dependent reasons-effects. To do that you need to write them all down and dive into intensive thinking to find out all of the dependencies. Book, states that in most cases reason of the main problem is just one of the reasons, you listed. If you commit lot of effort in building your dependencies tree, your reason will be obvious, so after that, you can proceed with building your plan to resolve that. Plan is path from root reason to the main problem, you should solve.
Book is very gripping and is written in way that gives us touches of both personal and business examples. I liked it, and maybe will try to use some of the technics to solve problems in my life.
August 14, 2010 Career, Success 6 comments
As I promised, here is post on Knowledge Evaluation for the Senior level.
Definition of a Senior Level Developer
In most of the sources, Senior level is defined as level on which person is responsible for building complex components with minimal guidance and being unsupervised. Also person is an expert in language and has experience in business areas. I personally like definitions, where they additionally indicate person’s interest in software and bringing business value to the client.
So, who is Senior Developer?
For me being Senior Developer isn’t just label, that is indicated somewhere in the company by HR. It isn’t only list of responsibilities/duties I will be stick to. It is significant breakthrough in my career, that blesses me to move on. Moreover it is another step to self-actualize myself by accomplishing my life goals. Again, it is part of my RoadMap (I feel, that I need some post on it, but cannot till map is rolled in one or few places.)
Knowledge Evaluation
Except of taking into account my performance, company should always evaluate my knowledge to proceed with promotion.
My theoretical knowledge of programing and language isn’t under question
For me it was good time and my personal outcome for myself is that complete understanding of engineering management and requirements will come only with facing more real world situations, since simple theoretical knowledge isn’t enough.
Feedback
They did not give me official feedback yet, but I feel confident about positive one.
How will I proceed with new position?
First of all I will do all possible to not disappoint my management. Also I will work hard on keeping my brand up to people expectations and higher. Of course I will continue doing more than it is expected from me.
Any congratulations and comments are welcome!
For the Thursday I had nothing planned for learning, since I spent my night watching Perseids out of the city.
Knowledge Evaluations is very close, so I just reviewed all of the items I should know for it.
To lot leave this post empty, I decided to write at least about something. I feel, that I still have some weak areas like Networking. But it turns our that for .NET Desktop Profile, I need only basic knowledge of it, like understanding networking itself, application layer protocols, IP, TCP, UDP, SMTP, and so on and so forth. So for my luck I have basic ideas how all of that works and glues the world together.
Networking
We often use these abbreviations, but do we always know what they mean?
local area network (LAN)
wide area network (WAN)
metropolitan area network (MAN)
personal area network (PAN)
virtual private network (VPN)
campus area network (CAN)
storage area network (SAN)
Simple Mail Transfer Protocol (SMTP)
Multipurpose Internet Mail Extensions (MIME)
User Datagram Protocol (UDP)
… what more??
In the evening there will be post about how KE went and what are outcomes.
P.S. I feel myself very nervously at the moment…
August 12, 2010 Career, CI, Opinion No comments
For today it was planned to learn SQL and Continues Integration. In this blog post I’m going to express few thoughts on Continuous Integration. Only thoughts, because you can read comprehensive articles on it over the internet, like this one written by Martin Fowler.
My definition of CI:
![]() |
I took picture somewhere from web, since I like how it illustrates CI |
Few main suggestions on introducing CI:
And some thoughts about blind architectors
When, I came to the project and I faced lot of difficulties that project had, like having sources under different repositories, having not automated procedure of builds, also when someone failed build, everyone knew about that next day and all QA work was stopped; lot of complains about merging sources; dry applying sources to diff versions procedures. None knew what is going with project till next day! I was junior at that moment I did not know about CI, but, hey where our architects have been? Thanks to efforts of new fresh architects we’ve got CI and it applies to our project very smoothly. What is left is to convince devs do committs more often and cover everything with Unit Tests. (But that has also something to do with our project specifics.)
Why didn’t they consider introducing CI earlier? This is mysterious question, I do not understand. There should be definitely something significant (like CI) that we can improve!