Solved

Which one is better for calculator project and why?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tidtcpserver connection lost handle 2 70
SUM 2 INTEGER ARRAYS INTO 1 10 93
servlet doXXX methods 3 34
MySQL  on Tomcat 8 24
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This video teaches viewers about errors in exception handling.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

914 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

13 Experts available now in Live!

Get 1:1 Help Now