Preferences

I use a couple, some I discovered along the way, some I leanrt:

Event and Event Handlers: I rely heavily on this one, event handlers subscribes to an event or you queue them to a certain event, when that event is emitted, it relays the info to the handlers which do their own thing. This pattern is simple, flexible but can be problematic sometimes (i.e. annoying if there is no async support, tight coupling if you are not careful, etc).

Hookers: This is inspired by the event pattern above, I use this in my Template System. The way it works is I build a base template, then I define the segment (hooks) I want to extend if I am to reuse the base template. Just like event handlers, you also subscribe to hooks but in this case, it is done directly in templates reusing the base.

I took this one step further, you can have hooks within hooks, remove a particular hook with their respective handlers, hook before a hook and hook after a hook. Very flexible and speeds up building page templates.

State Pattern: I use this one for breaking down complex problems, it works but you can easily shoot yourself in the foot.

Pattern makes sense if you understand the "Problem Space", if you do understand the problem you are solving, the pattern to use would come naturally (sometimes you do need to freestyle around to see which would one would make sense)


This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal