?
Solved

Which one is better for calculator project and why?

Posted on 2016-08-07
6
Medium Priority
?
92 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
4 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Make the most of your online learning experience.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 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