As I have posted in the Business/Contracts forum, I've inherited a real mess of a project.
While I can get to work on back end and server side code, the javascript is a god awful mess and I don't even know where to start.
My predecessor decided to use AngularJS & all the control validation code is a horrible mess - boolean variables everywere, convoluted if statements etc.
As a general moan about javascript - even in well implemented projects where people have followed the things we consider to be best practices in software design I always find it ironic that there is such a pile of cack on the client side. I use as little as possible - I quite like JQuery and I like the unobtrusive validation you get with MVC. But here, JQuery = BAD because it performs logic based on IDs and classnames (I argue that I try to use a rules based approach but it doesn't wash). Either way, you're plugging into a tried and tested framework and you're not having to roll too much of your own.
I'm thinking that the problem we have here is that none of the javascript has been written as object oriented code. It's completely procedural - and I have to confess that I don't know how to go about OO in the Javascript world even though it's second nature in C++/C# etc.
The first thing I'd like to do is abstract out all the nasty low level $Ajax calls. There are 26 of them in all - as somebody who likes to adhere to DRY principles, that's 25 too many. What approach would you take to dealing with this? I ask as a novice from a javascript OO perspective so any advice would be more than welcome.
While I can get to work on back end and server side code, the javascript is a god awful mess and I don't even know where to start.
My predecessor decided to use AngularJS & all the control validation code is a horrible mess - boolean variables everywere, convoluted if statements etc.
As a general moan about javascript - even in well implemented projects where people have followed the things we consider to be best practices in software design I always find it ironic that there is such a pile of cack on the client side. I use as little as possible - I quite like JQuery and I like the unobtrusive validation you get with MVC. But here, JQuery = BAD because it performs logic based on IDs and classnames (I argue that I try to use a rules based approach but it doesn't wash). Either way, you're plugging into a tried and tested framework and you're not having to roll too much of your own.
I'm thinking that the problem we have here is that none of the javascript has been written as object oriented code. It's completely procedural - and I have to confess that I don't know how to go about OO in the Javascript world even though it's second nature in C++/C# etc.
The first thing I'd like to do is abstract out all the nasty low level $Ajax calls. There are 26 of them in all - as somebody who likes to adhere to DRY principles, that's 25 too many. What approach would you take to dealing with this? I ask as a novice from a javascript OO perspective so any advice would be more than welcome.
Comment