Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 66127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:03:16+00:00 2026-05-10T19:03:16+00:00

I have been trying to learn how to add testing to existing code —

  • 0

I have been trying to learn how to add testing to existing code — currently reading reading Working Effectively With Legacy Code. I have been trying to apply some of the principles in JavaScript, and now I’m trying to extract an interface.

In searching for creating interfaces in JavaScript, I can’t find a lot — and what I find about inheritance seems like their are several different ways. (Some people create their own base classes to provide helpful methods to make it easier to do inheritance, some use functions, some use prototypes).

What’s the right way? Got a simple example for extracting an interface in JavaScript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:03:17+00:00Added an answer on May 10, 2026 at 7:03 pm

    There’s no definitive right way, because so many people are doing so many different things.. There are many useful patterns.

    Crockford suggests that you ‘go with the grain’, or write javascript in a way that corresponds to javascript’s prototypal nature.

    Of course, he goes on to show that the original model that Netscape suggested is actually broken. He labels it ‘pseudoclassical’, and points out a lot of the misdirection and unnecessary complexity that is involved in following that model.

    He wrote the ‘object’ function as a remedy (now known as Object.create() ). It allows for some very powerful prototypal patterns.

    It’s not always easy to do develop a clean interface when you have to work with legacy javascript, especially not when you’re dealing with large systems, usually including multiple libraries, and each implementing a unique style and different inheritance pattern. In general, I’d say that the ‘right way’ to do inheritance is the one which allows you to write a clean interface which behaves well in the context of your legacy code, but also allows you to refactor and eliminate old dependencies over time.

    Considering the differences between the major library patterns, I’ve found that the most successful route to take in my own work is to keep my interfaces independent of the library interfaces entirely. I’ll use a library or module if it’s helpful, but won’t be bound to it. This has allowed me to refactor a lot of code, phase out some libraries, and use libraries as scaffolding which can be optimized later.

    Along these lines, I’ve written interfaces that were inspired by Crockford’s parasitic inheritance pattern. It’s really a win for simplicity.

    On the other side of the coin, I’m sure you could argue for picking a library, enforcing it across your team, and conforming to both its inheritance patterns and its interface conventions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running the program from the debugger? It is… May 11, 2026 at 8:47 pm
  • Editorial Team
    Editorial Team added an answer I'm assuming that you're using PHP as a web-scripting language… May 11, 2026 at 8:47 pm
  • Editorial Team
    Editorial Team added an answer Can't be done. You basically want a trigger on SELECT,… May 11, 2026 at 8:47 pm

Related Questions

I have been trying to learn how to add testing to existing code --
I am trying to learn how to use MSBuild so we can use it
I'm trying to wrap my head around asp.net. I have a background as a
I'm still learning the dark arts of TDD and recently I've been trying to
Edit: This code is fine. I found a logic bug somewhere that doesn't exist

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.