So you want to know, how to become an efficient developer?
1) You have to develop communication skills
Before you start any project, you have to talk to you customer (in your case your boss) about what he wants. The difficulty here is not only to understand, what your customer says, but what he really means - these are most of the time two different things. It helps if you get your requirements in plain sentences. The simpler the better. You could do this formalized with "user stories" or "story cards", but a simple ticket-system will do.
2) You have to develop a toolbelt and a skillset
Like every good craftsman, you have tools and skills. One part of the Tools are Frameworks in the language you work in. The more you know (whether hearsay or in depth doesn't matter) the better for you. Another part are real tools: buildtools, monitoring tools etc.
And then there are skills. At first: stay sharp in your language. The more you know about the language you are working in, the better you get at solving problems in this language. Knowing the syntax is not enough: you have to know how to express yourself in the language you are working in - like an author writing prose or poetry, you have to know your language.
This includes a major part - which I find often neglected by novices: knowledge of the datastructures, your language offers: what kind of structures are there? how do they work internally? how efficient are they?
Then you need to have a working knowledge of problems others solved already (Algorithms and Design Patterns). The better you understand, what others have already done, the faster you are going to develop your solution. Sometimes programming is like plumbing existing pipes together and the problem is solved.
3) Think about your problem
Analyze your problem from different perspectives: GUI, Backend, Database, Client, Server, whatever perspective you could take.
4) Write your specifications down into acceptance-tests
Only when your solution passes all acceptance-tests, you are sure, that you build the right product.
5) Begin writing small Units and testing those units
Whether you write tests first, as apologets of TDD say or write code and than test doesn't matter, as long as you have tests at all. You are your worst enemy and nothing happens more often than breaking your code. Writing tests helps detecting sloppiness.
6) Get early and frequent feedback.
After you've written small chunks of code and testing those bits and pieces
show the result to your customer. Talk about the results frequently and in depth. So you get a better feeling, for what the customer wants and an immediate feedback for what you are doing.
The project took me 2 months and another developer said that he could do it in a month or less.
So, when a fellow developer said this, that only means, that he has more experience (more problems already solved) and better knowledge, how to plumb such a solution.
Programming is a skill like every other. You have to train and soon get better.