What the hack is NuPack

October 17, 2010 Uncategorized No comments

 

NuPack is package manager for .NET introduced to help developers easily work with 3rd party libraries.

Here is great post on NuPack, I would recommend to read.

But as I promised in twitter to have blog post called “What the hack is NuPack”, I need to post this.

So,… downloading…

image

After it get downloaded and installed, we have one additional menu item in same place where we do have “add reference”:

image

So what does “Add Package Reference” do?

It takes a look on the feed for packages, where you see 3rd party you can add. On the picture below I just added AutoMapper, by clicking “Install”.

SNAGHTML65533ec

I can easily search for other components and install them. On the picture below I easily searched for my favorite ORM – Nhibernate and installed it. But if you ever worked with it you know that it depends on few other 3rd party, such as log4net, etc. Great news! They all get installed automatically.

SNAGHTML658fe5c

Physically it puts config file within your project and locate all your components under folder ”packages” along with your solution file, like below:

image

After that I got interested to know how it behaves with couple of solutions all in SAME folder, and figured out that it works just fine – it puts everything into same folder.

Everywhere I read about nupack they all declare that it is solution related, so I have one folder for solution. But as you may know I work with enterprise project and we keep all 3rd party in separate location where dozen (20-30) solutions are looking for references. And it looks that I do not have possibility to configure NuPack to put “packages” folder in another place. Or I’m missing something. Please let me know.

EDITED (Oct 17, 11:39PM): I already got an answer for my question:

image

So to shortly summarize:

NuPack allows you easily fetch whole range of different 3rd party components and momentarily add references to your projects without need to manually go and download them, then unpack and reference. Also NuPack allows you easily manage all of your components, allowing you update them and do other cool stuff. Go and check it out!


No comments


Is this blog succeeding? Some statistics

October 17, 2010 Uncategorized 2 comments

I guess all bloggers know about such things as Google Analytics and Feedburner. But if you are not blogger, in few words those are statistics engines analyzing site’s visits. I’m keeping eye on statistics and here just want to share some information and thank you all.

Here is where from you all guys are:

image

Just another more deterministic representation of the same information:

image

Sadly, but I turned on Google Analytics only in the end of this summer, so pictures above do not represent whole life-time of my blog.

But feedburner states following about my Subscribers:

I have 30 readers on average for the whole time of existing of this blog. Most recent average numbers are near 50.

image

Also accordingly to feedburner I have:

  • 4,940 views of 97 items
  • 3,008 clicks back to the site on 105 items

Also I have 256 comments.

All of this shows me that my blog is getting more popular and it continues paying me back…

Thank you all guys for interest in this blog. I will do my best to keep it up and running by posting high quality content and the most needed information to help us reach success in this epoch of software development.


2 comments


Continue sharpening your English: English as a Second Language Podcast

October 17, 2010 English 1 comment

I have few posts on learning English and its importance for software engineer. For example my article “English classes in outsourcing company” became very popular for some reason, at least feedburner states that it was viewed 130 times and I got some feedback from at least 4 people on that post.

This post is also about English but this time it is very short. I just want to recommend one of the English podcasts. It is called:

English as a Second Language Podcast

I’ve been listening to this podcast for a few weeks and I would say that this is great and awesome tool to learn English and to understand lot of worlds usage deeply. I’m listening to it when getting to the work and back from it.

Ok, for example, do you know what does “to pimp the car” means? Ok let start with noun – “pimp”, which means bad guy who supervises prostitutes, but when we use it as verb it could literally mean to do what pimp does, but in application to car it means to add many different features to it and make it looking awesome or maybe not really awesome. You decide: Google search images

And that is not all – podcast just brings lot of interesting stuff you may learn to better understand not only English but USA as well, also differences between British and USA English.

Guys, from ESLPOD thank you very much!!!


1 comment


Interview. Job of dream. Cheese, money and happiness?

October 17, 2010 Career, Opinion, Success No comments

July 25, I wrote blog post called “Interview” and I mentioned that maybe in year term will post yet another blog post with the same title. Now I’m writing post with almost same title. Is this due to the fact that I had interview again? –Yes and no. Actually I had two interviews since that time and did not post about them, and I will have two more interviews next week.
Real reason for this post is to extend the “Remember that you are also interviewing” section. I want to hear what you guys think about what we should ask on Interview to ensure that we get job of our dreams.

