?
Solved

Which one is better for calculator project and why?

Posted on 2016-08-07
6
Medium Priority
?
80 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
[X]
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
  • 3
6 Comments
 
LVL 9

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 35

Accepted Solution

by:
gr8gonzo earned 2000 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 35

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 35

Expert Comment

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

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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.
Six Sigma Control Plans
Suggested Courses

770 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