-1

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?

2 Answers2

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.

HLGEM
  • 28,819
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.