164 reputation
3
bio website
location
age
visits member for 2 years, 10 months
seen Sep 5 at 14:24

Aug
17
comment Hiding away complexity with sub functions
I don't know where is this mountain of code you said, but the point I was trying to make was not about changing structures, but about encapsulation. For example, if there is an OrderProcessor class and this class needs the total value of the items, should it do the calculation? No, it should ask it for the collection. For the processor class, is doesn't matter if the collection is a set, an array or whatever, it just needs the total value. The changing structure possibility is a bonus you get for doing that, not the primary motivation.
Aug
15
comment Hiding away complexity with sub functions
Well, I didn't said never use collections, or always encapsulate every collection. These radical words are dangerous in software development. Things change, even the ones you never thought, so, the more prepared you are for changes, the better when they come. It's up to the developer to decide when to do it or not. Set has its limitations, if the order of the items becomes important, good luck in changing the same thing in dozens of places. Plus, there is the encapsulation issue: the collection should know how to handle its own items, not external classes.
Aug
15
comment Hiding away complexity with sub functions
@Stargazer712 He is not talking about 12 lines long functions, he asked about concepts and best practice. The 12 lines long function he posted was just a simplified example, just to illustrate his question. We all post simplified versions of our problems when writing a question. Would you prefer a full program with hundreds of lines in this tinny space?
Aug
14
awarded  Supporter
Aug
14
revised Hiding away complexity with sub functions
Formatting of word 'if"
Aug
14
revised Hiding away complexity with sub functions
corrected concordancy
Aug
14
revised Hiding away complexity with sub functions
Text about extracting if statements was poor
Aug
14
revised Hiding away complexity with sub functions
Suggestion to extract the items to OrderItems. Added text about extracting if statements to methods.
Aug
14
awarded  Editor
Aug
14
revised Hiding away complexity with sub functions
Removed last phrase. It has been said already
Aug
14
awarded  Teacher
Aug
14
answered Hiding away complexity with sub functions