Question:
is calling methods from another method considered bad coding style?
Fadi
2012-02-03 00:09:54 UTC
I'm doing a huge Java project for school and I thought of spitting my methods into mini-methods just to make my code look easier and to read and follow. I've been writing codes since I had my first computer, back in 2000, and I don't really know the difference between good coding style and bad coding style.
Three answers:
Anomaly
2012-02-03 20:13:26 UTC
When designing methods, think of code reuse. Think in an object oriented fashion and code reuse mind set. Methods should be used for breaking up a process into smaller chunks too. If notice your code is getting messy, or your repeating lines of code, try to think of a method you can create that you can use in the future as well. For instance, a student object:

Class Student

Public firstName as string

Public lastName as string

Public Function returnFull() as String

Return lastname & " " & firstName

End Function

End Class

-- you could say "Dim fullName as string = theStudent.lastname & " " & theStudent.firstName"

Or, you can make a function such as the returnFull, and instead do this

"Dim fullName as string = theStudent.returnFull()"

Use methods to make your life easier, also you can reuse that function over and over for each new student object you make
Michael
2012-02-03 00:34:46 UTC
"calling methods from another method" is certainly not bad coding style - if doing so makes the code easier to read then that is a good thing - just remember that you shouldn't be splitting the code up into arbitrary chunks just to make the methods smaller - you should be creating methods that have clean interfaces and which perform a clearly defined function
ensey
2017-01-12 12:43:06 UTC
guy, you need to struggle by using lots of the freakin C++ code I had to edit rasterize( effects( randomGamma( getRGBtoBytes( (int)r[],(int)g[],(int)b[], noAlpha())); yet no, many times you spot approach calls interior approaches. many times the laundry-record approach will return a boolean to make an straightforward try of the helpful final touch. in any different case, you spot mucho fact, it is needed of financial code to any extent further and a lot of try{}seize( Exception) {} finally{}; My customary sort is to load a sprint exhibit screen, do all my information inits, spoil the Splash and get in touch with the constructor of my application physique.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...