Is it good to submit pull requests that refractories code?

Hi, I've just read through uncle bob's clean code book.

After then, I skimmed through some OSS that I really like, and I realized there are a LOT of long functions that can be optimized for readability.

Should I refactor them and submit a/some pull request(s)?

Is it a good idea to submit pull requests such as this?

Comments (2)

Gaponenko Andrei's photo

From what I understand there is basically some open source code that needs a good refactoring here and there and you're not sure whether you should touch it or not. I don't have any experience with open source, to be honest.

I'm sure you already know that, but unit tests are your safety net when it comes to refactoring. If there are none, ask yourself whether you're ready to invest time to write good unit tests - which usually takes quite a bit of time.

Other then that: sure, why not? It's up to contributors to accept your PR and if they have some reason to reject it, perhaps they will be able to provide some useful feedback as well. Either way, people never learn how to write clean code unless they actually try - you can at least consider it a good exercise.

Be ready to meet some resistance along the way. I've never contributed to open source, but people who never read Uncle Bob sometimes don't understand and share same ideas and visions you do. I had colleagues who accepted those ideas, but there were far too many who could not for the life of them understand that function is not simply "reusable piece of code", but first and foremost a "named piece of logic", that can have a damn name longer than its actual body definition.

wusatosi's photo

Those projects have really good testings and code coverages, thanks.