├── .gitattributes
├── .gitignore
├── InterviewQuestions.sln
├── InterviewQuestions
├── InterviewQuestions.csproj
├── Introduction.txt
├── Properties
│ └── AssemblyInfo.cs
├── Question 01 - Law Of Demeter.cs
├── Question 02 - Law Of Demeter.cs
├── Question 03 - Refactoring.cs
├── Question 04 - Refactoring.cs
├── Question 05 - LINQ.cs
├── Question 06 - Unit Tests.cs
├── Question 07 - Code Review.cs
├── Question 08 - Error Prevention.cs
├── Question 09 - Asyncronous Programming.cs
├── Question 10 - Lazy Loading.cs
├── Question 11 - SOLID Principles.cs
├── Question 12 - SOLID Principles.cs
├── Question 13 - Big O Notation.cs
├── Question 14 - Sorting.cs
└── Question 15 - Logic Puzzles.cs
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
--------------------------------------------------------------------------------
/InterviewQuestions.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterviewQuestions", "InterviewQuestions\InterviewQuestions.csproj", "{45A3BAF2-9BA9-4215-B580-24379CA6922C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {45A3BAF2-9BA9-4215-B580-24379CA6922C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {45A3BAF2-9BA9-4215-B580-24379CA6922C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {45A3BAF2-9BA9-4215-B580-24379CA6922C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {45A3BAF2-9BA9-4215-B580-24379CA6922C}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/InterviewQuestions/InterviewQuestions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {45A3BAF2-9BA9-4215-B580-24379CA6922C}
8 | Library
9 | Properties
10 | InterviewQuestions
11 | InterviewQuestions
12 | v4.6.1
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
71 |
--------------------------------------------------------------------------------
/InterviewQuestions/Introduction.txt:
--------------------------------------------------------------------------------
1 | Please go through every class in this solution, answering all questions as you go along.
2 |
3 | Questions are asked in code comments at the top of every class, outlining the scenarios that we would like you to cover.
4 |
5 | You are permitted to add any references from nuget or any other code sources that you see fit. Answers may add classes, methods,
6 | properties or any other code that you as a candidate feel necessary.
7 |
8 | There are multiple ways of answering the vast majority of these questions, your code will be read through at the end and evaluated against
9 | how you went about answering these questions just as much as whether the code would do what the question asks.
10 |
11 | You are permitted to use google, or any other internet resource you see fit in this answer. However this should be used as a reference for things that you have forgotten about, instead
12 | of learning new technology. If you do not understand a question, there will not be a penalty for skipping it.
13 | As an example of this, please do not google 'What is demeters law' or 'what are the solid principles'
--------------------------------------------------------------------------------
/InterviewQuestions/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("InterviewQuestions")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("InterviewQuestions")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("45a3baf2-9ba9-4215-b580-24379ca6922c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 01 - Law Of Demeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Add code into the GetEngineManufacturer method so that it gets the name of a car's engine. In this example please BREAK demeters law.
11 | /// It is expected that the car class will have to have an engine property added to it.
12 | ///
13 | public class Question1
14 | {
15 | public string GetEngineManufacturer()
16 | {
17 | // answer here
18 |
19 | }
20 |
21 | private class Car
22 | {
23 |
24 | }
25 |
26 | private class Engine
27 | {
28 | public string Make { get; set; }
29 |
30 | public string Manufacturer { get; set; }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 02 - Law Of Demeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Add code into the GetEngineManufacturer method so that it gets the name of a car's engine. In this example please ADHERE to demeters law.
11 | /// It is expected that the car class will have to have an engine property added to it.
12 | ///
13 | public class Question2
14 | {
15 | public string GetEngineManufacturer()
16 | {
17 | // answer here
18 |
19 | }
20 |
21 | private class Car
22 | {
23 |
24 | }
25 |
26 | private class Engine
27 | {
28 | public string Make { get; set; }
29 |
30 | public string Manufacturer { get; set; }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 03 - Refactoring.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Refactor the code below to make it more object oriented and remove the switch statement.
11 | /// The likely result of this will end up with a boolean property on the service class
12 | ///
13 | /// You are permitted to write as many additional classes, methods or code as you see necessary.
14 | ///
15 | public class Question3
16 | {
17 | private Service _service;
18 |
19 | private Question3(Service service)
20 | {
21 | _service = service;
22 | }
23 |
24 | public string GetString(string theInput)
25 | {
26 | string response = _service.AskForPermission();
27 | switch (response)
28 | {
29 | case "FAIL":
30 | return "error";
31 | case "OK":
32 | return String.Format("{0} {1}", theInput, theInput);
33 | default:
34 | return null;
35 | }
36 | }
37 |
38 | private class Service
39 | {
40 | internal string AskForPermission()
41 | {
42 | throw new NotImplementedException();
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 04 - Refactoring.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Refactor the code below so that the nested if statements are reduced as much as possible.
11 | /// Attempt to failfast as much as possible, so that all checks do not need to run if any validation has failed.
12 | ///
13 | public class Question4
14 | {
15 | private ISuccessChecker _initializationChecker;
16 | private ISuccessChecker _nullChecker;
17 | private ISuccessChecker _dataEntryValidation;
18 | private ISuccessChecker _databaseValiator;
19 |
20 | private Question4(ISuccessChecker initializationChecker, ISuccessChecker nullChecker,
21 | ISuccessChecker dataEntryChecker, ISuccessChecker databaseValidator)
22 | {
23 | _initializationChecker = initializationChecker;
24 | _nullChecker = nullChecker;
25 | _dataEntryValidation = dataEntryChecker;
26 | _databaseValiator = databaseValidator;
27 | }
28 |
29 | public string GetResult()
30 | {
31 | string resultToReturnToUser = string.Empty;
32 |
33 | if (_initializationChecker.DidSucceed())
34 | {
35 | if (_nullChecker.DidSucceed())
36 | {
37 | if (_dataEntryValidation.DidSucceed())
38 | {
39 | if (_databaseValiator.DidSucceed())
40 | {
41 | resultToReturnToUser = "validated";
42 | }
43 | else
44 | {
45 | resultToReturnToUser = "Could not validate database";
46 | }
47 | }
48 | else
49 | {
50 | resultToReturnToUser = "Could not validate data entry";
51 | }
52 | }
53 | else
54 | {
55 | resultToReturnToUser = "Could not validate nulls";
56 | }
57 | }
58 | else
59 | {
60 | resultToReturnToUser = "Entry did not pass initial validation";
61 | }
62 |
63 | return resultToReturnToUser;
64 | }
65 |
66 | private interface ISuccessChecker
67 | {
68 | bool DidSucceed();
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 05 - LINQ.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Rewrite the GetIntValuesFromStrings method to make the most of LINQ.
11 | /// While method syntax is preferred, you are permitted to use query syntax.
12 | ///
13 | /// The nature of the query should not change. The query adheres to the following user story.
14 | ///
15 | /// Given I am processing a list of entities
16 | /// When the name of the entity starts with a two digit number
17 | /// Then the record will be processed
18 | ///
19 | /// Given I am processing a list of entities
20 | /// When the name of the entity does not start with a two digit number
21 | /// Then the record will be ignored
22 | ///
23 | public class Question5
24 | {
25 | public List GetIntValuesFromStrings(List entities)
26 | {
27 | var firstCharacters = new List();
28 | foreach (var entity in entities)
29 | {
30 | firstCharacters.Add(entity.Substring(0, 2));
31 | }
32 |
33 | var parsedEntities = new List();
34 |
35 | foreach (var entity in firstCharacters)
36 | {
37 | int parsedValue;
38 | if (int.TryParse(entity, out parsedValue))
39 | {
40 | parsedEntities.Add(parsedValue);
41 | }
42 | }
43 |
44 | return parsedEntities;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 06 - Unit Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Write a new unit test class (either inside this file, or in a new one) that will test the method below.
11 | /// The expectation is that 2 unit tests will be written.
12 | ///
13 | /// No unit test frameworks have been added, so it is up to your preference whether to use Nunit, Xunit, MSTest, or any other testing frameworks.
14 | ///
15 | public class Question6
16 | {
17 | private IQuestion6Dependency _dependency;
18 |
19 | public Question6(IQuestion6Dependency dependency)
20 | {
21 | _dependency = dependency;
22 | }
23 |
24 | public string GetFirstSixCharactersOfDatabaseValue()
25 | {
26 | var dbValue = _dependency.GetValueFromDatabase();
27 | return dbValue.Substring(0, 6);
28 | }
29 | }
30 |
31 | public interface IQuestion6Dependency
32 | {
33 | string GetValueFromDatabase();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 07 - Code Review.cs:
--------------------------------------------------------------------------------
1 | //Question 7 - Code review the code below. Write any comments / suggestions in code comments next to the affected line.
2 | // if you feel like your comment can be backed up with evidence: eg 'this breaks the open closed principle' - please point to any evidence via MSDN,
3 | // blogposts etc
4 |
5 |
6 | //Start code review HERE.
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.IO;
11 |
12 | namespace InterviewQuestions
13 | {
14 | public class Question7
15 | {
16 | public string defaultAnswer;
17 | private List AvaliableAnswers { get; set; }
18 |
19 |
20 | public Question7(List avaliableAnswers)
21 | {
22 | defaultAnswer = GetDefaultAnswer(avaliableAnswers);
23 | }
24 |
25 | public string GetDefaultAnswer(List avaliableAnswers)
26 | {
27 | try
28 | {
29 | // we shouldn't have more than one avaliable answer NORMALLY, so lets try and get one.
30 | return avaliableAnswers.Single();
31 | }
32 | catch (Exception e)
33 | {
34 | if (avaliableAnswers.Count == 0)
35 | {
36 | return "There are no answers avaliable";
37 | }
38 | else
39 | {
40 | // there were multiple answers. Inform the user
41 | return "There are more than 1 answers to this question";
42 | }
43 | }
44 | }
45 |
46 | public void DisplayAnswersToUser()
47 | {
48 | foreach (var answer in AvaliableAnswers)
49 | {
50 | var currentItemPosition = AvaliableAnswers.IndexOf(answer) + 1;
51 | Console.WriteLine(currentItemPosition + " - " + answer);
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 08 - Error Prevention.cs:
--------------------------------------------------------------------------------
1 | namespace InterviewQuestions
2 | {
3 | ///
4 | /// Write some code in the method below that will cause a stack overflow exception
5 | ///
6 | public class Question8
7 | {
8 | public void CauseStackOverflowException()
9 | {
10 |
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 09 - Asyncronous Programming.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | namespace InterviewQuestions
4 | {
5 | ///
6 | /// What will happen when I execute the DoWork method? write your answer below
7 | ///
8 | ///
9 | /// Answer:
10 | ///
11 | ///
12 | public class Question9
13 | {
14 | private readonly IRepository _database;
15 |
16 | private Question9(IRepository database)
17 | {
18 | _database = database;
19 | }
20 |
21 | public void DoWork()
22 | {
23 | var dbObject = GetObjectByIdAsync(5);
24 | DoMoreWork(dbObject.Result);
25 | }
26 |
27 | private void DoMoreWork(DatabaseObject obj)
28 | {
29 | throw new NotImplementedException();
30 | }
31 |
32 | private async Task GetObjectByIdAsync(int id)
33 | {
34 | var dbObject = await _database.GetObjectFromDatabaseAsync(id);
35 | return dbObject;
36 | }
37 |
38 | private interface IRepository
39 | {
40 | Task GetObjectFromDatabaseAsync(int id);
41 | }
42 |
43 | private class DatabaseObject
44 | {
45 | public int Id { get; set; }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 10 - Lazy Loading.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices.WindowsRuntime;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace InterviewQuestions
9 | {
10 | ///
11 | /// Implement lazy loading on memory heavy thing, do not use the Lazy class
12 | ///
13 | public class Question10
14 | {
15 | public IMemoryHeavyThing MemoryHeavyThing { get; set; }
16 |
17 | public Question10()
18 | {
19 |
20 | }
21 |
22 | public interface IMemoryHeavyThing
23 | {
24 |
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 11 - SOLID Principles.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Write some theoretical code that satisfies the following user stories. Please VIOLATE the solid principles as much as you possibly can.
11 | ///
12 | /// Given I am answering question 11
13 | /// When I process entities
14 | /// Then only items that have not been updated in the last week will be processed
15 | ///
16 | /// Given I am answering question 11
17 | /// When I process entities
18 | /// Then items being processed will '- done' appended to the end of their name
19 | /// And they will be marked as updated
20 | ///
21 | public class Question11
22 | {
23 | private IDatabase _db;
24 |
25 | public Question11(IDatabase db)
26 | {
27 | _db = db;
28 | }
29 |
30 | public void Process()
31 | {
32 |
33 | }
34 |
35 | #region Set Up Classes - Please look
36 |
37 | public interface IDatabase where T : IEntity
38 | {
39 | ISession OpenSession();
40 | }
41 |
42 | public interface ISession : IDisposable where T : IEntity
43 | {
44 | IQueryable GetObjects();
45 |
46 | void Insert(T entity);
47 |
48 | void SaveChanges();
49 | }
50 |
51 | public interface IEntity
52 | {
53 | int Id { get; set; }
54 |
55 | string Name { get; set; }
56 |
57 | DateTimeOffset LastUpdated { get; set; }
58 | }
59 |
60 | #endregion
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 12 - SOLID Principles.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace InterviewQuestions
9 | {
10 | ///
11 | /// Write some theoretical code that satisfies the following user stories. Please ADHERE the solid principles as much as you possibly can.
12 | /// Aim to copy your answer from question 11 as much as possible, adding comments to explain why you have made any changes when turning your non-solid code into good code.
13 | ///
14 | /// Given I am answering question 12
15 | /// When I process entities
16 | /// Then only items that have not been updated in the last week will be processed
17 | ///
18 | /// Given I am answering question 12
19 | /// When I process entities
20 | /// Then items being processed will '- done' appended to the end of their name
21 | /// And they will be marked as updated
22 | ///
23 | public class Question12
24 | {
25 | private IDatabase _db;
26 |
27 | public Question12(IDatabase db)
28 | {
29 | _db = db;
30 | }
31 |
32 | public void Process()
33 | {
34 |
35 | }
36 |
37 |
38 | #region Set Up Classes - Please look
39 |
40 | public interface IDatabase where T : IEntity
41 | {
42 | ISession OpenSession();
43 | }
44 |
45 | public interface ISession : IDisposable where T : IEntity
46 | {
47 | IQueryable GetObjects();
48 |
49 | void Insert(T entity);
50 |
51 | void SaveChanges();
52 | }
53 |
54 | public interface IEntity
55 | {
56 | int Id { get; set; }
57 |
58 | string Name { get; set; }
59 |
60 | DateTimeOffset LastUpdated { get; set; }
61 | }
62 |
63 | #endregion
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 13 - Big O Notation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Write some code that could be described in Big O notation as O(n^2)
11 | ///
12 | public class Question13
13 | {
14 | public List TheO { get; set; }
15 |
16 | public void DoSomethingToTheListUsingONotation()
17 | {
18 |
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 14 - Sorting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Without using any kind of .Sort or OrderBy Method or touching the constructor (other than one you make yourself) re-arrange the Numbers list into numerical order
11 | /// Hint: I'm looking for loops
12 | ///
13 | public class Question14
14 | {
15 | public List Numbers { get; set; }
16 |
17 | public Question14()
18 | {
19 | Numbers = new List()
20 | {
21 | 1,9,32,5,2,6,4,2,7
22 | };
23 | }
24 |
25 | public void Answer()
26 | {
27 |
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/InterviewQuestions/Question 15 - Logic Puzzles.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace InterviewQuestions
8 | {
9 | ///
10 | /// Without creating another variable, write code to swap around the values of firstNumber and secondNumber
11 | ///
12 | public class Question15
13 | {
14 | public void SwitchNumbers(int firstNumber, int secondNumber)
15 | {
16 |
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Interview Questions
2 | An open source solution with questions that you would expect any candidate worth hiring at a mid-level / senior role to be able to answer.
3 |
4 | The solution provided here is not supposed to be a catch all for developers, but more a base check of competancy in a C# development - A pre-screen to see if someone is worth taking to the next step in an interview process. You should absolutely be questioning candidates before, during and after this test. As well as giving them a further test (or a forked version of this repo) with more questions that are specific to your companies set-up.
5 | For questions you may consider asking, consider using some of the ones inside [this great GitHub Repo](https://github.com/arialdomartini/Back-End-Developer-Interview-Questions). I will potentially add some questions of my own into the wiki or readme as time goes on.
6 |
7 | This test should be taken on a PC with no iternet access. As candidates should not need to pull down any nuget packages and they should also already know the rules stated. If you do provide internet access for these questions, remember to check the browser history of the machine you gave access to. A candidate who has to google how to do asyncronous programming is will likely be a bad candidate. - Don't give them a machine with 0 internet history too, as you will not be able to identify if the candidate has cleared their browsing history.
8 |
9 | ## Contributing
10 | Feel free to contribute by forking this project and adding, removing and refactoring questions as you see fit.
11 |
12 | For your PR to be merged, it must not include any web, xamarin or 'coding street' questions. The current questionaire is just for core c# coding practices.
13 |
14 | If you want to add questions about a 'coding street' please add a new project into the solution and prefix it with InterviewQuestions (i.e: InterviewQuestions.Web.Mvc)
15 |
--------------------------------------------------------------------------------