Skip to content

Instantly share code, notes, and snippets.

@juristr
Created December 31, 2010 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save juristr/760856 to your computer and use it in GitHub Desktop.
Save juristr/760856 to your computer and use it in GitHub Desktop.
Taken from a #smellycode post, just to demonstrate the usage fo gist in code reviews
public Account ReadCompleteAccountByADUsernameAndServiceUID(string adUsername, string serviceInstanceUID)
{
    IList<Address> addresses;
    IList<Contact> contacts;
 
//Attention, directly instantiating an object within the method may potentially create
//problems when doing testing 'cause its dependency cannot be mocked out.
    MasterDataBL masterDataBL = new MasterDataBL();
 
    Account result =  AccoDao.ReadCompleteAccountByADUsernameAndServiceUID(adUsername, serviceInstanceUID, ConnectionString.Master, out addresses, out contacts);
 
    result.PhoneNumber = contacts.Where(x => x.ContactType.Id == masterDataBL.GetCachedContactTypeByUid(ContactType.WellKnownUid.PHONE).Id).FirstOrDefault();
    result.MobilePhone = contacts.Where(x => x.ContactType.Id == masterDataBL.GetCachedContactTypeByUid(ContactType.WellKnownUid.MOBILE).Id).FirstOrDefault();
 
    result.Residence = addresses.Where(x => x.AddressTypeId == masterDataBL.GetCachedAddressTypeByUid(AddressType.WellKnownUid.RESIDENCE).Id).FirstOrDefault();
    result.Domicile = addresses.Where(x => x.AddressTypeId == masterDataBL.GetCachedAddressTypeByUid(AddressType.WellKnownUid.DOMICILE).Id).FirstOrDefault();
 
    return result;
}
@juristr
Copy link
Author

juristr commented Dec 31, 2010

Feel free to make your edits here or add any comments. Note, this is just an example taken from one of my #smellycode posts (http://blog.js-development.com/2010/12/smelly-code-direct-object-instantiation.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment