<p>I remember back when MS released a forum sample application, the design of the application was like this:</p>

<p>/Classes/User.cs
/Classes/Post.cs
...
/Users.cs
/Posts.cs</p>

<p>So the classes folder had just the class i.e. properties and getters/setters.
The Users.cs, Post.cs, etc. have the actual methods that access the Data Access Layer, so Posts.cs might look like:</p>

<pre><code>public class Posts
{
    public static Post GetPostByID(int postID)
    {
          SqlDataProvider dp = new SqlDataProvider();
          return dp.GetPostByID(postID);
    }
}
</code></pre>

<p>Another more traditional route would be to put all of the methods in Posts.cs into the class definition also (Post.cs).</p>

<p>Splitting things into 2 files makes it much more procedural doesn't it?
Isn't this breaking OOP rules since it is taking the behavior out of the class and putting it into another class definition?</p>

[{'answer_id': 58080, 'author': 'Eric Haskins', 'author_id': 100, 'author_profile': 'https://Stackoverflow.com/users/100', 'pm_score': 0, 'selected': False, 'text': "<p>Are you sure the classes aren't partial classes. In which case they really aren't two classes, just a single class spread across multiple files for better readability.</p>\n"}, {'answer_id': 58082, 'author': 'SkunkSpinner', 'author_id': 5592, 'author_profile': 'https://Stackoverflow.com/users/5592', 'pm_score': 0, 'selected': False, 'text': '<p>Based on your code snippet, <strong>Posts</strong> is primarily a class of static helper methods. <strong>Posts</strong> is not the same object as <strong>Post</strong>. Instead of <strong>Posts</strong>, a better name might be <strong>PostManager</strong> or <strong>PostHelper</strong>. If you think of it that way, it may help you understand why they broke it out that way.</p>\n'}, {'answer_id': 58085, 'author': 'Dr8k', 'author_id': 6014, 'author_profile': 'https://Stackoverflow.com/users/6014', 'pm_score': 0, 'selected': False, 'text': '<p>This is also an important step for a decoupling (or loosely coupling) you applications.</p>\n'}, {'answer_id': 58087, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>What's anti-OOP or pro-OOP depends entirely on the functionality of the software and what's needed to make it work.</p>\n"}, {'answer_id': 58091, 'author': 'Guy Starbuck', 'author_id': 2194, 'author_profile': 'https://Stackoverflow.com/users/2194', 'pm_score': 3, 'selected': True, 'text': '<p>If every method is just a static call straight to the data source, then the "Posts" class is really a Factory.  You could certainly put the static methods in "Posts" into the "Post" class (this is how CSLA works), but they are still factory methods.</p>\n\n<p>I would say that a more modern and accurate name for the "Posts" class would be "PostFactory" (assuming that all it has is static methods).</p>\n\n<p>I guess I wouldn\'t say this is a "procedural" approach necessarily -- it\'s just a misleading name, you would assume in the modern OO world that a "Posts" object would be stateful and provide methods to manipulate and manage a set of "Post" objects.</p>\n'}, {'answer_id': 58094, 'author': 'JamesSugrue', 'author_id': 1075, 'author_profile': 'https://Stackoverflow.com/users/1075', 'pm_score': 1, 'selected': False, 'text': '<p>Well it depends where and how you define your separation of concerns. If you put the code to populate the Post in the Post class, then your Business Layer is interceded with Data Access Code, and vice versa. </p>\n\n<p>To me it makes sense to do the data fetching and populating outside the actual domain object, and let the domain object be responsible for using the data.</p>\n'}]
['https://Stackoverflow.com/questions/58070', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1368/']