# \[Article\] RFC: Refactoring flows - with inline flow images!

**URL:** <https://discourse.nodered.org/t/article-rfc-refactoring-flows-with-inline-flow-images/79598>\
**Category:** General\
**Created:** [5 July 2023 09:20 UTC](https://discourse.nodered.org/t/article-rfc-refactoring-flows-with-inline-flow-images/79598 "2023-07-05T09:20:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [5 July 2023 09:20 UTC](https://discourse.nodered.org/t/article-rfc-refactoring-flows-with-inline-flow-images/79598/1 "2023-07-05T09:20:47Z")

</div>

Hi There!

Here is another bit of writing from me, this time refactoring Node-RED flows. I was thinking that refactoring seems to be a non-topic when it comes to flows or rather a _design patterns for flows_ discussion.

I'd love to get input and thoughts about this - I would like to do series aimed at beginners and non-Node-RED users.

Another novel feature is the use of the [flow viewer](https://discourse.nodered.org/t/standalone-flow-viewer-plugin/79388) - all images (except for the screenshots!) are generated on-the-fly from codeblocks.

I hope this can bring Node-RED to a new audience.

> **[Refactoring Node-RED flows: Duplicate computation | Open Mind Map Blog](http://blog.openmindmap.org/blog/refactoring-node-red-flows-duplicate-code)**
>
> How can Node-RED visual flows be refactored? Do we need to refactor them? How to handle code duplication in Node-RED? Find out!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 July 2023 10:13 UTC](https://discourse.nodered.org/t/article-rfc-refactoring-flows-with-inline-flow-images/79598/2 "2023-07-05T10:13:18Z")

</div>

Nice to see people writing blog posts for node-red 🙂

Refactoring IS quite often discussed but rarely, if ever, is it called that because that is a techie developer phrase. 😁

I think, though that you missed possibly the most important tool for refactoring - the link nodes.

Refactoring flows often starts with tidying the layout and then realising just how much duplication or redundancy you ended up with. Link nodes can help both with the tidying and with de-duplication.

Many of us much prefer linked flows to sub-flows in any case because the use of sub-flows actually DOES introduce duplication (each instance of the subflow being a duplicate of course).

As with traditional code, flow designers are likely to read flows far more than they ever amend them and so layout is critical to rapid understanding and memory of what the flow does. The use of groups (with titles) and comment nodes further enhances (when you do it right!) the comprehension. _Personally_, I would include all of this under the topic of refactoring.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [5 July 2023 10:50 UTC](https://discourse.nodered.org/t/article-rfc-refactoring-flows-with-inline-flow-images/79598/3 "2023-07-05T10:50:55Z")

</div>

> [@TotallyInformation](#):
>
> Nice to see people writing blog posts for node-red 🙂

And using Node-RED as software for the blog - dogfooding all the way down with the turtles! Sorry have to plug the flexibility of Node-RED here!

> [@TotallyInformation](#):
>
> the link nodes.

Yes! I did that on purpose since a) the text would have gotten far too long and b) this is aimed at beginners as intro to Node-RED - I don't want to overwhelm readers right off the bat!

> [@TotallyInformation](#):
>
> prefer linked flows to sub-flows

#metoo, I rarely use them but when, then with a specific and fixed purpose that isn't going to change.

> [@TotallyInformation](#):
>
> layout is critical to rapid understanding

Agree, hence my procrastination trap critic of Node-RED: the feeling of having done something by fixing the layout but that is a form of refactoring when visually coding. The number of times I ended up replacing or removing nodes because a layout didn't look "right".

I guess any boss when told (in the daily scrum meeting) "I fixed the layout of the flows" would roll their eyes and wonder how that could possibly be useful! 🙂

> [@TotallyInformation](#):
>
> _Personally_, I would include all of this under the topic of refactoring.

I see this also but boss' might not therefore one should make it clear how important layout becomes in visual coding.

Thank you for the feedback 👍

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [5 July 2023 11:56 UTC](https://discourse.nodered.org/t/article-rfc-refactoring-flows-with-inline-flow-images/79598/4 "2023-07-05T11:56:46Z")

</div>

> [@TotallyInformation](#):
>
> Refactoring IS quite often discussed but rarely, if ever, is it called that because that is a techie developer phrase.

Good point - it motivated me to start a new blog page on refactoring:

> **[What is Refactoring? | Open Mind Map Blog](https://blog.openmindmap.org/blog/what-is-refactoring)**
>
> Refactoring for techies is daily activity but what is it? Why do geeks and programmers keep talking about refactoring? Refactoring, it nutshell is organising stuff around you.

It's only a start and input very welcome!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 September 2023 11:57 UTC](https://discourse.nodered.org/t/article-rfc-refactoring-flows-with-inline-flow-images/79598/5 "2023-09-03T11:57:03Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
