3 ms·
From someone who started as a developer only 2 years ago, I found the stuff about how to properly design classes to be the hardest part. There is not enough to
by Bahamut 12y ago
From someone who started as a developer only 2 years ago, I found the stuff about how to properly design classes to be the hardest part. There is not enough touted articles on it on the internet.
For example, how would a developer know to break [insert functionality] into a separate method? It is not always obvious to junior developers to break a method into smaller chunks, especially when they understand every line of code written. They usually recognize the problem once it is pointed out, but it doesn't often register beforehand.
- tragic 12y agoA common approach is to describe the functionality aloud. If your description includes the word 'and', then there may be a problem ("this method increments the foo counter, and makes the tea").
- balabaster 12y agoI don't think there's anything wrong with any method that also makes me tea :P
- Bahamut 12y agoIt is the minute details that are sometimes the problem. For example, if a developer is iterating over an array to do something to each element, there is a good chance that that iterator should be separated out in the event that it may be reusable (if using something like map).
- spacecowboy_lon 12y agoAnd knowing when OO is not the right solution to all problems.
- Bahamut 12y agoIn this case, I'm using classes very loosely - the same applies to methods, and when to break them up into smaller methods.
- codygman 12y agoI believe spacecowboy_lon is referring to functions opposed to methods. For those that don't know the difference a method is basically a function that has access to the state of an object (correct me if my definition is wrong or sucks).