Job and happiness

I’ve been trying to find out for my-self what is the job of happiness. What does bring satisfaction from what we do.
I did not read huge range of articles and other resources on this theme, only couple of them. But besides of them I have my own opinion on this topic and will try to express it.
For example, this article states that connection between good job and happiness is overrated (?). As I understand from that article more evident role in job satisfaction is your own optimistic mood, which can be developed not only at your work but at home with you family. I agree with this, I now see that when I have better relations with my girlfriend I do have better desire to work. Also I disagree with this, because I think that everyday activities play very evident role in my satisfaction of my job. Currently everything is more or less good, but I do not get enough “I love this” work.

Cheese

But on other hand are you sure that your cheese is not getting old? And are you afraid to move to other position with new cheese? You have to read “Who moved my cheese?” This book brings into light some very important aspects of human fear to change things around even if their cheese is getting old or even if someone has moved it away. And I understand why those people are afraid. Guys like, Bodo Schaefer recommend to have something (ok, MONEY!) to ensure that you are safe. So unless you bought car or house in credit you are safe and can easily move to another piece of cheese. You know, I agree with them. I cannot buy house here in Lviv for money that I have, maybe some small car, but money that I have with bank interest and including my outgo is enough to live maybe 1-2 years without working at all. That is why I’m not afraid at all. And I would recommend you the same if you are still young – do not buy anything that is expensive and there should be NOWAY for credits!

Money table

Use following money table to find out if you have enough to feel free moving for better cheese; I have it automatically calculated in Excel spreadsheet:
You can put as Deposit MDeposit (e.g. 10000) -be honest
You need per day PerDay (e.g. 100) PerMonth=PerDay*30 -calculated
Per day to be happy PerDayHappy (e.g. 500) PayMonthHappy=PerDayHappy*30 -up to you
Ave. bank interest InterestRate (e.g. 0.12) MInterest=YouHave*InterestRate/12 -depends on banks
You are safe: YouAreSafe=PerMonth*6 YouHave > YouAreSafe ? (“you are more or less in good situation”) : (“Hey man, do you think about the future?”) -if you do not have enough to live half a year, something is definitely bad with your budget
You can live without need to work YouHaveEnough=PerMonth*12/InterestRate YouHave > YouHaveEnough ? (“you can stop working without impact on your life”) : (“it is too hard to reach this since needs often increase ”) months you have to wait to reach this goal:(YouHaveEnough-YouHave)/(MDeposit+MInterest)
You are free, or even rich YouHappy=PerMonthHappy*12/InterestRate YouHave > YouHappy ? (“hey! you are rich”):(“almost none reach this, since they start spending too much when they have enough”) months you have to wait to reach this goal:
(YouHappy-YouHave)/(MDeposit+MInterest)

What do I recommend to help you find out if some job is for you?

Create description of your dream’s job in couple of sentences. Then try to build questions that will help you correlate their offers to your dream.

Job of my dream

I work with newest technologies, designing and constructing architecture/technical approaches with professional team. In my team I have world level professional(s) from whom I can learn something new and really valuable, at the same time I see them and/or other team members to learn from me. All team members are open-minded passionate developers/QA/SM/PO. I’m more or less independent in my work organizing; customer trusts me, so I can do the best for them without their direct interventions. PO, representing customer, really knows requirements and goals of project and doesn’t push team to figure requirements for them. My employer is not afraid to invest money into refactoring/research and into team needs. They express respect to their employees and listen to them. They keep an eye on the project’s future and employees satisfaction, they do the best to keep employees motivated. Employees at the same time are really dedicated to help their customer/employer reach company’s goals.

Questions:

  1. What do you like about working for the X company? Why should I like it as well?
  2. What is the overall goal of the project I will be working on?
  3. Is project new? What are terms and team size?
  4. What are my duties for this project? In percents?
  5. What are the most challenging aspects of this position?
  6. What technologies will be used?
  7. Do you use recent approaches in software development?
  8. How to you measure code quality? Unit Testing? Code Coverage? BDD?
  9. Would it be possible to see piece of already written code?
  10. What methodologies are used for this project?
  11. With whom will I be working most closely? What is their professional level?
  12. Who is my supervisor? To whom would I report?
  13. Will I supervise someone?
  14. Are you interested in my professional development and how will this appear?
  15. Do you invest in refactoring/research?
  16. Do you accept initiative from your employees?
  17. Will I have many meetings per day?
  18. Is there anything else that prevents you from hiring me?

