There are some good books on this topic. One is Clean Code. It's fairly language agnostic and keeping code in good order is something you'll really want to do even on small projects. It's a good habit to form.
There are some good books on this topic. One is Clean Code. It's fairly language agnostic and keeping code in good order is something you'll really want to do even on small projects. It's a good habit to form.
I would strongly disagree here. Uncle Bob has a way of splitting down methods into too small methods each which does almost nothing. All he achieves is essentially the creation of a new language. If you are looking to stay employed this is a great way to keep yourself occupied but if you take over a project written this way you will want to stab the author with a blunt instrument.
In some circles Uncle Bob is hailed like the new messiah. To me he looks like the poster child of all the projects that were never completed.
Avoid like the plague.
I wonder, did you read past the first 2 chapters? Have you seen any of the videos?
I would strongly disagree here. Uncle Bob has a way of splitting down methods into too small methods each which does almost nothing. All he achieves is essentially the creation of a new language. If you are looking to stay employed this is a great way to keep yourself occupied but if you take over a project written this way you will want to stab the author with a blunt instrument.
In some circles Uncle Bob is hailed like the new messiah. To me he looks like the poster child of all the projects that were never completed.
Avoid like the plague.
He creates a new language? I didn't gather that from the book.
What is the issue with small methods? Almost all of my methods fall into the 20 lines or fewer category.
The book appears to be well written to sell books and seminars.
The proof is not in any chapters or videos, but in whether successful programmers or companies actually keep using the described methods and succeed. Some do. But many dump them after an initial try as actually reducing overall productivity. e.g. they clean up messes that are in the opposite direction, but when taken seriously make another kind of mess.
This one is a pretty hot potato at the moment. It's a good watch no matter which camp you are in.
YouTube: video
I like the video because it kindof points out that;
If you write **** code, your code is **** no matter what design philosophy you use. A philosophy (or ideology) alone is not going to fix your code.
I think this is often overlooked, just like a fad diet.
Of course I have unit tests! But only where I think I will benefit from having a test. Don't confuse unit tests with TDD.
I had the great fortune of working with a contractor for a while. The fella oozed experience, he'd been coding since before I was born! His take on it was pretty simple.
Write your code as if the next person is a deranged serial killer and he has your address.
I don't care for TDD either. I tend to write unit tests based on my documentation (if my documentation says my code will do X, it better do it!) and sometimes I update my documentation based on my unit tests.
What would you guys say are good habits to have/develop and bad habits or common problems that beginner or novice devs encounter. Also any ones specially in Objective C.
I'm constantly updating my opinion to the best opinion.Overall it's good to read multiple and differing opinions on programming habits. Don't just read the "You should do it this way" part, also read the "You should do it this way because" part. Depending on your situation various habits make better sense. For my stuff at work, unit tests make a lot of sense. I really have no say in the customer requirements. So when marketing decides to change something, I have to change it. Having a set of strong unit tests is essential so when I make the changes I can ensure myself I haven't broken anything. For others this might not make sense and that's fine. I've historically found more benefit to having them than not in my area. Likewise with code. Some prefer to write super tiny code with extreme efficiency. Some have no idea what they are doing and copy paste until it works. I prefer a middle ground that is concise but you can easily determine what it is doing.
The more you read about programming habits, the more you'll change to what suits your needs and that's a good thing. Just don't ever say "I'm doing it this way because 'source X' said so". Instead be able to say "because of these benefits". Also don't be averse to changing if somebody makes a solid argument that the benefits you're getting are better gotten another way or are even not really benefits.
3 Thinking that version control, bug tracking, good comments at the top of every functional block and file all don't apply to them.
In theory, it sounds like a good idea to comment every function or every file yada yada... In reality and in practice, its not necessary and comments do more harm than good. I believe people should use them sparingly.
In short comments LIE.
In theory, it sounds like a good idea to comment every function or every file yada yada... In reality and in practice, its not necessary and comments do more harm than good. I believe people should use them sparingly.
4. reinventing to many wheels. Many beginners maybe can't understand some big library/API so they think it is easier to re-implement the functions they need. But then they have created a huge maintenance problem and their reinvention will never be as mature and well tested. I've seen people pushing data to port 25 because they thought the system sendmail interface was to hard to use and others writing an entire files management system because they thought SQL was to complex to learn.
You're very confused. Comments say what the author thinks the code does (or should) do and/or why they wrote it. They may not actually say what the code actually does.
No, see, you're the problem. You think you don't need comments. Please stay away from me and any projects I work on.
"Self documenting code" can "lie" as you put it. Just because I gave my function a name that says exactly what the function should do doesn't mean it actually does what it should do.
Which is why you write unit tests - good unit tests that actually verify your comments and variable names, at that.
When I see a comment I'm like ok I know some crap code is coming up that needs a refactoring or two.
// increases the value of i by 1
i++;