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 6139569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:00:25+00:00 2026-05-23T18:00:25+00:00

This is probably a common pattern in coding, though I am not knowledgeable enough

  • 0

This is probably a common pattern in coding, though I am not knowledgeable enough to recognize it or use the correct terminology (I would’ve googled it then).
When you are creating an object that will invoke a method in a loop, but the content of the loop can change according to a certain set of conditions, do you do (pseudo-code):

method _method($condition){
    switch($condition){}
}

or

method init($condition){
  switch($condition){
     case 1:
         this._method = function(){};break;
     case 2:
         this._method = function(){};break;
     ....
  }
}

I prefer version 1 as it is more maintainable, but I feel version 2 is lighter. Am I correct?

I realize the answer can differ quite a lot depending on the use case, so here is mine: I have a javascript slider, implemented as a jQuery plugin. depending on options, when the slider comes to the last frame, it either scrolls back to start, or seamlessly loops. Now, if it must seamlessly loop, then when each slide advance, I must set the element that has just disappeared on the left to be queued at the far right. Which means I have to detect when the element has disappeared from the view, and do a helluva of other checks for scrollLeft values and whatnot that I don’t need to do if I am simply scrolling.
So how should I go about that?

  • 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. Editorial Team
    Editorial Team
    2026-05-23T18:00:25+00:00Added an answer on May 23, 2026 at 6:00 pm

    I’m sure you understand this, but it’s worth repeating:

    If it ain’t broke, don’t fix it.

    You can almost never find a performance problem in non-toy software by just thinking about it.

    When people learn how to solve performance problems (as, IMHO, I have),
    they are often asked what the secret is.
    The secret is simple – don’t guess, do diagnose.
    Here’s the method I use.

    Everybody knows that, but they go ahead guessing anyway.
    For one example, review the answers to this question.

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

Sidebar

Related Questions

This probably has a simple answer, but I must not have had enough coffee
I am working with VisualStudio 2010 and this would probably be the most common
This is probably one of the most common tasks / problems when programming; You
This is a fairly common problem, it probably has a name, I just don't
I know this probably really simple but Im not sure what im doing wrong...
This is probably a common Objective-C question reported by Java coders, but I don't
This is probably a very common question but here it goes. I created an
Probably this is a common question. In fact I think I asked it years
This is probably a very common question, but I was unable to find an
This is probably a common question, but all answers on the internt have failed

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.