Forum

Community Coding : Design Patterns

vl

#1

hei all,

I started reading this book (Head First Design Patterns, O’Reilly) that gives an introduction to design patterns and thought it would be a nice exercise to try to implement those in VL. Then, @sebl suggested it could be a cool communitythingy on the forums, so let’s do it :)

I’ve set-up a repo so anyone can contribute and see what’s going on. The idea would be to produce a series of documented patches that could serve as a learning resource for anyone interested in the topic.

Also, you can check out Christopher Okhravi’s YouTube channel where he (brilliantly) explains in details the patterns of the book.

Any comments/suggestions welcome!

cheeerz

seb


#2

first pattern is very simple in vl, i can try to patch something if no one is working on it already.


#3

working on it but i’d be curious to see how you handle it :)


#4

here is a patch that implements some ducks from the first video with the strategy pattern and draws them with skia. also made a pull request (edit: now merged): https://github.com/sebescudie/VL.HeadFirstDesignPatterns/tree/master/01_StrategyPattern

there is a Root and DuckManager patch to actually make some different ducks and manage them:
image

the output looks a bit silly tho, but i didn’t want to clutter it with too much functionality:
image


#5

Thanks @tonfilm, merged !
A bit busy these days but I should be able to study it and maybe come up with something by the end of the week.


#6

great, so next up, observer pattern! this is basically two nodes in vl, who is up for it? … hint hint:


#7

Ok, not really sure where I’m going with this, so I’ll post here first.

I was trying to patch the thing with ToObservable nodes when I remembered something @Elias showed at LINK about Subjects. Despite the OnNext node being a bit counter intuitive at first, it seems pretty straightforward now, almost feels “too easy” to be the right thing to do :)

What would you think about that approach ?

image

VVVV.DesignPatterns.Observer.vl (49.2 KB)