This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Joakim Wimmerstedt
Posted Mar 31 - Read on Facebook

Hey, what design patterns are people using for framer? Complex prototypes get messy so easily...

22 Comments

Jordan Robert Dobson

I'm bundling a lot of my functionality into classes which I place in modules and using event firing to communicate between the apps. For a while I was passing an array of methods to my classes asking them to call them for specific events.

Jordan Robert Dobson

Oh and lots of helper classes... like Pointer.isInCircle(circle, point) or Pointer.isInRect(rect, point) or Pointer.coords(event, layer) # This helps me get correct coordinates between desktop and mobile.

Joakim Wimmerstedt

Sounds like something you should publish like a module jordan!

Jordan Robert Dobson

Yeah... I wrote a few of these for work... I just need time to pull these little goodies out... And then fully bake them. :) They weren't very clean or publiclly ready. I hope some of that helps though.

Josef Richter

You know this will never happen - to actually have time to clean it up and make it ready for public :-) 80/20 rule... Just share them as they are ;-)

Jordan Robert Dobson

It does happen... plus, the way they are, I would probably get more questions asking about WTF I was doing here or there... my answer would likely be "UH, I was rushing my code for a meeting". :P

Jordan Robert Dobson

Yeah... some of it just doesn't make sense out of context... and bits and pieces are scattered.

Jordan Robert Dobson

But... since you asked for it... here's one example: http://jrdn.io/aSpe

Joakim Wimmerstedt

I just realised how much i'm not using coffeescript as I should. I'm basically just writing regular javascript - that shit you've got there is a lot sexier.

Jordan Robert Dobson

Here's one more for you: http://jrdn.io/aT0C

Jordan Robert Dobson

^ I dislike a lot of things about what I'm doing above... mostly naming of the class...etc.

Jordan Robert Dobson

Joakim - I used to do events like this before: http://jrdn.io/aT4v Then I realized I needed an event controller to keep everything clean.

Joakim Wimmerstedt

Nice stuff, man! It seems like you really know your stuff

Jordan Robert Dobson

Dude... just start to keep your stuff in classes... That way it's easier to dig through now, and later, in regards to what they handle specifically.

It helps keep it organized in your head what your App handles (events, organizing main View layers)... what a ViewLayer handles (it's contents and hit areas)... What a ViewShell handles (multiple view layers, nav bar, drag / scroll listeners, communication between the View Layers )... etc.

Jordan Robert Dobson

Just start small with helper classes like my Move class to encapsulate logic... and eventually you'll get the hang of it.

Jordan Robert Dobson

Would this be helpful for anyone to have? I like, during my layer setup, to be able to specify the style, states to add, html... as well as a few other things: http://jrdn.io/aSOP

Koen Bok

Hey Jordan, you can ditch the . in @.x etc (@x).

Jordan Robert Dobson

Oh... yeah... duh!

Jordan Robert Dobson

Koen Bok - Like so? http://jrdn.io/aSUh

Jordan Robert Dobson

Thanks Koen - Old code dies hard.

Josef Richter

Hmm looking at all this stuff, I think it's just a matter of time till someone builds some framework, or another layer of abstraction on top of Framer. There's so much stuff that needs to be put into modules rather than reinventing the wheel over and over again. Or am I wrong?

Jordan Robert Dobson

Sure.. some already exist out there... This is all just coffeescript after all. I tend to build just the parts that I need instead of brining in an entire framework... but yeah I think eventually Framer will get there as more users provide feedback and build modules... I assume the popular modules will eventually end up being obsolete as they get added into framer core.

Read the entire post on Facebook