DEV Community

Lou Willoughby
Lou Willoughby

Posted on

The Joy of Sharing: Why Developers Should Geek Out More

Hi, I'm Lou,

I've been coding for a while now, creating an assortment of projects from animations to landing pages, games, and responsive design. As a developer, one of the things that excites me the most is the satisfaction of creating something new and exciting.

However, one of the more mentally challenging things that I face is the lack of enthusiasm from others when I share my projects or just want to geek out about something coding related.
While I can talk about these things with my colleagues, friends, and family, most of the time, I’m returned with blank stares as they either don't quite understand or simply, don’t care.

It’s not seeking validation from others but more wanting to share the passion and excitement I feel. I think that it's great to celebrate our accomplishments ourselves but also when you see something so slick that you or someone else has made or you’ve seen online and it makes you go 🤩👀 then you look around and there’s no one you can show it to! 😓
Do you remember as a child, the thrill of bringing home a handmade project and showing it off to your parents. The same feeling of joy still exists in me today when I build something new and exciting.

By celebrating our accomplishments and sharing our passion with others, we can inspire and motivate each other to keep pushing ourselves to new heights, and let's not forget to celebrate our hard work and success along the way.

In conclusion, being a developer is challenging, but by focusing on the joy of creating and sharing our passion with others, we can overcome the challenges and continue to grow and learn in our field 🙏🏻

What have you built or learnt recently that you’ve been excited to talk about?

Top comments (1)

Collapse
 
mykezero profile image
Mykezero

I made a dotnet cli tool that will convert CSharp classes into GraphQL types.

The tool takes classes with the following format and generates the appropriate GraphQL type using regular expressions to extract the needed information:

[Theory]
[InlineData("int", "Int!")]
[InlineData("long", "Int!")]
[InlineData("string", "String!")]
[InlineData("bool", "Boolean!")]
[InlineData("double", "Float!")]
[InlineData("decimal", "Float!")]
[InlineData("DateTime", "AWSDateTime!")]
[InlineData("TimeSpan", "AWSTime!")]
[InlineData("List<int>", "[Int!]!")]
[InlineData("List<int>?", "[Int!]")]
[InlineData("List<int?>", "[Int]!")]
[InlineData("List<int?>?", "[Int]")]
public void Class_WithPropertyType_GeneratesCorrectGraphQLType(string actual, string expected)
{
    // Fixture setup
    // Exercise system
    GraphSchema schema = TypeGenerator.Generate($@"
        public class Test 
        {{
            public {actual} Value {{ get; set; }}
        }}
    ");
    // Verify outcome
    GraphType? graphType = schema.GetGraphType("Test");
    GraphField? graphField = graphType.GetGraphField("Value");
    Assert.Equal(expected, graphField.DataType);
    // Teardown
}
Enter fullscreen mode Exit fullscreen mode

It's absolutely wild what you can build just using regular expressions, the first one is not for the faint of heart xD:

Regex PropertyRegex = new("(?:\\[JsonProperty\\(\"(?<JsonName>\\w+)\"(?:.*?)\\)\\]\\s+(?:\\[.*\\]\\s+.*)?)?\\s+public\\s+(?!class)(?:virtual\\s+)?(?:new\\s+)?(?:static\\s+)?(?<DataType>(?<EnumerableName>\\w+)?<?\\w+\\??>?\\??)\\s+(?<PropertyName>\\w+)");
Regex ClassNameRegex = new(".*(?:public|internal|private)\\s+class\\s+(?<ClassName>\\w+).*");
Regex IsEnumerableRegex = new("(?:IEnumerable|List|IList|ICollection)<\\w+(?<IsEnumerableDataTypeNullable>\\?)?>\\??");
Regex IsNullableRegex = new("(?:[\\w<>?])+\\?$"
Enter fullscreen mode Exit fullscreen mode

Essentially, they extract all the information from a CSharp class into the following format:

  • ClassName: Test
  • PropertyName: Value
  • JsonName: value
  • DataType: int
  • IsNullable: false
  • IsEnumerable: false
  • IsEnumerableDataTypeNullable: false

Then, the TypeGenerator takes that information and assembles it into this nice GraphQL type (for the int data type)

type Test {
    Value: Int!
}
Enter fullscreen mode Exit fullscreen mode

I've packaged that all into a dotnet cli tool that the team could use to avoid having to manually convert these classes by hand (there were 63 files to convert..)

Now we can just run the command to get the results:

Image description

And 96% percent code coverage; haven't written anything using TDD in a while, so this was very fun to put together! Also got to learn a lot more about regular expressions as well along the way.