Link to home
Start Free TrialLog in
Avatar of chima
chima

asked on

Interview question Javascript, database

Hello,  This question has been bugging me, so I better ask to get it off my mind.  During an interview I was asked this question; A company having several/many web sites, their customer service phone number was in error.  the web sites consisted of legacy code and newer web service code.  How would the CS phone number be easily corrected in both the old web sites and the new web sites?
I won't post what my response was, let's see how close I came to answering this correctly.
Avatar of James Bilous
James Bilous
Flag of United States of America image

I would say that you would want to make an update that resolves some of the technical debt. This would entail creating a central location in the new web service code that can be queried for the phone number and updating the legacy sites to pull from this location. That way, if the number ever changes again, the update only needs to be made in one spot.
Avatar of chima
chima

ASKER

James, thanks, I said that if the javascript was done correctly; that the phone number "value" would be pulled from the database.  Then he responded by saying; what about the legacy code.  At that time I said; if the code was done correctly and not hard code the phone number on every web page, but have a "globe variable," whereby it would only need to be changed in one location (variable).  I added that then the code would have to be refactored and re-released.
What is your comment to what I said?
thanks
I think the concept of keeping the number in one place is the key here.  It could be in a database, or a variable, or class, etc.  But in actuality, it wouldn't be that hard to do a grep search on file contents and find / replace all hard coded instances.  A better question would be how to maintain business logic -- things like "how is net sales calculated".  If there's a change in something like that, you surely hope that there is one base class or process that everything else refers to.
@chima I think that is correct given how broad the question is. I would probably follow up with questions like: Do the legacy sites have any sort of framework? Are they simple HTML and CSS pages? How difficult is a legacy deployment? Is the legacy deployment automated? How long do you expect the legacy pages to be around?

If they expect the legacy sites to migrate to the new framework soon, then I would just do as zephr_hex mentioned and do a grep/replace. Otherwise, if the ROI isn't aggregiously bad, an update to the legacy sites so they reference a single location makes sense.
Avatar of chima

ASKER

Megan, thanks, had not thought of "class," yet possibly a variable/property within a class.  I'll surely keep class in mind.
James, I do not mean to have you work extra hard for the points; please allow me to ask the following >>> about the questions you wrote:
Do the legacy sites have any sort of framework? >>> What kind of framework would this be, like a .NET framework?  What would it be for a Java application?  I find, when I google; a PHP legacy framework.  I'll have to search more.

Are they simple HTML and CSS pages? >>> I would think that html and css files could be greped/replaced.  Or could the html and css have a globe variable/class?
thanks
SOLUTION
Avatar of James Bilous
James Bilous
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chima

ASKER

James and Megan, great, thanks.  I'm not a developer, yet I need to understand these concepts.  I'll issue the points shortly.
Avatar of chima

ASKER

This is coincidental, I was searching for "unknown javascript" is, and I found this under "Javascript Best Practices;"
Avoid Global Variables
Minimize the use of global variables.
This includes all data types, objects, and functions.
Global variables and functions can be overwritten by other scripts.
Use local variables instead, and learn how to use closures.

I guess I blew the interview question....darn!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Though not expressly forbidden (AFAIK), requesting answers to employment interview questions, and giving such answers, may be frowned upon. I suspect that employers would not think well of a site that did such. Giving constructive criticism of a question that included an attempted answer could be reasonable.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chima

ASKER

I forgot to say; thank you.  And Megan thank you for responding to tliotta.