Created
June 20, 2012 15:15
-
-
Save frockenstein/2960411 to your computer and use it in GitHub Desktop.
Code Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# | |
int totalrows = 1000; | |
int processed = 0; | |
while (processed < totalrows) | |
{ | |
processRow(); | |
// bug: infinite loop - we never increment processed var | |
} | |
// SqlClient | |
SqlConnection con; | |
using (con = new SqlConnection("Data Source=(local);Initial Catalog=myDataBase;Integrated Security=SSPI;")) | |
{ | |
DataTable dt = new DataTable(); | |
SqlDataAdapter da = new SqlDataAdapter("select * from person", con); | |
da.Fill(dt); // bug: dt won't be available to code below - should be outside of using statement | |
} | |
foreach (DataRow row in dt) // bug: should be dt.Rows | |
{ | |
processRow(); | |
} | |
// JS | |
var agent = { | |
leads: [], | |
init: function() { | |
$.get('/agent/1', function(data) { | |
this.leads = data; // bug: this !== agent | |
}); | |
} | |
}; | |
agent.init(); | |
// SQL | |
select l.* from listing | |
join listingphoto lp on lp.listingid = l.listingid -- l.* will fail because no alias declared | |
where l.boardid = 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment