A lesson in learning to use JavaScript Patterns and tools to get rid of spaghetti code