oop - How to break up a large class -


I have a large size class, many of which may be able to do things I have many "domain" shapes There are classes that are received from this class, but do not provide any other functionality other than portraying themselves.

I have tried to sub-class the shape class, but then all the "domain" objects will still get this subclass.

How do I break the square? (This is 300 text lines, C #)

Some ideas (like more hieroglyphs):

1) Check the areas of the class. If a group is used in a few areas, then it can be an indication that the group of fields and methods that use it may be in the second category.

2) Comparing the name of a well named class, the name of the class actually does what the class does. If you find the ways in which you expect the things above and beyond that which is called the class If it is expected, it can be an indication that these methods are in a different class. For example, if your class represents a customer, but opens the log file, closes, and writes, then log the log file code into a logger class. See also for some interesting ideas. 3) If in some ways primarily the ways of a second class are called, then it can be an indication that those methods should be transferred to the class which they often use. (Like feature jealousy).

WARNING: Like they say, it is difficult to break. If there is any risk in breaking the class, then you can put some tests in place so that you know that you are not breaking anything in the form of a refactor. Consider reading "" and "" books.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -