Say you have a Car class. Properties that make sense for a Car class might be:
var make;
var model;
var year;
var turnOn; // a function
But the turnOn
function is very complicated and ends up needing a static variable and a couple sub functions:
var isTurningOn; // too specific to be a class variable
function turnOn() {
// 30 lines to start the engine
// 30 lines to start the air conditioner
// 30 lines to start the radio
}
So now we have a function that maybe isn't really suitable to be made into its own class and it's polluting the Car class with a variable that only the turnOn
function ever uses. Plus the function contains sections of code that should be made into their own functions. So what do you do in situations like this?