Navigation überspringen
Stop writing utility classes.
0:00 / 0:48

Stop writing utility classes.

Gautier 💙

@mcflyDev10.029 Follower

Auf X besuchen

19.626 Aufrufe

Stop writing utility classes. Utility classes are a sign that you are writing procedural code. You should avoid them. Instead, write a real object model. For example, an email is not a String... It's an Email. Gautier - 🤘

11 Kommentare

Kommentare aus dem Originalbeitrag auf X (Twitter)

  • Profilbild von Christian Findlay

    @CFDevelop

    I don’t write utility classes I write utility functions 👌

    5 Likes

  • Profilbild von PDF GPT

    @pdfgptsupport

    Everyone is getting ahead with AI. You should be too. Summarize documents, craft emails, and generate custom content instantly with this powerful tool. It's like having ChatGPT tailored for your job. Try it for free.

    13.783 Likes

  • Profilbild von Rody Davis

    @rodydavis

    Probably a good use of extension types for Email to implement String and also still provide validate methods.

    4 Likes

  • Profilbild von Francesco Vallone

    @francescovll

    In my opinion another approach is to use a validation library like Acanthis that will still remove the need for a utility class, while providing validation and parsing of the object. Everything is just a line of code string().email()

    4 Likes

  • Profilbild von Cillian Myles

    @IdiomaticBytes

    You didn’t give a concrete reason why your approach is better? Same validation everywhere? I don’t think that’s guaranteed any more than that a user imports the same util class everywhere. 🤔

    3 Likes

  • Profilbild von Nnaemeka Sidney

    @sidswipe

    .isEmail

    2 Likes

  • Profilbild von Dany | Mobile & Game Dev 🍉

    @yasfdany

    Ohhh I like this

    1 Like

  • Profilbild von Gautier 💙

    @mcflyDev

    🤘🏻

  • Profilbild von AbdulAzeez

    @dev_azeez

    Nice

    1 Like

  • Profilbild von jayson.kt

    @idiomaticdev

    it's not an email until after it's validated. it's a wannabe

    1 Like

  • Profilbild von Pangz (pangz.vrsc@)

    @PangzLab

    It doesn't add any value modeling the email as a different class instead of just leaving it by default as a string. You're using unnecessary resources just to wrap a simple string to a class just to make it appear as an object. You only need to validate it and that's it.(just my 2 cents)

    1 Like