Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use methods and objects [closed]

This might be a duplicate, but as I haven't seen anything hopefully it isn't. Basically, I've never seen a good rule-of-thumb for when to split a chunk of code into separate methods and objects. Does anyone have any good rules they found work well?

like image 777
Dean Barnes Avatar asked Nov 28 '25 09:11

Dean Barnes


1 Answers

If a method doesn't fit on a page, it's too big. :-)

That's not an excuse to use a really small font or use a really big monitor

Go and read;

  • Refactroring : http://www.amazon.co.uk/Refactoring-Improving-Design-Existing-Technology/dp/0201485672/
  • Working with legacy code : http://www.amazon.co.uk/Working-Effectively-Legacy-Robert-Martin/dp/0131177052/

Although they talk about how to deal with what you already have, if you read them and learn from them you can aim not to create lagacy code to start with!

like image 51
Adam Straughan Avatar answered Nov 29 '25 23:11

Adam Straughan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!