klincecum
(Kevin Lincecum)
August 23, 2024, 4:46pm
1
So, Iām working on my own little email templating system kind of like @hkeric.wci and @jgiese.wci
And Iām going through and mostly cleaning up all my test code, and turning it into production code, because as much as I want to play with it, I need it yesterday .
I find myself going through and refactoring this little bit here, that little bit thereā¦
Make this a helper Func<T>, etc, etcā¦
And I keep running into, āWell damn thatās useful, it should be its own standalone function.ā
So I do it.
And now Iām tired. Because then you have to make that all nice and production ready too, because you know you will reuse it.
I just donāt wanna!
Sometimes I just want to build a big monolith and move on with my day.
Iām gonna do it, but ā¦
3 Likes
josecgomez
(Jose C Gomez)
August 23, 2024, 4:48pm
3
Its called Tech Debt!
Just go into debt solve the problem and come back and fix it later.,ā¦ (says every dev ever who never goes back and fixes shit)
9 Likes
Banderson
(Brandon Anderson)
August 23, 2024, 4:49pm
4
Not to mention, itās hard to spend time on making things pretty when they go obsolete so fast, itās hard to know if itās worth it.
4 Likes
josecgomez
(Jose C Gomez)
August 23, 2024, 4:50pm
5
We call those Ugly babies in our company. I have a couple the biggest one is called PG Order is 2K-4K lines of C# code in a classic customization that only me and God knew what it did when I wrote it and these days only God knows but it runs 50% of our business so it has to keep running. We are slowly replacing it.
@Banderson has a couple of ugly babies on his side too it happens
5 Likes
klincecum
(Kevin Lincecum)
August 23, 2024, 4:51pm
7
josecgomez:
Tech Debt!
Been thereā¦ done thatā¦
Got theā¦
Iāve mostly learned my lesson.
1 Like
klincecum
(Kevin Lincecum)
August 23, 2024, 4:54pm
8
josecgomez:
Ugly babies
I had one in Vantage.
We called it RollMaster. It was a standalone app that tied into Vantage, originally just to manage getting inventory in like we wanted.
Eventually everything tied into it. It was pretty well designed, but it was my (not completely) ugly baby.
Ran 80% of our business.
I was both sad and ecstatic to see it go when we moved to 10.
1 Like
knash
(Ken Nash)
August 23, 2024, 4:58pm
9
Sounds like a slogan for EpiUsers.
Ugly Babies: Code Only God and an EpiUser Understand, Keeping the Business Running One Line at a Time!
5 Likes
klincecum
(Kevin Lincecum)
August 23, 2024, 4:59pm
10
Banderson:
finally got tired?
Donāt confuse ADHD with an abundance of energy.
I run on coffee and curiosity.
Me Inside ā
4 Likes
klincecum
(Kevin Lincecum)
August 23, 2024, 5:07pm
11
Here was the little bit that prompted the thread:
ReplaceStringsFromDictionary
Replaces strings based on a dictionary. Uses a regular expression or looping. Default regular expression is replace dictionary āKeysā between braces " {Key} " with dictionary āValueā. Looping is a straight replacement of āKeyā with āValueā.
//Helper Functions Section----------------------------------------------------------------------------------------------------------------------------------------->
Func<Exception, string, string> AddExceptionToList = (exception, exceptionListJson) =>
{
List<Exception> exceptionList = new List<Exception>(){exception};
if(!String.IsNullOrEmpty(exceptionListJson)) { try { exceptionList.AddRange( JsonConvert.DeserializeObject<List<Exception>>(exceptionListJson) ); } catch {} }
return JsonConvert.SerializeObject(exceptionList);
};
//<-----------------------------------------------------------------------------------------------------------------------------------------Helper Functions Section
try
{
Success = true; //Assume true
var replacementDictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(ReplacementDictionaryJson);
OutputString = InputString; //Preserve InputString for easy compare
if(!UseRegex) // Looping
{
foreach(var item in replacementDictionary)
{
OutputString = OutputString.Replace(item.Key, item.Value);
}
return; //Done
}
//Regex
string defaultRegexString = @"{(.+?)}"; //Replaces everything inside the braces {key} with value, including the braces
//A regex was not prrovided, use default
if(String.IsNullOrEmpty(RegexString)) RegexString = defaultRegexString;
OutputString = System.Text.RegularExpressions.Regex.Replace(OutputString, RegexString, match =>
{
if(replacementDictionary.ContainsKey(match.Groups[1].Value))
{
return replacementDictionary[match.Groups[1].Value];
}
return $"KeyNotFound( \"{match.Groups[1].Value}\" )";
});
}
catch (Exception ex)
{
Success = false;
ListErrorJson = AddExceptionToList(ex, ListErrorJson);
}
finally
{
//Log?
}
This is a hell of an assumption
Do or do not. There is no try.
5 Likes
utaylor
(Utah Taylor)
August 23, 2024, 5:10pm
14
Itās nice to know that everyone has these things hanging outā¦
3 Likes
klincecum
(Kevin Lincecum)
August 23, 2024, 5:10pm
15
I went back and forth on that one.
I figured I was more likely to remember to say I screwed up in the code, than say I didnāt.
Any actual exceptions set it false.
Itās Friday. I was going full-on existentialist and life-choice-questioning with my comment. Success? Pah.
1 Like
klincecum
(Kevin Lincecum)
August 23, 2024, 5:16pm
17
Just popped on linked in and saw this lolā¦
5 Likes
klincecum
(Kevin Lincecum)
August 23, 2024, 5:33pm
18
Dammit!
Going through here, just remembered I added the ability to add templates from templates likeā¦
{MessageTemplate.LetterheadLogo}
ā {[TableName].[MessageTemplateID]}
where it pulls the body for another template into this one.
Guess Iām breaking that out next.
1 Like
josecgomez
(Jose C Gomez)
August 23, 2024, 6:26pm
19
This is called scope creep and if you donāt nip it in the bud youāll never get anything done!
6 Likes
klincecum
(Kevin Lincecum)
August 23, 2024, 6:30pm
20
A little, but I do actually plan to reuse that piece.
(Of course my reuse may not fit very well, still evaluating)