Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all!

Partial classes is excellent for readability, separating UI / logic, teams, etc. , but:

Is there any runtime benefits (i.e. memory use, loading UI (WinForms)) of saving / splitting different logical parts of a class into different files, or are me asking this question a tell-tale of poor design (my class need refactoring)?

Project scenario: Single developer, desktop-dev, winform displaying results of different types of filesearch (local computer). Some of the search-logic separated in a dll, rest is embedded in the winform-code. What started as a "You'll have it by the end of the week", became "Shure, I know UML" before I parted the threading logic, filtering, etc.

TIA
Per Rollvang
-------------
On Error Goto Hell
Posted

No benefits and no drawbacks whatsoever (as speed, memory and so on).
 
Share this answer
 
Comments
Load_error 4-Dec-10 13:39pm    
Ok, nothing magic happening :) Thanks for answering.
If you feel the need to break apart your class into different files because it has different "logical" parts, you probably need to refactor the class into multiple classes that each perform a more specific role in the project. Classes really should be treated a little along the lines of how methods should be. With methods, the name should be descriptive and the method should do exactly what it says it does and nothing more. A class should do the same. It should define an object and only do stuff that is directly relevant to itself and that it can do without knowledge of other objects in the domain. Logic that needs to have knowledge of multiple objects should be in a third class, not in one of those other objects.
 
Share this answer
 
Comments
Load_error 4-Dec-10 14:27pm    
That is the concept of OO, right? Well, I more often than not end up with small pieces of crap, than real OO-classes anyhow.. ;) Guess I have to read up on design! Thanks for answering!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900