Last active
January 11, 2021 22:21
-
-
Save JoshuaTheMiller/4c9b21ecfa6bd7efe3acbbfaf4c20c11 to your computer and use it in GitHub Desktop.
Revisions
-
JoshuaTheMiller revised this gist
Jan 11, 2021 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,5 +14,9 @@ class weatherForecasterService{ } } function useWeatherForecaster(weatherForecaster) { console.log(weatherForecaster.generateWeatherForecast("Minnesota")) } const weatherForecaster = new weatherForecasterService(); useWeatherForecaster(weatherForecaster); -
JoshuaTheMiller renamed this gist
Jan 11, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
JoshuaTheMiller revised this gist
Jan 11, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ This Gist and the associated files were created to support an article on Feature Flags (to be linked) -
JoshuaTheMiller revised this gist
Jan 11, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ This Gist and the associated were created to support an article on Feature Flags (to be linked) -
JoshuaTheMiller revised this gist
Jan 11, 2021 . 5 changed files with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,13 +6,13 @@ function appendAmountOfRain(forecast) { return `${forecast} with 3cm of rain`; } class weatherForecasterService{ generateWeatherForecast(location) { const forecast = buildForecast(location); // We have been asked to insert appendAmountOfRain(...) here return forecast; } } const weatherForecaster = new weatherForecasterService(); console.log(weatherForecaster.generateWeatherForecast("Minnesota")) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ const weatherForecasterService = { generateWeatherForecast: function (location) { let forecast = buildForecast(location); if(process.env.CURRENT_ENVIRONMENT === "nonprod") { This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ const features = getFeatureFlagServiceFromSomewhere() class weatherForecasterService{ generateWeatherForecast(location) { let forecast = buildForecast(location); if(features.isEnabled("amount-of-rain")) { This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ const featureDecisions = getFeatureDecisionServiceFromSomewhere() class weatherForecasterService{ generateWeatherForecast(location) { let forecast = buildForecast(location); if(featureDecisions.appendAmountOfRainToForecast()) { This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ class weatherForecasterService{ constructor(options) { this.options = options ?? { appendAmountOfRainToForecast: false @@ -13,14 +13,14 @@ class weatherForcasterService{ } } class featureAwareWeatherForecasterServiceFactory{ build() { const options = { appendAmountOfRainToForecast: featureDecisions.appendAmountOfRainToForecast() } return new weatherForecasterService(options); } } const weatherForecaster = new featureAwareWeatherForecasterServiceFactory().build(); -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 4 changed files with 33 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,13 +6,13 @@ function appendAmountOfRain(forecast) { return `${forecast} with 3cm of rain`; } class weatherForcasterService{ generateWeatherForecast(location) { const forecast = buildForecast(location); // We have been asked to insert appendAmountOfRain(...) here return forecast; } } const weatherForecaster = new weatherForcasterService(); console.log(weatherForecaster.generateWeatherForecast("Minnesota")) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ const features = getFeatureFlagServiceFromSomewhere() class weatherForcasterService{ generateWeatherForecast(location) { let forecast = buildForecast(location); if(features.isEnabled("amount-of-rain")) { forecast = appendAmountOfRain(forecast) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ const featureDecisions = getFeatureDecisionServiceFromSomewhere() class weatherForcasterService{ generateWeatherForecast(location) { let forecast = buildForecast(location); if(featureDecisions.appendAmountOfRainToForecast()) { forecast = appendAmountOfRain(forecast) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ class weatherForcasterService{ constructor(options) { this.options = options ?? { appendAmountOfRainToForecast: false } } generateWeatherForecast(location) { let forecast = buildForecast(location); if(this.options.appendAmountOfRainToForecast) { forecast = appendAmountOfRain(forecast) } return forecast; } } class featureAwareWeatherForcasterServiceFactory{ build() { const options = { appendAmountOfRainToForecast: featureDecisions.appendAmountOfRainToForecast() } return new weatherForcasterService(options); } } const weatherForecaster = new featureAwareWeatherForcasterServiceFactory().build(); -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,9 @@ const weatherForcasterService = { generateWeatherForecast: function (location) { let forecast = buildForecast(location); if(process.env.CURRENT_ENVIRONMENT === "nonprod") { forecast = appendAmountOfRain(forecast) } return forecast; } } -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,5 +14,5 @@ const weatherForcasterService = { } } const weatherForecaster = weatherForcasterService; console.log(weatherForecaster.generateWeatherForecast("Minnesota")) -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,4 +14,5 @@ const weatherForcasterService = { } } const weatherForecaster = weatherForcasterService console.log(weatherForecaster.generateWeatherForecast("Minnesota")) -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 1 changed file with 1 addition and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,9 +14,4 @@ const weatherForcasterService = { } } console.log(weatherForcasterService.generateWeatherForecast("Minnesota")) -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 3 changed files with 28 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,17 @@ function appendAmountOfRain(forecast) { return `${forecast} with 3cm of rain`; } const weatherForcasterService = { generateWeatherForecast: function (location) { const forecast = buildForecast(location); // We have been asked to insert appendAmountOfRain(...) here return forecast; } } function retrieveWeatherForecaster() { return weatherForcasterService; } const weatherForecaster = retrieveWeatherForecaster() console.log(weatherForecaster.generateWeatherForecast("Minnesota")) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,10 @@ const features = getFeatureFlagServiceFromSomewhere() const weatherForcasterService = { generateWeatherForecast: function (location) { let forecast = buildForecast(location); if(features.isEnabled("amount-of-rain")) { forecast = appendAmountOfRain(forecast) } return forecast; } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,10 @@ const featureDecisions = getFeatureDecisionServiceFromSomewhere() const weatherForcasterService = { generateWeatherForecast: function (location) { let forecast = buildForecast(location); if(featureDecisions.appendAmountOfRainToForecast()) { forecast = appendAmountOfRain(forecast) } return forecast; } } -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 2 changed files with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ const featureDecisions = getFeatureDecisionServiceFromSomewhere() function generateWeatherForecast(location) { let forecast = buildForecast(location); if(featureDecisions.appendAmountOfRainToForecast()) { forecast = appendAmountOfRain(forecast) } return forecast; } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ const features = getFeatureFlagServiceFromSomewhere() const featureDecisionObject = { appendAmountOfRainToForecast: function() { return features.isEnabled("amount-of-rain") } } function getFeatureDecisionServiceFromSomewhere() { return featureServiceObject } -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ const features = getFeatureFlagServiceFromSomewhere() function generateWeatherForecast(location) { let forecast = buildForecast(location); if(features.isEnabled("amount-of-rain")) { This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,6 @@ const featureServiceObject = { } } function getFeatureFlagServiceFromSomewhere() { return featureServiceObject; } -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 4 changed files with 6 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,12 @@ function buildForecast(location) { return `The forecast for ${location} is "cloudy"`; } function appendAmountOfRain(forecast) { return `${forecast} with 3cm of rain`; } function generateWeatherForecast(location) { const forecast = buildForecast(location); // We have been asked to insert appendAmountOfRain(...) here return forecast; } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,3 @@ function generateWeatherForecast(location) { let forecast = buildForecast(location); if(process.env.CURRENT_ENVIRONMENT === "nonprod") { This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,3 @@ const features = getFeatureServiceFromSomewhere() function generateWeatherForecast(location) { let forecast = buildForecast(location); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ function environemntIsNonProduction() { } const featureServiceObject = { isEnabled: function(flagName) { return environemntIsNonProduction() } } -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 2 changed files with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,7 @@ function appendAmountOfRain(forecast) { return `${forecast} with 3cm of rain`; } const features = getFeatureServiceFromSomewhere() function generateWeatherForecast(location) { let forecast = buildForecast(location); if(features.isEnabled("amount-of-rain")) { This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,13 @@ function environemntIsNonProduction() { return process.env.CURRENT_ENVIRONMENT === "nonprod"; } const featureServiceObject = { isEnabled: function(toggleName) { return environemntIsNonProduction() } } function getFeatureServiceFromSomewhere() { return featureServiceObject; } -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 2 changed files with 9 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,3 @@ function buildForecast(location) { return `The forecast for ${location} is "cloudy"`; } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ function environemntIsNonProduction() { return false } const features = { isEnabled: function(toggleName) { return environemntIsNonProduction() } } -
JoshuaTheMiller revised this gist
Jan 7, 2021 . 3 changed files with 44 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ function buildForecast(location) { return `The forecast for ${location} is "cloudy"`; } function generateWeatherForecast(location) { const forecast = buildForecast(location); return forecast; This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,11 @@ function buildForecast(location) { return `The forecast for ${location} is "cloudy"`; } function appendAmountOfRain(forecast) { return `${forecast} with 3cm of rain`; } function generateWeatherForecast(location) { let forecast = buildForecast(location); if(process.env.CURRENT_ENVIRONMENT === "nonprod") { This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ function environemntIsNonProduction() { return false } // Some nonsense builder function to get this example rolling function featureToggleService() { const fnName = "isEnabled"; const someObj = {}; someObj[fnName] = function(toggleName) { // For any toggle, just check the env var return environemntIsNonProduction() }; return someObj; } const features = featureToggleService() function buildForecast(location) { return `The forecast for ${location} is "cloudy"`; } function appendAmountOfRain(forecast) { return `${forecast} with 3cm of rain`; } function generateWeatherForecast(location) { let forecast = buildForecast(location); if(features.isEnabled("amount-of-rain")) { forecast = appendAmountOfRain(forecast) } return forecast; } -
JoshuaTheMiller created this gist
Jan 7, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ function generateWeatherForecast(location) { const forecast = buildForecast(location); return forecast; } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ function generateWeatherForecast(location) { let forecast = buildForecast(location); if(process.env.CURRENT_ENVIRONMENT === "nonprod") { forecast = appendAmountOfRain(forecast) } return forecast; }