代码改变世界

新加坡面试经历

2012-08-26 10:51 by 圣殿骑士, ... 阅读, ... 评论, 收藏, 编辑

Introduction

How time flies! It has been a little bit long time I haven’t update my blog! So sorry about this especially for the guys who sent email or msn messages to me(becoz of so many emails and so busy and no time to reply one by one, I just want to say sorry to anyone here I didn't reply to)! These days I had been busy with my work and also I want to change my career and I must decide to stay in Singapore or go back to China, so I had some interviews which I found very interesting and I want to share to you guys who want to know or want to get experience from it and also is a record for myslef. Such as this one, details as below:

The First Interview

Before I start, I would specifically like to say a massive thanks to the companys(HR/Tech Staff), without whom this article would never have been possible. This company which I applied is the world leader in creating interactive applications for connected devices. They are working with leading consumer electronics companies such as Apple, Samsung, LG, Panasonic, Philips. Online service providers and media/sports companies they work with include Google, Facebook,ESPN, NBA, CNBC  and  Twitter.
They want a Silverlight .Net Architect/Developers/Programmers in Xbox Projects(This job is OK for me becoz I mainly looking for Senior Software Developer/Team Lead/Architect and focused on WPF/Silverlight/Cloud Computing)  and Ability to travel is not a requirement, but if staff is interested in travel, there is also the opportunity to work overseas at Microsoft Redmond or the media company's location—California,Stockholm, Hong Kong, Madrid and Mountain View(This is one of the reasons I want to join also).

The second day the HR sent me the email and asked me some basic information and we scheduled the interview to last Monday(Becoz that day is a Hari Raya Holiday,  Hari Raya Puasa in Singapore is celebrated by the Muslims to mark the end of their one month of fasting )

Before the interview, I installed Skype and set all equipments well and waitting for the interviewer. Around 11AM the interviewer started a video call with me and asked the basic details such as my Career Overview,Technical Skills,Experience,Academic Profile and Summary of Projects experience(Judging from her accent, maybe she is from Europe).

The Second Interview

Then after half an hour, As discussed with her via Skype, I was required to take a written test to evaluate my understanding of Silverlight. And also noted this is not an open book test. I just have 10 minutes to complete and return the test paper to interviewer(So this means I have no time to consider more and I must try to finish it asap).

1. The following code prints out integers stored in memory. Please modify it so that the integers are
printed in ascending order.

using System;
using System.Collections.Generic;
 
public class Test
{
        public static void Main()
        {
                List<Employee> data = new List<Employee>{ new Employee("A",20), new Employee("B",10), new Employee("C",30), new Employee("D",0), new Employee("E",50) };
 
                foreach(var e in data)
                {
                        Console.WriteLine(e);
                }
        }
}
 
public class Employee
{
        public string Name;
        public int Salary;
 
        public Employee(string n, int s)
        {
                this.Name = n;
                this.Salary = s;
        }
        
        public override string ToString()
        {
                return string.Format("{0}: {1}", this.Name, this.Salary);
        }
}

Please feel free to use any class, method, etc provided by .NET Framework 3.5

My answer as below:

data.OrderBy( employee => employee.Name ).ToList();

2. Referring to the following piece of code:

using System;
using System.Net;
using System.Threading;
 
public class Test
{
        public static void Main()
        {
                WebClient wc = new WebClient();
                wc.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) =>
                {
                        Console.WriteLine("Got the following data:");
                        Console.WriteLine(e.Result);
                };
 
                Console.WriteLine("Getting data...");
                wc.DownloadStringAsync(new Uri("http://checkip.dyndns.com/"));
                Console.WriteLine("Exiting...");
        }
}

It gets the content of a web page and print it out to the screen.
Please suggest the reason why the output is:
Getting data...
Exiting...
Instead of:
Getting data...
Got the following data:
(File Content)
Exiting...

My answer as below:

Because of Silverlight’s asynchronous

3. What is the purpose of datacontext in MVVM?

