Click here to Skip to main content
13,046,679 members (60,855 online)
Rate this:
Please Sign up or sign in to 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.

Per Rollvang
On Error Goto Hell
Posted 4-Dec-10 7:12am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

No benefits and no drawbacks whatsoever (as speed, memory and so on).
Load_error 4-Dec-10 13:39pm
Ok, nothing magic happening :) Thanks for answering.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 4 Dec 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100