loading...

re: Most effective and simplest way to write readable code. VIEW POST

FULL DISCUSSION
 

I think extracting to methods is good, but I think it's better to not hide initialization. For example, I would have preferred it like
mView.setTabLayout(createLayout()) because more clearly conveys what's being done (and has less side effects and so on).

Also, having methods indicates that you plan to reuse the code inside it. I think immediately invoked functions is a great way to handle that (although not all languages support that):


function Init(){
    (function restoreGroupSelection(){
        // preferences = ... 
        // manager.restore(preferences)
    })()
} 

You might also use lambdas or similar code grouping elements.

 

"having methods indicates that you plan to reuse the code inside it"

That's what really bothers me about having all those small functions. I don't need them anywhere else and my IntelliSense is soon full of garbage.

 

Separation of concern is another reason why we define methods and if we define proper method names then we need not worry about IntelliSense drop down list size.

code of conduct - report abuse