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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:19:15+00:00 2026-05-25T02:19:15+00:00

EDIT: Sometimes it happens that our problem is kind of not in code but

  • 0

EDIT:
Sometimes it happens that our problem is kind of not in code but in our way of judging what is right and wrong. I am writing my problem through an example as it would help to explain it. The problem is in short “should our function handle each exception in iteself. Through the example i showded it sometimes become confusing and more like writing same code everywhere.

When we write code in C its kind of flowing procedural language. So we handle situations as they come. For example, given (a,b,c) to find which triangle type it is (NOT_POSSIBLE, Equilateral, Isosceles, Scalar). We input these and go on checking first equilateral then isosceles and then scalar, etc.

In C++ we make functions to check these conditions (so isEuilateral() and isScalar() are two functions that checks it).

Problem is:
now isScalar() function “should” check whether it is equilateral or not and then its own condition, or just simply its conditions.

Is it the headache of isScalar() function to check whether it is equilateral triangle or not, that is:

if(isEquilateral()) 
    return false; 
else if(a==b) 
    return true;
else if (b==c) 
    return true;
...

Or start from itself:

if(a==b) return true; // not checking equilateral
....

Or it should do its work only and provide functions. It would be programmers duty to check object.isEquilateral() before object.isScalar().

so I devloped this class api Triangle and send it to you. U know only function name like isEquilateral() and isIsosceles() like… so you are assigned job to make an application that inputs 3sides of triangle a,b,c and tells what kind of triangle is this. .. ok.. input is 3,3,3, your program then should check about equilateral condition before isoceles condition and calling isIsoceles() without before calling isEquilateral() is not safe for this output. . isIsoceles () is not an independent function now.. NOt complete or is it not a bug. what to do?

Well actually this is an example which does not contain all of my confusion.

So question is should each function handle each exception explicitly. Would not that be redundancy and duplication of code.

Note that we cannot make a function for checking all exceptions because some exceptions here would not be exceptions at some other place.

  • 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-25T02:19:15+00:00Added an answer on May 25, 2026 at 2:19 am

    The simpler approach I would use is a classifyTriangle function, that returns an enum of triangle types. Then, any subsequent code can just consult the return value to act according to the triangle type.

    Alternatively, I believe that each function should concentrate on checking its own condition, regardless of other triangle types.

    Edit: Now that I’ve re-read the question, I believe you’re asking about precedence. Meaning, a triangle can be equilateral and isosceles, but you want it to be classified as equilateral only. If you have a validation function for each type, then you want the user to use your predetermined order of call. This is resolved by using a classifyTrianlge function, where you can decide on the order you wish.

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

Sidebar

Related Questions

This happens only sometimes, but makes my files unreadable. The problem is that the
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
My current solution will suck sometimes EDIT For those who don't understand,see this example:
I want to pipe [edit: real-time text] the output of several subprocesses (sometimes chained,
Edit: From another question I provided an answer that has links to a lot
I'm seeing a strange build bug a lot. Sometimes after typing some code we
Right then, I'm coming to the end of a rewrite of our JavaScript system,
What happens, step by step, when a variable is returned. I know that if
I sometimes wonder what happens when you submit a form multiple times and the
Edit: also happens with $('body').width() and window.outerWidth API 2.3.3 HVGA Before and after rotating

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.