Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Which one is better for calculator project and why?

Posted on 2016-08-07
6
70 Views
Last Modified: 2016-10-18
I'm a novice programmer i draw two class diagrams for calculator Project, i want you to check each one of them and tell me which one is better and also, i would appreciate it if you point out the parts that are wrong or could be better.

classdiagragm1
class2
0
Comment
Question by:Member_2_7970207
  • 3
6 Comments
 
LVL 8

Expert Comment

by:James Bilous
ID: 41746469
What do you gain from separating out each operation into its own class? I would guess nothing but obfuscation.
2
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 41746585
It's not quite as easy as "one is better than the other." It's more of a question about your long-term plans.

Let me ask you about how a computer is assembled. A computer has a lot of different parts, but several of them are their own "entities" comprised of many parts. For example, if you were building your own home computer, you'd probably buy the motherboard as one component, a CPU as another component, etc, even though each part is made up of a lot of other tiny pieces.

Now, there's no reason that a manufacturer couldn't just create a computer as one all-in-one piece (motherboard, memory, graphics card, CPU, etc all in one piece that cannot be taken apart), but it reduces the flexibility.

The only reason they care about flexibility is because it's often more convenient for everyone to be able to swap in and out components and since that's the expectation and long-term plan, that's how they build computer components.

So back to your program - if your long-term expectation is that the calculator should be modular and that you or others will be plugging in new types of mathematical operations or algorithms, then maybe it's better to separate out the operations.

Bear in mind that abstraction has a price - the more generic you make an application, the harder it will be to set up that way and the less efficient it will be (because the code will need to be written in a way where it is able to handle future, unknown, new classes), via interfaces and such.

So if your long term plan is to make the fastest-possible calculations, then stay with smaller, more proprietary classes. If being able to customize it is more important than speed and development cost, then go with the separated classes. Again, it's all about YOUR long-term plans. Nobody can tell you which way is better for sure because nobody knows your plans and expectations better than you do.
1
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 41846857
The answer here is subjective. #41746585 provides a general commentary on the pros/cons of each approach, which should address the intent of the question.
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 41846860
Sorry, that should have been an objection.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java: The Public Class Main 4 32
How to call a web service and get the results posted in a form in PHP 9 52
Generate Unique ID in VB.NET 21 60
jsp error 6 25
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question