-1

This question already has an answer here:

recently I got job as a java developer, and now I have assigned project too.

I want to know what is a good logic? when I check in the code my team lead is saying that its a good code.

But when it comes to my project manager he is saying that its a bad code. And he is changing my code, after his changes if I see his code its really very very good and even simple.

can you please tell me how to develop the good program, good logic? what is the best way to structure a problem in terms of code?

marked as duplicate by user40980, gnat, Kilian Foth, Bart van Ingen Schenau, jozefg Nov 1 '13 at 14:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Good engineers have a knack for making the complex simple. Everybody else has a knack for making the simple very complex. It sounds like you are everybody else. Sorry to say, that for the most part this is an inborn trait, although if the desire is there I'm sure can be improved somewhat. But I've seen new-grads with the trait and many, many, many very experienced developers who will never gain that trait. – Dunk Nov 1 '13 at 14:01
1

Since you are lucky enought to have someone who can change your code to be better, learn from him. Look for patterns in what he changes and what he does not. Try to use the same methods he used when doing your next piece of code. Ask him for advice on how to learn to be better. When he changes things, ask him why he changed them and what situations his improvements are appropriate in and when they would not be. Ask him if instead of changing the code, he would sit with you and guide you into changing the code, so that you learn what to do.

0

There are some basic rules like high cohesion (the methods , classes and modules should do what they are supposed to do....nothing more and nothing less), low coupling, simplicity (yes there can be 'smarter' ways to accomplish more tasks with one unit but with time the complexity rises and maintainability suffers.)

Personally, I feel that one should always write a pseudo-code first. It might appear to be a waste of time but in the long run it actually saves time. Typing the code should be the last part.

Also, before writing the code, decide what all its supposed to do, the possible instances when it can break and how it should handle them.

Lastly, read best practices and blogs to keep yourself updated. Google blogs can be a good starting point.

  • without an explanation, this answer may become useless in case if someone else posts an opposite opinion. For example, if someone posts a claim like "I feel that one should never write a pseudo-code first", how would this answer help reader to pick of two opposing opinions? Consider editing it into a better shape, to fit How to Answer guidelines. – gnat Nov 1 '13 at 8:52
  • Like I said, its my personal opinion on pseudo codes. One should go ahead, try writing codes with and then without writing pseudo codes and see for oneself which suits them better. – user1152083 Nov 3 '13 at 11:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.