Also I was looking for some other good lists of questions. One is more general and other is awesome list of questions from stackoverflow.

Awesome questions list from stackoverflow

Here below in dark-blue is complete list of questions composed by Rob Wells on stackoverflow. This is copy-paste (!). All rights are reserved for stackoverflow and I do not pretend to be author of any part of it. Please follow this link to see original question.

Questions for development:

  1. What software development methodology do you use, e.g. Waterfall, Agile, Scrum, XP?
  2. Is training provided for the methodology being used?
  3. What parts of the software development life cycle do developers do?
  4. What is the breakdown of a developer’s day, e.g. how much time for support or troubleshooting, how much time for coding, analysing requirements, etc.?
  5. How long does your design, code and test cycle last? Less than thirty seconds, less than five minutes, less than ten minutes, etc.
  6. Do you encourage refactoring if sufficient unit tests exist?
  7. What test bench do you use?
  8. Do you have coding standards?
  9. Are the standards revisited or are they just left, as written, i.e. “carved in stone”, in 2001?
  10. Do you allow time for peer reviews of code?
  11. Can you give me an example of a code review that is done here. Are there different levels of a review, e.g. new system is handled in a day long explanation compared to a quick bug fix that is needed ASAP.
  12. Does the project use continuous integration?
  13. (If they use continuous integration) does your software build and test cleanly right now? What’s the current successful build rate?
  14. Does the project have regular regression testing?
  15. Are metrics kept for the code base? SLOC? Numbers of unit tests? Numbers of regression tests?
  16. How are conflicts resolved between testers and developers? I ask this because there have been times in the past where I see finger pointing of “Well, I interpreted it this way and he interpreted that,” enough to make me ask how is this handled.
  17. How are requests for large changes to be done quickly handled? For example, someone requests a web application that would normally take 2 weeks be done in 2 days for a prospective client that could be a big account.
  18. Do you use a software repository? (If the answer is no, walk out).
  19. What is the budget for tools?
  20. Do you offer your developers any sort of allowance to order technical books?

Questions about estimating:

  1. Do you have a standard template for estimating development effort for new work to make sure nothing is overlooked?
  2. A process for obtaining such an estimate?
  3. What percentage of contingency do you build in to your estimates?
  4. Do you allow time to revisit

Questions regarding the team:

  1. What has the team achieved so far?
  2. What has the team learnt?
  3. What aspects of the team would you like to change to improve the team?
  4. What’s the team spirit like?
  5. Where do team members generally have lunch?
  6. Does the team go out together every now and then?
  7. Do you encourage team members to give presentations to improve their abilities?
  8. Do you do the same with writing?
  9. Can I please speak informally to some of the people in the team I’ll be joining? (Useful to get beyond the management BS and get a feel for the real deal.)

Questions regarding personnel type policies:

  1. Does the company have a training policy?
  2. What were the latest courses that the company sent people on?
  3. Does the company have a mentoring policy?
  4. What kind of feedback mechanism is there for determining employee performance, e.g. how often is my work evaluated and suggestions given on where to improve?
  5. Is there a dress code? Do employees work a fixed set of hours?
  6. Is there any on-call time as part of the job?
  7. Do you encourage employees to set goals and provide incentives to meet those goals?
  8. Is self-improvement a value common to this organization?
  9. What’s your company’s Internet policy?
  10. What sites do you block? (I’ve worked at places where you can’t access various good technical sites.)
  11. Can I work irregular hours if I need to? For examle, at night, all the week’s hours in 2 days?
  12. Can I work from home?
  13. Do you have any policies against employees listening music while they work?
  14. How much work do you expect developers do outside of the normal business day?

Questions about management:
For the manager:

  1. What is your style of managing?
  2. How s/he motivates people
  3. How problems are handled (I leave that open-ended to see what sort of problem they assume–relating to those under them or those over them or issues unrelated to people at all, and then ask about whichever they didn’t cover).
  4. What the company does to help develop their managment skills
  5. What motivates them
  6. How much they work (typical hours/schedule)
  7. What accomplishment they are most proud of (I don’t specify work-related, and if they mention something besides that I ask about work as well)
  8. How they develop team cohesiveness and what they’ve been able to accomplish in that area
  9. What they see as the next big step for the team, for the company, and in dealing with projects or whatever the main mission of the group is