Like MVP, Model-View-ViewModel (MVVM) pattern splits the User Interface code into 3 conceptual parts - Model, View and ViewModel out of which the concept of the ViewModel is the new and the most exciting.  Model is a set of classes representing the data coming from the services or the database. View is the code corresponding to the visual representation of the data the way it is seen and interacted with by the user. ViewModel serves as the glue between the View and the Model. It wraps the data from the Model and makes it friendly for being presented and modified by the view. ViewModel also controls the View's interactions with the rest of the application (including any other Views). Contents is a bridge for View and ViewModel using the Binding, we always use MEF or some IOC container to do that.We have finished 3 projects with MVVM and 1 project with MVP .

4. Describe the concept of Inversion of Control (IoC).

We did so many projects with IOC, As I know, Inversion of Control (IOC) is an object-oriented programming practice where the object coupling is bound at run time by an assembler object and is typically not known at compile time using static analysis. We used Unity and Spring.Net in our project.

5. How would you trigger a storyboard from a viewmodel?

At our first project, we used messagers to do that(View and viewmodel uses a simple Publish/Subscribe model to allow loosely coupled messaging.) and later we found the way as below:

<Grid x:Name="LoginGrid">
  <i:Interaction.Triggers>
    <ei:DataTrigger Binding="{Binding IsLoggedIn}" Value="true">
      <ei:ControlStoryboardAction x:Name="FadeOutOnLogin" Storyboard="{StaticResource LoginFadeOut}"/>
    </ei:DataTrigger>
  </i:Interaction.Triggers>
</Grid>

The Third Interview

After completing the written test. Moving into the next phase of our recruitment process, I was required to take a simple programming test to verify my technical ability.
The task is to build a memory game and a server for players' high scores. They do not expect me to know all the required coding technique needed to build the game and noted to me"Please feel free to do research, find reference and learn from the internet". The judging criteria, in descending order, would be quality, delivery time and creativity.
Also I was required to provide detailed instructions on how to set up the game and server, and to develop the application using Silverlight.
The details of the task requirement is in the enclosed package and package up the finished work and return to interviewer.

The task details as below:

Work Sample

The goal of this work sample is to construct a game called ”Colour Memory”. The game board consists of a 4x4 grid, all in all 16 slots. All slots consists of cards face-down. The player is to flip two of these upwards each round, trying to find equals. If the two cards are equal, the player receives one point, and the cards are removed from the game board. Otherwise, the player loses one point and the cards are turned face-down again. This continues until all pairs have been found.
After the game is finished, the user would be required to input his/her name and email. User's details and the scores would then be submitted to the database and the user would get notified with the highscores and his position in score rankings.

Prerequisites
1,The application must be developed with Silverlight.
2,The application must have at least one customized control in Silverlight.
3,The application must have a high score data provider.
4,Developer must provide instructions on how to set up the game and server.
5,The application should be blendable.
6,The application should have sample data, and provider which can be easily switched with the high score date provider.
7,The application should implement Unit Testing wherever applicable.
8,The application should be controllable by only the arrow keys (to navigate) and enter (to select) (except the operations inside the input field)
9,The application should follow the design template illustrated on the last page
10,Highscores server is suggested to be developed in PHP and MySQL
Design
1,The game should entirely fit inside a 720x576 area
2,The game info area is to contain information about the current game session. Current score for instance. Be creative
3,The graphics for the cards and the logotype have been supplied 
4, All other graphical elements are up for you to decide upon
5,The restart button should start a new round when selected
6,There has to be a way to signal to the player that the game is over, when all pairs have been found. Ideally, this includes an option to play a new round
Delivery

 


The implementation of Colour Memory should be delivered in a compressed archive containing all necessary files and resources. Also, an instruction on how to install and start the game is expected.

Suggested Structure

image

UI

image

After I confirmed that I had received this test and I started to do it using WPF and My WPF version finished 3 hours later, details as below:

image

The XAML Code:

