• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
  • Tim Holloway
  • Carey Brown
  • salvin francis

Code design question

Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm currently working on one of the assignments in the the Cattle Drive .   I want to know if it's bad design to call multiple methods from another ?   From my main method I want to call one method and from that one method I want to have option to call one or more methods depending on the condition.  So main()  calls  methodA() and methodA() may call methodB() , methodD(), and methodF() or methodA() may only call methodC() it depends on the conditions calculated in methodA().  

Also is it correct to say that this question is about code design?
Posts: 3034
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's difficult to answer in the abstract. Generally speaking, it's perfectly fine to have a decision (if-else) in a method, and part of the resulting branches may involve calling different methods. Something to consider is whether each of your methods performs exactly one task. If you can say that methodA() performs the same task when it calls B, D, and F, as it does when it calls C, just for different starting inputs, then your design is fine. I can't think of the Cattle Drive problem that would fit this analogy, but give it go, and your nitpicker will let you know if it makes sense. That's what we're for!
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!