Skip to content

Instantly share code, notes, and snippets.

View anthonydotnet's full-sized avatar

Anthony Dang anthonydotnet

View GitHub Profile
@anthonydotnet
anthonydotnet / git-dmz-flow.md
Created February 18, 2020 16:15 — forked from djspiewak/git-dmz-flow.md
Git DMZ Flow

Git DMZ Flow

I've been asked a few times over the last few months to put together a full write-up of the Git workflow we use at RichRelevance (and at Precog before), since I have referenced it in passing quite a few times in tweets and in person. The workflow is appreciably different from GitFlow and its derivatives, and thus it brings with it a different set of tradeoffs and optimizations. To that end, it would probably be helpful to go over exactly what workflow benefits I find to be beneficial or even necessary.

  • Two developers working on independent features must never be blocked by each other
    • No code freeze! Ever! For any reason!
  • A developer must be able to base derivative work on another developer's work, without waiting for any third party
  • Two developers working on inter-dependent features (or even the same feature) must be able to do so without interference from (or interfering with) any other parties
  • Developers must be able to work on multiple features simultaneously, or at lea
var globalNode = Getto.Get("theCacheKey", () => MyTreeCrawler.GetGlobalContentNode());
Caching result of https://gist.github.com/anthonydotnet/bbffa6db42d9bc933cfde053df67571d
public IPublishedContent GetGlobalContentNode()
{
var settingsNode = GetNonPageContentNode();
//Get the child folder node - Configuration Folder
var configFolder = settingsNode.Children.SingleOrDefault(x => x.DocumentTypeAlias == Constants.DocTypes.SiteConfigurationFolder);
if (configFolder == null) { return null; }
//Try & get the child External Services node
public IPublishedContent GetGlobalContentNode()
{
const string CacheKey = "Application.BusinessLogic.Services.GetGlobalContentNode";
var globalContentNode = HttpContext.Current.Items[CacheKey] as IPublishedContent;
if (globalContentNode == null)
{
var settingsNode = GetNonPageContentNode();
public void Main()
{
_service.OnCreate_HasConflict += _service_OnCreate_CustomEvent;
var response = _service.Create(model);
if (response is MyCustomResponse<Profile>)
{
// the conflict event was fired and already handled by custom logic
}
@anthonydotnet
anthonydotnet / Create method with event hooks
Created March 9, 2019 22:42
This method used to be really clean until I added the event hooks. Is there any cleaner way to code this?
public async Task<ICreateResponse<TEntity>> CreateAsync(TEntity poco)
{
bool exitMethod = false;
//-- Event: Method start
var eventResult = OnCreate_MethodStart != null ? OnCreate_MethodStart(poco, out exitMethod) : null;
if (exitMethod) { return eventResult; }
try
IBaseCrudResponse
{
StatusCode StatusCode;
}
ICrudGetResponse<TEntity>: IBaseCrudReponse
{
TEntity Data;
}
@anthonydotnet
anthonydotnet / gist:dff6440ae77129a803dc711de8747bc2
Last active March 7, 2019 07:30
Crud response with Typed entity in CreateAsync so you don't have to cast the entity later
This wouldn't work in my code, because ICrudResponse doesnt have Entity as a property. So it still requires casting.
ICrudResponse response;
// create 1
response = service.CreateAsync<Profile>(poco1).Result;
System.Console.WriteLine($"CreateAsync. {response.StatusCode}");
if (response.StatusCode == StatusCode.Created)
{
@anthonydotnet
anthonydotnet / gist:a82807b8b32c893d4c9c8f6f840e865c
Last active March 7, 2019 08:19
CRUD service returning strongly typed responses (with status codes) in c#
ICrudResponse response;
// create 1
response = service.CreateAsync(poco1).Result;
System.Console.WriteLine($"CreateAsync. {response.StatusCode}");
if (response is CreateResponse<Profile> typedCreateRes)
{
System.Console.WriteLine($"Success - Id {typedCreateRes.Entity.Id}");
}
I now only communicate via gists.
How's it going? Long time no see.