-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?

1
  • 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
    Commented Nov 1, 2013 at 14:01

2 Answers 2

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.

2
  • 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
    Commented Nov 1, 2013 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. Commented Nov 3, 2013 at 11:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.