Discussion on answer by David Arno: My boss asks me to stop writing small functions and do everything in the same loop

Discussion on answer by David Arno: M

Imported from a comment discussion on http://softwareengineering.stackexchange.com/questions/335783/my-boss-asks-me-to-stop-writing-small-functions-and-do-everything-in-the-same-lo/335792#335792
3024d ago – Dispersia
42
3

export all events for this room

Starred posts

Nov 14, 2016 03:52
A loop should fit one screen page. That gives you a rough overview at a glance. You will then go into details in the next step. 100 lines would not fit one page (my eyes are too old and the screen resolution too). Every time you need to scroll, it starts messing up your mind. In former times we had printouts from the line printer. The two pages are still about the same that fits one screen page.
Nov 14, 2016 03:52
@ThomasKilian, "A loop should fit one screen page". What?!?? Not in my world, mate. I aim for the whole file to fit on the screen, and set myself a non-negotiable (except in real edge-case situations) 200 line limit to files and 20 lines for functions. Never looked back since doing that.
Nov 14, 2016 03:52
+1 for "interested in the 'how', only the 'what' of a piece of functionality." Also, regarding testing: forget unit testing; comments can't be tested at all.
Nov 14, 2016 03:52
Code Complete also concurs with Clean Code - Focus on writing code at a single level of abstraction within a function. If you find yourself moving up and down the context ladder, it's a good indication things need to be refactored.
Nov 14, 2016 03:52
@MatthewWhited Having it inline is all well and good until you hit an edge case and add handling for that. And then another edge case. And another. There's no detriment to adding a function while the implementation is "simple", and when the implementation becomes more complex, you have a clearly defined area where you add changes, and the code on the calling level gets to remain the same.
Nov 14, 2016 03:52
Nov 14, 2016 03:52
I disagree with the entire notion that a function "isApplicationInProduction" should rely on a parameter called "headers". Surely it's more fundamental than which headers you happen to have around right now.
Nov 14, 2016 03:52
@LorenPechtel they're both really fast so it hardly matters, but for me switching files is precious milliseconds faster than scrolling 200 lines. But everyone has their own workflow.
Nov 14, 2016 03:52
@LorenPechtel, Like Mark, my experience is that eg switching between 5, 200 line files is faster (I would say a lot faster, rather than just milliseconds) than scolling through a 1,000 line file.
Nov 14, 2016 03:52
@Mat'sMug, um, it's a parody account. That's the whole point to that account. It ridicules "expert beginner" stupid ideas, like those of the OP's boss. "there's a 15 LOC minimum on all methods" is as much an anti-pattern as "We don't pay you to think, we pay you to code".
Nov 14, 2016 03:52
@EvSunWoodard Because eventually that function can be replaced with some code that actually performs a meaningful test for a production environment, but the rest of the code doesn't need to be altered.
Nov 14, 2016 03:52
"If the function is well-named" and this is typically where the pain lies.
Nov 14, 2016 03:52
@EvSunWoodard If you're a computer, the isApp... function doesn't impact the overall program in any way. If you're a human, the isApp... function does two things: 1) tells you why there are two phone number branches (one's for production, the other's not) 2) why we're looking up the resourceId header (to see if we're in production).