<Window x:Class="AccedoTestWPFVersion.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:AccedoTestWPFVersion"
        Title="Knights Warrior Colour Memory" Height="576" Width="720" x:Name="mainwin">
    <Window.Resources>
        <ResourceDictionary Source="MainResources.xaml" />
    </Window.Resources>
    <DockPanel Width="Auto" Height="Auto" LastChildFill="True">
        <!--Menu-->
        <local:Menu x:Name="test" Width="Auto" Height="20" Background="LightGray" DockPanel.Dock="Top"/>
        <!--Left-->
        <Grid Height="500" Width="500" Background="Gray" Name="DisplayAllCards"/>
        <!--Right-->
        <StackPanel Width="200" Height="500" Background="Gray">
            <Image Margin="5,5,5,5" Width="200" Height="80" x:Name="imgLogo"/>
            <DataGrid Name="dgRanking" AutoGenerateColumns="False" Height="250">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="AppID" Width="60" Binding="{Binding AppID}"/>
                    <DataGridTextColumn Header="Name" Width="90" Binding="{Binding Name}"/>
                    <DataGridTextColumn Header="Score" Width="40" Binding="{Binding Score}"/>
                </DataGrid.Columns>
            </DataGrid>
            <Viewbox Stretch="Uniform">
                <StackPanel Margin="0,0,0,0" Background="White" Orientation="Horizontal">
                    <Label Content="Current Score:"></Label>
                    <Label x:Name="lblScore" Content="{Binding ElementName=mainwin, Path=DPScore}" Width="61"></Label>
                </StackPanel>
            </Viewbox>
            <Button Margin="10,30,10,10" Name="btnReStart" Style="{StaticResource DigitBtn}"  Content="ReStart" Command="{Binding Path=ReStartCommand}" FontSize="24" />
        </StackPanel>
    </DockPanel>
</Window>

Core code(Non MVVM version):

   1: //This is the data for Ranking datagrid
   2:  private ObservableCollection<User> _UserDataList;
   3:  public ObservableCollection<User> UserDataList
   4:  {
   5:      get { return this._UserDataList; }
   6:      set
   7:      {
   8:          this._UserDataList = value;
   9:      }
  10:  }
  11:  
  12:  //DPScore is for current score
  13:  public int DPScore
  14:  {
  15:      get { return (int)GetValue(dpScore.DependencyProperty); }
  16:  }
  17:  
  18:  private static readonly DependencyPropertyKey dpScore =
  19:      DependencyProperty.RegisterReadOnly("DPScore",
  20:                                          typeof(int),
  21:                                          typeof(MainWindow),
  22:                                          new PropertyMetadata(0));
  23:  
  24:  
  25:  private object ShowImageCard(int imgType)
  26:  {
  27:      switch (imgType)
  28:      {
  29:          case 1:
  30:              return GetCardBg("colour1");
  31:          case 2:
  32:              return GetCardBg("colour2");
  33:          case 3:
  34:              return GetCardBg("colour3");
  35:          case 4:
  36:              return GetCardBg("colour4");
  37:          case 5:
  38:              return GetCardBg("colour5");
  39:          case 6:
  40:              return GetCardBg("colour6");
  41:          case 7:
  42:              return GetCardBg("colour7");
  43:          case 8:
  44:              return GetCardBg("colour8");
  45:          default:
  46:              return imgType;
  47:      }
  48:  }
  49:  
  50:  private void ShowAllCardsUI(Grid Grid)
  51:  {
  52:      Grid.Children.Clear();
  53:      Grid.ColumnDefinitions.Clear();
  54:      Grid.RowDefinitions.Clear();
  55:      // Generating 4x4 Grid
  56:      for (int Index = 0; Index <= 3; Index++)
  57:      {
  58:          Grid.RowDefinitions.Add(new RowDefinition());
  59:          Grid.ColumnDefinitions.Add(new ColumnDefinition());
  60:      }
  61:  
  62:      // Generating 4x4 Cards
  63:      for (int i = 0; i <= 3; i++)
  64:      {
  65:          for (int j = 0; j <= 3; j++)
  66:          {
  67:              Add(Grid, i, j);
  68:          }
  69:      }
  70:  }
  71:  
  72:  private List<int> Random(int Start, int Finish, int Total)
  73:  {
  74:      int _number;
  75:      List<int> _numbers = new List<int>();
  76:      // Total Numbers
  77:      while (_numbers.Count < Total)
  78:      {
  79:          long tick = DateTime.Now.Ticks;
  80:          Random r = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
  81:  
  82:          _number = (r.Next(Finish)) + Start;
  83:          // Between Start - Finish
  84:          // If Chosen or None
  85:          if (!_numbers.Contains(_number) | _numbers.Count < 1)
  86:          {
  87:              _numbers.Add(_number);
  88:              // Add Number
  89:          }
  90:      }
  91:      return _numbers;
  92:  }
  93:  
  94:  private void GenerateAllCards()
  95:  {
  96:      List<int> valuesList = new List<int>();
  97:      List<int> indicesList = new List<int>();
  98:  
  99:      int intCounter = 0;
 100:      // Get 16 Numbers (2x8)
 101:      while (valuesList.Count < 17)
 102:      {
 103:          List<int> numbersList = Random(1, 8, 8);
 104:          // Random 1 - 8
 105:          for (int intNumber = 0; intNumber <= 7; intNumber++)
 106:          {
 107:              valuesList.Add(numbersList[intNumber]);
 108:              // Add to Cards
 109:          }
 110:      }
 111:      indicesList = Random(1, 16, 16);
 112:      // Random 1 - 16
 113:      // Board Columns
 114:      for (int Column = 0; Column <= 3; Column++)
 115:      {
 116:          // Board Rows
 117:          for (int Row = 0; Row <= 3; Row++)
 118:          {
 119:              gridBoard[Column, Row] = valuesList[indicesList[intCounter] - 1];
 120:              intCounter += 1;
 121:          }
 122:      }
 123:  }

