Skip to content

Instantly share code, notes, and snippets.

View micahasmith's full-sized avatar

Micah Smith micahasmith

View GitHub Profile
@micahasmith
micahasmith / PeopleRepository.js
Created October 3, 2011 01:43
The Repository Pattern in JavaScript
function PeopleRepository() {
//when using constructor functions like this one to create objects in js,
//always make sure you're doing so with the new keyword
//or the scope will be off
//
//like so:
if(!(this instanceof PeopleRepository) {
return new PeopleRepository();
//we just enforced new
}
@micahasmith
micahasmith / PeopleRepository.cs
Created October 3, 2011 01:29
The Repository Pattern in .NET
public class PeopleRepository
{
public List<PersonDTO> Get()
{
//return a list of person data transfer objects here
}
public void Insert(PersonDTO person)
{
//insert a person here
@micahasmith
micahasmith / classic-DAL.cs
Created October 3, 2011 01:22
The Classic DAL in .NET
public class PeopleDAL
{
public DataSet Person_GetAll()
{
//Returns a DataSet containing all people records in the database.
}
public DataSet Person_GetByPersonID(int personID)
{