---
title: "Discussion on \"URL Shortener using Clean Architecture\" | Hashnode"
description: "Discussion on \"URL Shortener using Clean Architecture\". Clean Architecture by Robert C. Martin (Uncle Bob)"
url: "https://hashnode.com/posts/url-shortener-using-clean-architecture/61d522f5220e98797766a15c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [URL Shortener using Clean Architecture](https://hashnode.com/post/url-shortener-using-clean-architecture?utm_source=hashnode&utm_medium=feed)

Clean Architecture by Robert C. Martin (Uncle Bob)

Jan 5, 2022 · 9 min read · hashnode.com  
Read the article

-   [#clean-code](https://hashnode.com/tag/clean-code)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#express](https://hashnode.com/tag/express)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#best-practices](https://hashnode.com/tag/best-practices)

## Written by

[Vighnesh Kulkarni](https://hashnode.com/@vighneshk)

@vighneshk

  
[View profile](https://hashnode.com/@vighneshk)

Web Developer

## Responses 1

Markdown supported · ⌘↵ to post

[Jesse Bellingham](https://hashnode.com/@jessebellingham)

[Jan 17, 2022](https://hashnode.com/posts/url-shortener-using-clean-architecture/61d522f5220e98797766a15c/comment/61e540888a425719c1735e92)

Really nice article Vighnesh 🙌 super comprehensive. I have a question, and it may just be my lack of experience building with Node, but why do you use a builder function for the entity and have the validation be a separate function passed in? In .NET for example, the entity would be represented with a class (and optionally, interfaces), and if you were aiming for rich domain objects rather than anemic ones, you might have the validation be a part of the class's constructor.

Is the way you've got it here a common node pattern?

[Vighnesh Kulkarni](https://hashnode.com/@vighneshk)

[Feb 12, 2022](https://hashnode.com/posts/url-shortener-using-clean-architecture/61d522f5220e98797766a15c/comment/61e540888a425719c1735e92#reply-62074870d59187113c4bf9b5)

Thank you Jesse! I've kept the validator function in a separate file because it uses a module called 'dns' from node which I had to import. So, I did not want the entity to directly depend upon any framework/library. Just separation of concerns.

Is the way you've got it here a common node pattern? ---> Actually the framework I've used is Express.js(Nodejs framework) and it doesn't follow any pattern/architecture. It's completely flexible. This is the first time I'm following any architecture and still exploring, so I might be wrong on some parts😅.

Sorry for a really late reply :(