Then I ask them to answer the same kinds of questions for the company as a whole, explaining that I consider there’s such a thing as a company “personality” that usually emanates from the top. I ask how that has changed over the years (if they’ve been there very long).
Further questions on management:

  1. What’s your staff turnover rate?
  2. What’s the worst project you’ve ever been on here?
  3. How long does the typical hiree at my level stay with the company?
  4. How are projects categorized, e.g. changes compared to a small project compared to a big project?
  5. What kind of management is there within the company, e.g. is the development manager also the project manager or are these separate people usually?

Questions on the work environment:

  1. Can I please see my workplace?
  2. And, more specifically, can I see the desk where I will be working please?
  3. What’s the company’s policy to downloading software? (I’ve worked at places where you can download zip so it takes a week to get the help team to download the hex editor you needed yesterday.)
  4. How locked down are the PC’s? (I’ve worked at companies where the PC’s are so locked down it’s almost impossible to do any work e.g. no access to command prompt.)
  5. Do developers have admin rights on their PC’s? (Rule of thumb – The more locked down the PC, the worse the company. The real development sites I’ve worked at give all developers admin rights. They trust and empower them with corresponding rises in productivity.)
  6. What software is loaded by default on a standard developer PC? For example, can I use Eclipse or am I condemned to Notepad hell).
  7. Can I choose my own development tools?
  8. What sort of equipment do you provide to your developers? For example, are all developers given a laptop to work with, do they have access to two monitors, are they allowed to order other equipment (e.g. ergonomic keyboard)?

Miscellaneous questions:

  1. Why did the guy I’m replacing leave?
  2. How can I help you?
  3. What are your biggest needs right now?
  4. What kind of things would you want someone in this position to do?
  5. If you choose me, are there things I could read about your problem domain that would help me be effective on day one?
  6. Why the interviewer(s) work(s) there (or likes working there, or continutes to work there, etc). Their responses usually give me a good feel for the company.

Hope you liked this blog post. Looking forward to hear from you guys!


No comments


log4net versions deployment issue

October 6, 2010 .NET, Deployment 13 comments

So few days ago I faced with issue of 3rd party references.

My original question on stackoverflow:

What is the best approach to use 3rd party that uses another version of other 3rd party (log4net) already used in the system?

  • Currently we use log4net of version 1.2.10.0 and we should start using some 3rd party components developed by other team.
  • Mentioned component references log4net of version 1.2.9.0.
  • All binaries are deployed into one folder.
I’m sure that we cannot rebuild our sources with 1.2.9.0 version,
because there are too many other dependencies and will require lot of
efforts. Are there any other approaches to solve this issue? I’m NOT
looking for too sophisticated that have something to do with CLR
assemblies loading, but would hear them with great pleasure. I’m looking
for the simplest approaches. I guess someone has encountered the same
issue.

I got (as for now) two answers and I would like to try them out.

So I created 3 projects, one references log4net of version of 1.2.10.0 and another references 1.2.9.0. Both of them are referenced in client console application, which also references one of the log4net assemblies. In client application I’m trying to execute code that requires log4net in both of the assemblies.

Below is projects layout:

When I execute my code I’m getting error:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly ‘log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: ‘log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905’
   at ProjReferencesLog4Net._1._2._9._0.ClassA..ctor()
   at ConsoleAppReferencesLog4Net1._2._10._0_andBothAssemblies.Program.Main(String[] args) in
  ….

In order to resolve this I tried suggestion one by one…

Suggestion number 1

Redirecting Assembly Versions

Accordingly to MSDN there is possibility to redirect code execution to assembly with higher version, just with using following configuration:

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity name="log4net"
                           publicKeyToken="b32731d11ce58905"
                           culture="neutral" />
         <bindingRedirect oldVersion="1.2.9.0"
                          newVersion="1.2.10.0"/>
       </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

