Anyways, there always seems to be some massive desire to break up large methods into small methods for no other reason that people don't like large methods. These people usually have a hard on for Uncle Bob and his dribbling tulipe pile of a book. If a method is a workflow service type arrangement often it is best leaving it in that state.
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Code reviews
Collapse
X
Collapse
-
-
Yeah, if only they'd use source control.Originally posted by tarbera View PostThe poor sod who has had to fire the out of control new programmer 'Who knows best' but knows nothing.
(that's like a backup system in PM terms)Originally posted by MaryPoppinsI'd still not breastfeed a naziOriginally posted by vetranUrine is quite nourishingComment
-
Large methods are usually harder to follow and maintain. If it's doing multiple things then it's harder to re-use the code, refactor and unit test. Often you end up with a tangled mess of code that's difficult to change without breaking something else. You can also end up with lots of repeated code because programmers cant be arsed refactoring the mess of code and just cut and paste.Originally posted by minestrone View PostAnyways, there always seems to be some massive desire to break up large methods into small methods for no other reason that people don't like large methods. These people usually have a hard on for Uncle Bob and his dribbling tulipe pile of a book. If a method is a workflow service type arrangement often it is best leaving it in that state.
This is my experience yours might be different, just wanted to say there are lots of good reasons to refactor monolithic classes/methods.Comment
-
Reverting the code back is entirely separate to canning the cleverclogs contractor who annoyed the rest of the team by rewriting the entire code for no good reason....Originally posted by d000hg View PostYeah, if only they'd use source control.
(that's like a backup system in PM terms)Last edited by eek; 6 January 2014, 19:25.merely at clientco for the entertainmentComment
-
Completely agree with that. Small classes and small methods are the way forward.Originally posted by woohoo View PostLarge methods are usually harder to follow and maintain. If it's doing multiple things then it's harder to re-use the code, refactor and unit test. Often you end up with a tangled mess of code that's difficult to change without breaking something else. You can also end up with lots of repeated code because programmers cant be arsed refactoring the mess of code and just cut and paste.
This is my experience yours might be different, just wanted to say there are lots of good reasons to refactor monolithic classes/methods.
The first half of this presentation convinced me to almost take this to extremes. Watch around 3 minutes - "methods more than one method long are a code smell" - Aloha Ruby Conf 2012 Refactoring from Good to Great by Ben Orenstein - YouTubeComment
-
Wow. Thanks for the replies.
There's a whole lot of crazy in this thread. It's possible the scope of change we're talking about is being overestimated (refactoring != redesign). I'm really shocked by some of the responses.
Exactly. Otherwise you might as well be a code monkey.Originally posted by Kanye View PostMy view was always that you should leave code better than you found it. If you can make simple refactorings such as pulling methods to improve readability, reuse, testablity then its basically your responsibility as a professional to do that.
Code-rot is a fact of life; and once the rot's set in, if i intertwine new functionality with rotten code I'm just catalysing the whole rotting process.
Comparisons to a decorator doing the wallpaper/ceilings/etc when he was only asked to paint the skirting boards are the wrong analogy. It's more akin to the painter discovering that the skirting boards are peeling badly, so he does a professional job and sands them down first rather than just slapping a new coat on top of the peeling paintwork. The painter isn't interested in the wallpaper or ceilings, and limits the scope of his professionalism to the area which he's been assigned to improve.
Plus the new feature/fix i've implemented is now unit tested, along with whatever i've been able to make testable in the process.
And Tarbera - get a clue! Worst case you see what i've done, say "nice effort, but there are particular risks in this project which you wasn't aware of and it'll be too expensive to redo the performance testing". Then it takes me 3 minutes to revert the code back to it's original state (Oh! not even that because it's not even merged into the release branch because it;s not been approved yet), and you can not pay me for 3 hours of my time, or I can make it up and I'll know better next time.
that kind of refactoring typically doesn't even change ANY logic. One can go further afterwards if they like, but you can split that huge chunk of code into small methods with descriptive names often without changing any logic at all. You can encapsulate the different responsibilities you discover, in separate classes, again often without changing any logic. Plus I'm aware enough to know whether the code I'm working on is performance critical or not - in fact in this example (in which I did change some logic which the enhancement required) I made the conscious decision to reimplement the new version of the routine in a less efficient way. The trade-off between performance & maintainability was easy to make given the context in which that code is utilised.So a change in a variable name requires same performance testing as breaking a 1000 line program into 15 sub procedures -
Are you one of those excel-monkey (clueless) PMs who has to manufacture importance for themselves?
Anyhow, like i say it's possible some people have overestimated the scale of the refactoring (or just aren't very good at refactoring), so ignore me if that's the case.
Had another batch of reviews today, with a different guy, which went well - infact he started calling me out on the inappropriate multiple responsibilities a particular class was holding, before I pointed out that he was looking at the previous commit, rather than the new one, on the diff. So I might have just got the cantankerous bad egg previously.
I didn't expect a whole load of pages arguing whether it is right or wrong to maintain code as you work with it - it's something I've always taken for granted (at least in my more experienced years after having had a chance to work with the real pros).
I just wanted to see who else was frustrated working with the software dung-beetles who like to live & work in tulip.
Last edited by SpontaneousOrder; 6 January 2014, 21:22.Comment
-
Ok... I like uncle bob (apart from the fact that he's called uncle bob). Not everything he says though, but a lot.Originally posted by minestrone View PostAnyways, there always seems to be some massive desire to break up large methods into small methods for no other reason that people don't like large methods. These people usually have a hard on for Uncle Bob and his dribbling tulipe pile of a book. If a method is a workflow service type arrangement often it is best leaving it in that state.
Where I decide to break the methods up is when there are comments in the code, and the comments are necessary. In my experience it is incredibly rare to actually need to put any comments in the code, and often (As in the example i'm posting about) the comments say that the code does something different to what it actually does.
If the code actually NEEDS comments, and a broken-down collection of methods doesn't then need any comments, then do you think thats a strong indicator to do the refactor?
Or are you fine with comments in code (I know lots of people are) ?
I don't like playing the "do i feel lucky, punk?" game when reading comments - so i'd rather just read the code and understand it than having to read the comments, and then read the code as well just to make sure they match.Comment
-
Originally posted by woohoo View PostLarge methods are usually harder to follow and maintain. If it's doing multiple things then it's harder to re-use the code, refactor and unit test. Often you end up with a tangled mess of code that's difficult to change without breaking something else. You can also end up with lots of repeated code because programmers cant be arsed refactoring the mess of code and just cut and paste.
This is my experience yours might be different, just wanted to say there are lots of good reasons to refactor monolithic classes/methods.
Methods should be sized to do a specific task, dogmatically designing your code based on LOC is wrong, as is designing your class for ease of testing. The cleanest code comes from clarity of the interface and the worst thing you can do for that is create methods based on size and methods that make it easier to get your lines of code tested percentage up.Comment
-
You changed the classes, created new class signatures and therefore created a new internal API. If you cant see that is a redesign then no wonder the permies are despairing of you.Originally posted by SpontaneousOrder View PostWow. Thanks for the replies.
There's a whole lot of crazy in this thread. It's possible the scope of change we're talking about is being overestimated (refactoring != redesign). I'm really shocked by some of the responses.Comment
-
I agree with everything you said there, even though I go for small methods. I aim for single responsibility - at both class and method level. I don't think keeping methods small, per se, helps testability, because i factor the large methods out into smaller private methods - and I don't unit test private methods.Originally posted by minestrone View PostMethods should be sized to do a specific task, dogmatically designing your code based on LOC is wrong, as is designing your class for ease of testing. The cleanest code comes from clarity of the interface and the worst thing you can do for that is create methods based on size and methods that make it easier to get your lines of code tested percentage up.
Class level single responsibility, though, tends to make testing easier as a side effect. Single reason to change = helpful, easier to test = bonus!
+1 on the not designing code for testability though (apart from special cases).Comment
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Andrew Griffith MP says Tories would reform IR35 Oct 7 00:41
- New umbrella company JSL rules: a 2026 guide for contractors Oct 5 22:50
- Top 5 contractor compliance challenges, as 2025-26 nears Oct 3 08:53
- Joint and Several Liability ‘won’t retire HMRC's naughty list’ Oct 2 05:28
- What contractors can take from the Industria Umbrella Ltd case Sep 30 23:05
- Is ‘Open To Work’ on LinkedIn due an IR35 dropdown menu? Sep 30 05:57
- IR35: Control — updated for 2025-26 Sep 28 21:28
- Can a WhatsApp message really be a contract? Sep 25 20:17
- Can a WhatsApp message really be a contract? Sep 25 08:17
- ‘Subdued’ IT contractor jobs market took third tumble in a row in August Sep 25 08:07

Comment