After finished the WPF version, I found time was so early, so I continued finished WPF MVVM version and Silverlight Version. If some of you have interesting with this Game source code, I will post to CodePlex later.

Summary

These days these interviews gave me some experiences, For HR/Manager, They always asked these questions besides my basic information(Career Overview,Technical Skills,Experience,Academic Profile and Summary of Projects experience etc.) :

1,What two or three things are most important to you in your job?
2,What responsibilities did you like most and least in your last job? Why?
3,Give me a specific example when you faced a particularly difficult problem? What steps did you take to resolve it?
4,What characteristics do you feel distinguish a great software engineer? Give me an example in your past which you feel demonstrates those qualities in you.
5,Describe one example where your actions led to improved quality of your organisation’s product or service.
6,What do you feel is the most effective way to keep up to date with latest technologies? Why?
7,What do you see yourself doing five years from now?
8,What makes you stand out / why should we hire you?

For the technology skills, You must prepare some questions because the interviewer’s pronunciation have so many differences(such as US, Singapore,India and the UK), If you can not follow them and you will have a nightmare with this interview.Form the interviews I joined before, They like ask below questions:

1. What is WPF/Silverlight ? Why it is used?
2. What is XAML?
3. What is Dispatcher Object?
4. What is Dependency Object?
5. What is the architecture of WPF/Silverlight ?
6. What are Types of Events and Event Routing or a Routed Event?
7. What is difference between Event Bubbling Vs Event Tunneling? When to apply what?
8. What are difference Win-Forms,WPF, ASP.NET, ASP.NET, ASP.NET MVC, Silverlight ?When to choose what?
9. What are different types of Panels in WPF/Silverlight ? Explain them?
10. What is difference between StackPanel, DockPanel, WrapPanel and Grid?
11. What are Primitive Controls and Look Less Controls?
12. What are different important components to know in WPF/Silverlight ? Explain them?
13. Why do you think WPF/Silverlight has more power?
14. How did you use Dependency Object?Purpose of Freezables?Visual vs Logical tree?
15. Example of attached behavior?
16. What is MVC,MVP,MVVM? Did you use PRISM ? What are its advantages of using it in real time applications?
17. If you used MVVM, How to allows view to communicate LifeCycle events to a ViewModel without any hard reference links?
18. If you used MVVM, Why you use attached behaviours,How to do Numeric text entry?
19. If you used MVVM, How to allows the ViewModel to determine if a Models data should be editable?
20. If you used MVVM, How to show MessageBox service,Popup window service?
21. If you used MVVM, How would you trigger a storyboard from a viewmodel?
22. WPF/Silverlight Performance tuning

At last, Today is sunday and Let’s enjoy a picture and get more pleasure!!!

image