I’ve tried it and it did not work. Reason is that we cannot do redirection between assemblies with different PublicKeyToken-s. log4net 1.2.9.0 has “b32731d11ce58905” and log4net 1.2.10.0 has “1b44e1d426115821”. Also see this stackoverflow question.

Suggestion number 2

Use GAC. So when I install those two assemblies into GAC:

In this case code works, but suggestion doesn’t work for us, since we do not want to gac assemblies we use.

Other suggestions

So I’ve been thinking about another approach.
Approaches that require rebuilding our code with different version of log4net are not suitable for us. At least for now.
Another thing about which I’ve been thinking is to load those assemblies into different application domain or host 3rd party that uses 1.2.9.0 under different WinService. Both of these are cumbersome solutions and I like to avoid them.

YOUR SUGGESTION

If you have some ideas, could you please let me know!

[EDITED 7 Oct, 2010 11PM]

FUNNY-HAPPY-END OF THIS STORY

Do you know what is the most interesting about all of this? It is how it has finished. We contacted those guys, who developed component we now should use. They gave us know, that they were encountering issues with updating on-the-fly configuration file for log4net 1.2.10.0. By their words, new version of log4net is not capable of doing this. So they sent as simple application that demonstrates this, and indeed, after updating config when app is running, 1.2.10.0 did not catch up new configuration, but 1.2.9.0 was working just fine. This surprised me very much, so I went to this download page and downloaded latest binaries. When I tried it got working!!! Actually I guess that they simply used version of log4net buit with references to .net framework 1.1, and we should use one built with .net 2.0 (Yeah! Actually if you would download you will see.)

After all of this, they created new sub-release of their sources especially for us and they were able to fix some minor bug. Great news! Unexpected end of story! :)


13 comments


Composition vs. Aggregation – Best way to distinguish

October 5, 2010 OOP, UML 2 comments

Shame on me, but I have to admit that yesterday I had doubts about what is aggregation and composition. As everyone of us would do I started googling and found some of very useful and helpful explanations.

Two examples to start with

For example, we have table in room, we say that room aggregates table. Table can live without parent object (room).

Example of composition would be college composing faculties. Faculty cannot live without college.

Challenge

When I talked about this two examples with my friend he challenged following verification:
“If child cannot live without parent we have composition and when child can live without parent we have aggregation.” He gave me example of queue build upon list, he stated that this always was an example of composition to him. In this case queue has field _innerList (or something like that), but indeed being child list can be moved out of queue and conceptually we can operate with different lists in our system. So the rule of child-parent doesn’t apply. Even more it is applicable vise verse – queue (parent) cannot live without list (child).


So I found following to be the best way to distinguish:

If during lifetime of parent its child element(s) should exist to have consistent system, then this is COMPOSITION.
If above statement is not satisfied, but at the same time parent can contain child element(s), then this is AGGREGATION.

Relational/UML point of view

If you would read this wiki  page. You will also find that aggregation is more general term then composition. They explain this from a bit another point, point of relations.

Above relation on the picture shows composition and is marked as filled diamond, below relation shows aggregation as more generalization of composition, without restriction to have child elements (Monday our pound is full of ducks and Tuesday there is no ducks at all).

I would love to hear from you thoughts on how we can help others distinguish this more quicker.


2 comments


Book Review: The Deadline: A Novel About Project Management

October 4, 2010 Book Reviews 6 comments

TheDeadline.TomDeMarkoSo yesterday (ok today) in the evening (ok night) I finished reading yet another book on management, this time it is called “The Deadline: A Novel About Project Management”.
All things are happening in some post-Soviet-Union country, and it turns out that main thing that country does is software development. Hero of the book is lack to be there and lead 6 projects, which of them has deadline. Ugly boss is trying to shorten dates of releases, but fortunately hero has lot of connections to get world-known experts in different areas, also he has lot of people, so he decided to have 3 team for each of the project to be able to experiment and see how different factors impact productivity of the team, for example size of the team.

I read this book, and you know what? I’m disappointed by it. I has lot of ideas that do NOT glue with current world Agile ideas. Book states that everything should be designed and specified up to smallest details and after that developers start code. Also as one of improvements of the process was to omit unit testing o_O. Regardless of this I liked ideas about how managers should deal with people, bosses, deadlines, team sizes.About team sizes: If team is huge it will not lead to good design or effective utilization of resources – it will lead to enormous amount of meetings, discussions, etc, and in the end you could even get worse results!

