Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elsevier interview submission #278

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added dot-net/.DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions dot-net/UnitTesting/.vs/WriteUnitTest/xs/UserPrefs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Properties StartupConfiguration="{00A40A05-8314-4F25-A444-46DDEAC3497E}|Default">
<MonoDevelop.Ide.Workbench>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
<Node name="WriteUnitTest" expanded="True">
<Node name="WriteUnitTest" expanded="True">
<Node name="INSTRUCTIONS.txt" selected="True" />
</Node>
<Node name="WriteUnitTest.UnitTests" expanded="True">
<Node name="Properties" expanded="True" />
<Node name="Services" expanded="True" />
</Node>
</Node>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.ItemProperties.WriteUnitTest PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MultiItemStartupConfigurations />
</Properties>
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8792527b0a7f3837ea6da48d383dd93cf15384de
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9d509945367841048aba1c4429dd1813304e4462
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
C:\Users\lyncha1\SourceCode\interviews\dot-net\UnitTesting\WriteUnitTest\bin\Debug\WriteUnitTest.exe.config
C:/Users/lyncha1/SourceCode/interviews/dot-net/UnitTesting/WriteUnitTest/bin/Debug/WriteUnitTest.exe.config
/Users/MichaelJennings/Code/elsevier/dotnet/interviews/dot-net/UnitTesting/WriteUnitTest/bin/Debug/WriteUnitTest.exe.config
/Users/MichaelJennings/Code/elsevier/dotnet/interviews/dot-net/UnitTesting/WriteUnitTest/bin/Debug/WriteUnitTest.exe
/Users/MichaelJennings/Code/elsevier/dotnet/interviews/dot-net/UnitTesting/WriteUnitTest/bin/Debug/WriteUnitTest.pdb
/Users/MichaelJennings/Code/elsevier/dotnet/interviews/dot-net/UnitTesting/WriteUnitTest/obj/Debug/WriteUnitTest.csprojAssemblyReference.cache
/Users/MichaelJennings/Code/elsevier/dotnet/interviews/dot-net/UnitTesting/WriteUnitTest/obj/Debug/WriteUnitTest.csproj.CoreCompileInputs.cache
/Users/MichaelJennings/Code/elsevier/dotnet/interviews/dot-net/UnitTesting/WriteUnitTest/obj/Debug/WriteUnitTest.exe
/Users/MichaelJennings/Code/elsevier/dotnet/interviews/dot-net/UnitTesting/WriteUnitTest/obj/Debug/WriteUnitTest.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
32 changes: 32 additions & 0 deletions dot-net/WhatWouldYouChange/.vs/ExampleProgram/xs/UserPrefs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Properties StartupConfiguration="{30B4042C-447C-42A3-A237-1303FCA6FED9}|Default">
<MonoDevelop.Ide.Workbench ActiveDocument="INSTRUCTIONS.txt">
<Files>
<File FileName="Program.cs" Line="15" Column="10" />
<File FileName="ExampleClass.cs" Line="17" Column="49" />
<File FileName="INSTRUCTIONS.txt" Line="16" Column="20" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
<Node name="ExampleProgram" expanded="True">
<Node name="ExampleProgram" expanded="True">
<Node name="INSTRUCTIONS.txt" selected="True" />
</Node>
</Node>
</State>
</Pad>
<Pad Id="MonoDevelop.UnitTesting.TestPad">
<State name="__root__">
<Node name="ExampleProgram" expanded="True" selected="True" />
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.ItemProperties.ExampleProgram PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MultiItemStartupConfigurations />
</Properties>
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions dot-net/WhatWouldYouChange/ExampleClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public void ExampleMethod(string exampleTextFile)
var fs = File.Open(exampleTextFile, FileMode.Open);
var streamReader = new StreamReader(fs);
text = streamReader.ReadToEnd();

}
catch
{
Expand Down
29 changes: 29 additions & 0 deletions dot-net/WhatWouldYouChange/ExampleProgram.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('packages\NUnit.3.11.0\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -41,6 +42,33 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor">
<HintPath>packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure">
<HintPath>packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System.Web.Helpers">
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment">
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages">
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor">
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc">
<HintPath>packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ExampleClass.cs" />
Expand All @@ -49,6 +77,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="ExampleText.txt">
Expand Down
21 changes: 20 additions & 1 deletion dot-net/WhatWouldYouChange/INSTRUCTIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,23 @@


Suggested Changes:

1. The first thing I would change is the try...catch. I am drawing similarities between this and promises from javascript.
When I try to fetch some data or pull from a file, I want to see this actually worked or not. To do this, I would use the catch
to throw an error. The way the try...catch is written now is basically saying "Try to pull from the text file. If you can't,
let's just hard code it line by line." The reason why this is a bad idea is because what your program is today might
not be what your program is a week or a month from now. You want to make sure it can adapt. Let's say that the ExampleText.txt
file is a living txt file that updates on a weekly basis. If you build the try...catch with hard coded values, your output will
never show the most recent file (if it's not working properly) and your users would be none the wiser. If you threw an error
instead you would know right away that something went wrong in the process and you can start to debug your code from there.
2. Piggybacking off of the first point, the try doesn't actually ever work the way that it's written. Program.cs line 11 is missing a period.
I noticed this when running the code through debug mode with a break point on line 11. If you step into from there, you start to see that
the try isn't working and it's going right to the catch. If you change line 11 in Program.cs to `exampleClass.ExampleMethod("ExampleText.txt");`
it starts working as intended.
3. If the purpose of this program is just to return some text, I think it would be better if you just return the text right in ExampleMethod.
To clean up the code a bit based on my third point:
A. ExampleClass.cs
- Delete line 7.
- replace whats on line 50 with `System.Console.WriteLine(text);`
B. Program.cs
- Delete line 13 and 14.
The program performs the same as it did before with less code.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Binary file not shown.
13 changes: 13 additions & 0 deletions dot-net/WhatWouldYouChange/bin/Debug/ExampleText.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non pulvinar sapien, nec accumsan justo. Suspendisse
facilisis auctor tortor, a maximus erat feugiat eu. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin at
euismod nisi, egestas imperdiet turpis. Ut scelerisque diam sit amet tincidunt mollis. Curabitur eu quam ultricies,
tincidunt augue et, lobortis diam. Suspendisse pharetra aliquet augue. Duis eu sollicitudin erat. Integer luctus
euismod suscipit. In erat nulla, aliquet id consequat nec, luctus nec justo. In at gravida est, semper elementum nisi.
Phasellus interdum dapibus massa, sed volutpat odio rhoncus a. Proin pellentesque quam non justo sodales eleifend.
Curabitur ornare arcu id mauris porta vehicula.

Donec vehicula metus purus. Nulla ut augue eros. Mauris scelerisque justo nibh, non suscipit dui egestas sit amet.
Vestibulum et magna pharetra, auctor eros sit amet, mollis neque. Vestibulum ultricies dolor diam, id semper sem
ultricies eget. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed nec pulvinar orci. Donec sed nisl
varius, mollis enim auctor, placerat sapien. Vivamus accumsan dui neque, eu tincidunt elit venenatis vel. Sed pharetra
elit sed gravida convallis.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading