Solved

Which one is better for calculator project and why?

Posted on 2016-08-07
6
60 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 7

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 45
for i loop in grovy 1 32
unix in java example 9 43
eclipse formatting 6 43
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now