Book is very naive, but I agree that it was initial intent of the author to write about known to all of us things on Project Management and they could be solved. He described main issues that may happen when you deal with Deadline. Honestly, it looks like he was asleep and had this dream, and then quickly wrote it down :)
If you have time and like to read something before bed you may read it, but I wish I had not spent my time on this book.


6 comments


Visitor

October 3, 2010 Design Patterns No comments

Today we will talk about yet another Design Pattern. Imagine situation in which you have finally rented new building for your business. Not sure how it is in other countries, but I guess that for each enterprise you have to pass many verifications standardized by government. Those should verify if your building, and the conditions are good for people, who will work there. So in few recent months you have to accept many visitors, like electrician, plumber, office designer, etc. They all will diagnose and assessment your building going from floor to floor and from room to room. I hope you already have some class diagram in you mind. I have a question: who better knows logic for validating electricity entrance into building, and validating electricity in floor shields, also if all lamps are connected correctly in rooms? Of course Electrician – your next week visitor. He encapsulates logic of validating certain elements of you building.

 

VISITOR


Visitor – is Design Pattern, that allows you separate different sets of logic/algorithms from elements in your system, on which that logic/algorithms should be applied. It also allows you easily add and change that logic without impact on your existing system and that is the biggest benefit of using this DP as per me.
Lets talk around our example.
So the encapsulated logic lives within concrete Visitor. Logic can be applied to Elements in the system. Basically you have two interfaces which represent core of this design pattern – they are
IVisitor
public interface IVisitor 
{ 
    void Visit(OfficeBuilding building); 
    void Visit(Floor floor); 
    void Visit(Room room); 
}
IElement
public interface IElement 
{ 
    void Accept(IVisitor visitor); 
} 

ElectricitySystemValidator
One of the concretes of the IVisitor is ElectricitySystemValidator and it might look like in code snippet below. What does this class tells to us? It tells that some logic for each of the elements lives in one visitor and it is forced to provide that logic for all elements in your system, so you can easily pass electrician visitor from floor to floor and be sure that he know what he must do out there.
public class ElectricitySystemValidator : IVisitor 
{ 
    public void Visit(OfficeBuilding building) 
    { 
        var electricityState = (building.ElectricitySystemId > 1000) ? "Good" : "Bad"; 
        Console.WriteLine(string.Format("Main electric shield in building {0} is in {1} state.", building.BuildingName, electricityState)); 
    } 

    public void Visit(Floor floor) 
    { 
        Console.WriteLine(string.Format("Diagnosting electricity on floor {0}.", floor.FloorNumber)); 
    } 

    public void Visit(Room room) 
    { 
        Console.WriteLine(string.Format("Diagnosting electricity in room {0}.", room.RoomNumber)); 
    } 
}
PlumbingSystemValidator
Does quite similar work as ElectricitySystemValidator, but is takes into account building’s age to have an idea of the plumbing system state. Also it does nothing for rooms, since it is common, that you have no water in all rooms unless your building is special plant.
Elements
We have kind of traversing object structure. It starts with OfficeBuilding, it has Floors, any floor can have many rooms. Lets take quick look on Floor implementation.
Floor
public class Floor : IElement 
{ 
    private readonly IList<Room> _rooms = new List<Room>(); 
    public int FloorNumber { get; private set; } 
    public IEnumerable<Room> Rooms { get { return _rooms; } } 

    public Floor(int floorNumber) 
    { 
        FloorNumber = floorNumber; 
    } 

    public void AddRoom(Room room) 
    { 
        _rooms.Add(room); 
    } 

    public void Accept(IVisitor visitor) 
    { 
        visitor.Visit(this); 
        foreach (var room in Rooms) 
        { 
            room.Accept(visitor); 
        } 
    } 
} 
As you see above Accept method, that accepts visitor them passes it to its inner structure and visitor will know how to deal with those elements. So in future if you will have to change how the electrician should behave in room, you can be sure that logic will be moved to the room smoothly without need to change Floor class.
OfficeBuiling is quite similar, but is has additional properties. Room is very simple since doesn’t aggregate or compose other elements.

Source code elements in diagram

You can take a look on the picture below to see other pieces of my demo program.


