Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

http://ideone.com/9LMM5 So I have no more memory leak problems and bad calls to free(), but my code still looks terrible. How can I improve my code?

OpenStudy (anonymous):

thats glad to hear that your code is bugs free....yu can improve it by intendation ,i mean give spaces at appropriate modules and index the paranthesis and so on......do it repeatedly to make yur code look like me..:P

OpenStudy (anonymous):

and you also should write more comments :D

OpenStudy (anonymous):

I thought my code was practically self-documenting :-D All it does is break the integer apart, match each piece into an english word (string), and then contatenate all the strings together. How complex could it be?.

OpenStudy (anonymous):

You're right though... I shaved away all the comments while I was debugging it.... Now I will make it work for decimals... (float 14) and then arbitrary precision numbers!

OpenStudy (anonymous):

I think you can do this thing in Java way easier. :-P

OpenStudy (shadowfiend):

So, to be honest, it is possible to write code that is ostensibly self-documenting, at least most of the time. It takes two things: (1) Very clear (tradeoff: potentially long) function/method names. To see this taken to the extreme, look at the Objective-C Cocoa APIs. Some of these are definitely excessive (e.g., [array itemAtIndex:0]). (2) Breaking things down into functions as much as possible. This is harder in C because you have to do some backflips to make sure the code isn't super-slow by consequence and still stays relatively clear (pointers start flying really fast), but it's still doable. But pretty much every distinct block of code can get its own function if you want to go this way. This way, you end up with parent functions that just call a set of other functions in a very narrative fashion.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!