A lot of front end work enables a lot of flexibility. Your page redering can be a single function, or not even a function. View pages can also be controllers as well depending on request parameters. View pages can return HTML, XML, JSON, etc depending on input.
Then I read Modern JavaScript, and I realized I am not alone in my worries.
As I am becoming more and more fond of Javascript, again I am worried. I see code all over the place. Functions that are a hundred lines long, no room for extension, scripts scattered across page templates, fragments and includes that render together as one. Where is the traceability and testing? In addition, I usually am not the original author when looking at bugs. I don't have the authors context and reasoning. I have to resort to the browser for debugging to understand how elements are combined and how they are dependent. Not the IDE, the browser.
- When I see server side dynamically created Javascript, I am worried.
- When I see large DOM elements being constructed in Javascript and added to the page, I am worried.
- When I see more then one $(document).ready() in the primary rendering page, I am worried.
- When I see a lot of global variables defined across includes, fragments and templates, I am worried.
- When I talk to developers about bad Javascript and they tell me I should rewrite it if I don't understand it, I am worried.
Hopefully things will get better, maybe they don't have to. Maybe developers need to grow up. A lot of code looks like "college code", you know, when you first are learning to program and hacked everything together? When you didn't debug, used a notepad editor and used logging statements for tests?
No comments:
Post a Comment