Hello,
I'm importing products and so I have an product import class. It has around 4000 lines so I want to break it up. I've started to break it up but I have difficulty deciding what should be a class and what should not. I think all my methods use three of the same instance variables, so if I separated the methods, I would be passing in these instance variables to each separate class in it's constructor. One way I started breaking this up was by looking at groups of methods that dealt with the same type of product data. For example, some methods worked with product descriptions and some worked with product categories and so I started splitting them into separate classes but then someone told me if these different classes are all using the same three instance variables, they probably should be combined into one class. So, how do I do this? I don't really understand proper class design and was only splitting them up because it was hard to find code in the big class.
If the question here is lost, what are some tips to re-factor a large class. Is what I've purposed above a good solution and should I be re-factoring a class where all the methods use the same three instance variables.
This app is an asp.net app that takes product data from one system A's database and, based on a plethora of settings and configuration the user can choose from, saves the product data to system B's database. For example....
public class ProductImporter
{
ProductA productA;
ProductB productB;
ImportSettings settings;
public void GetProductADescription()
{
//look at the settings and add productB description to productA
productA.Desc = productB.Desc;
//....
}
//.... tons of methods that all deal with product moving one product to the other
public void AddProduct()
{
//go through all the settings
productA.Save();
}
}