Nothing so much special till now? Then let see usage and output of my super demo example.

Usage

var floor1 = new Floor(1); 
floor1.AddRoom(new Room(100)); 
floor1.AddRoom(new Room(101)); 
floor1.AddRoom(new Room(102)); 
var floor2 = new Floor(2); 
floor2.AddRoom(new Room(200)); 
floor2.AddRoom(new Room(201)); 
floor2.AddRoom(new Room(202)); 
var myFirmOffice = new OfficeBuilding("[Design Patterns Center]", 25, 990); 
myFirmOffice.AddFloor(floor1); 
myFirmOffice.AddFloor(floor2); 

var electrician = new ElectricitySystemValidator(); 
myFirmOffice.Accept(electrician); 

var plumber = new PlumbingSystemValidator(); 
myFirmOffice.Accept(plumber);
Output:

Main electric shield in building [Design Patterns Center] is in Bad state.

Diagnosting electricity on floor 1.

Diagnosting electricity in room 100.

Diagnosting electricity in room 101.

Diagnosting electricity in room 102.

Diagnosting electricity on floor 2.

Diagnosting electricity in room 200.

Diagnosting electricity in room 201.

Diagnosting electricity in room 202.

Plumbing state of building [Design Patterns Center] probably is in Good condition, since builing is New.

Diagnosting plumbing on floor 1.

Diagnosting plumbing on floor 2.

Classic UML diagram

So the general UML diagram for this Design Pattern looks like on the image below:
Visitor1[1]
I hate that I have to go to bed, I still have a lot to add to this Design Pattern, since I see it very useful and thrilling.

My Design Patterns Table


No comments


I gave up with Design Patterns in Java – I start my book

September 26, 2010 C#, Design Patterns, Java, Opinion, Personal, Success 12 comments

Yeah, title sounds not logically, but you will understand in a few why it is still relevant to this blog post.

It was and it is a good idea to…

In one of my blog posts I’ve decided to have all of the GoF Design Patterns written with Java. And idea itself is very good. Having all of the design patterns written by your own with you own examples gives you understanding of the DP that you cannot gain anywhere else plus to that if you have industrial experience of using all of them you can start think that you are guru of DP.

Process of writing my post on one of the Design Patterns looks like this: I read chapter of the GoF book on the particular DP, then I think up my own example if I do not have it already in my mind and after I’m done with some preliminary ideas I search over the internet for interesting articles on it and probably rethink some of the aspects of my example. After all of that I proceed to writing blog post and source code with Java.

Conclusion: Awesome and probably one of the best ways of learning DP is to have your own example of using it and industrial experience.

Design Patterns articles

One of the intents of having DP written in Java was to familiarize with that language. But it turns out that I did not learn much from Java (except of few things). Also few months ago I started keeping up Tuesday’s Design Pattern on the Lviv .NET User Group Page. Since it is .NET specific UG, I used to do following: 1) translate and 2) translate. In first place it is translation from English to Ukrainian and in second from Java to C#. When with item number one I have to apply some logic and rephrasing I cannot say the same about second item. I just copy code-paste code into Visual Studio and change few keywords. So what do I learn regarding of Java in this case?

I will continue learning Java, but I have to consider better way of doing it. I will also continue writing about Design Patterns, but with examples in C#.

Conclusion: Learning another programming language (Java) is really great idea, but be sure that you choose right approach of doing this.

First free e-book

On the road to Lviv I got perfect idea to start my first book. Of course this cannot be comprehensive stunning author’s book, but I have to start with something. In other words some probing book and this could be this “try it” case. I’m almost sure that there are no books about GoF Design Patterns in Ukrainian. (I suppose that there are in Russian, which can be easily understandable for most Ukrainians…)

How this book will be different?

  • It will be in Ukrainian.
  • It will NOT be a translation of GoF book in any way.
  • It will have my own unique examples.
  • It will be short and easy to understand.
  • It will be really cool kick-off book on DP for starting Developers.
  • It will be free to download.

Why do I need it?

I understand that this book might not be popular at all. But I have to start with something and plus to this it will help me familiarize with the whole process and build my confidence for future.

Also if you have some doubts about my idea I have a question for you: “Have you ever dreamt about your own book? If yes, do you have at least small book written?”

Conclusion: Never be skeptic about starting your first book. It might be a huge step to your success as anything else you are hesitating about but still dreaming about it!


12 comments


My new Dell Studio XPS 16 (1647) laptop

September 23, 2010 Personal 9 comments

So I finally bought high performance machine for my blogging :).


I probably should mention that I do NOT have desktop computer located somewhere at home*. I heard that many people like to have those at home and one small laptop for travel or whatever else. I’m supporter of the idea that nowadays the gap between desktop computers and laptops is much much smaller and I do not see any reason why I should use few computers and play around synchronizing them, administrating, etc. I have one entry point for everything and I like this.

Why I was not satisfied with my previous laptop?

Top number one reason is screen resolution! I often like to remotely connect to my work machine. But resolution there is much higher than my old (1280×800) so it was unpleasant to work that way. Also having a lot of applications opened doesn’t work very well.
Second reason is performance. I simply wanted to be able to open few VS2010 instances without any delays.
Third and also valuable reason is that I as a kid wanted a new toy to play with.

Comparison of Dell Studio 1535 and Dell Studio XPS 1647

So here is comparison of what I had and what I have now:

Dell Studio 1535

DellStudio1535

Dell Studio XPS 1647

DellStudioXPS

Processor
Intel® Core™ 2 Duo T5850 2.16GHz
Processor
Intel® Core™ i7-620M Processor 2.66GHz (3.33GHz Turbo Mode, 4MB Cache)
Display
LCD(1280×800)
LCD Panel
Edge-to-Edge FHD Widescreen 15.6 inch WLED LCD (1920×1080) W/2.0 MP
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
4GB Shared Dual Channel DDR3 at 1333MHz
Hard Drive
320GB 5400

Hard Drive
500GB 7200 RPM SATA

Video Card

ATI Mobility Radeon™ HD 3450

Video Card
ATI Mobility Radeon™ HD 5730 – 1GB
Sound
High Definition Audio
Sound
High Definition Audio 2.0 with SRS Premium Sound
Wireless
Dell Wireless 1397 WLAN Mini-Card
Wireless
Intel® 5300 WLAN Wireless-N (3×3) Mini Card
Battery
56 Whr Lithium Ion Battery (6 cell)
Battery
85 WHr 6-cell Lithium Ion Primary Battery

Windows Experience Comparison

Dell Studio 1535:
Studio.1535.WindowsExperience
Dell Studio XPS 1647:
Studio.XPS.1647.WindowsExperience

So looking at the pictures above it is seen that bottleneck of my new laptop is hard disk and memory speed. This means that when something will require accessing hard disk (loading something into memory, working with svn, etc) I will not gain performance. Sadly, but I can do nothing about this.

My personal comparison

Wow! That is exactly what I wanted. This laptop is just sexy. You cannot imagine how everything is loading quickly. Everything is flying.
Appearance is amazing. Perfect for those guys who like style toys. It has genuine leather accents at the edge, which looks very cute.
I do see much more with full HD screen. Yeah, some fonts are very tiny, especially when you are taking a look on the 8pt fonts on the screen of resolution 1920×1080 but with the same physical size as screen 1280×800 difference is evident. I do not have any complains about my eye vision so this is something I even like. If that could be the problem for you, you can easily increase font sizes and have much smoother looking symbols. And very interesting fact I opened some site, and they have text alignment to the left. Of course this is bad idea, but what is interesting I was able to see many lines of “You have perfect monitor” on the most right :)
Also I experienced that one of old games that I used to play now easily can be switched to higher resolution, so all textures are very smooth.

Getting everything up and running

You know what is the sad about this? – I got Home Premium version of Windows 7 and I’m not completely sure if this is something that is enough for software developer.
Copying everything from was as much as easy as copying from logical disk D to disk E. I plugged Ethernet crossover cable into both of them and ensured that they have different IP addresses and that’s it! High speed computer-to-computer network is ready.
At the moment I feel that movement to brand new computer happened momentarily without any stress for me.

Latest cents

Having a good quality computer for person who is interested in developing software is very important. So if you are now considering of buying something expensive – do not hesitate, because you deserve it. (If you are not Ukrainian – laptop which costs 1500$ is near average software developer month salary (2-6 years of experience).)

(*) Ok, I have it, but I gave up using it.


9 comments