Tagged Questions
-1
votes
2answers
41 views
Beans, DTOs, & Non-Internal Classes as Data in General - Acceptable or OOP-Murdering Antipatterns? [closed]
Am I not understanding encapsulation? What's with all this data out in the line of function-spaghetti disguised as one-method classes fire? Beans and DTOs are everywhere. Isn't it better design to ...
3
votes
4answers
284 views
Is it a good practice to create a ClassCollection of another Class?
Lets says I have a Carclass:
public class Car
{
public string Engine { get; set; }
public string Seat { get; set; }
public string Tires { get; set; }
}
Lets say we're making a system ...
2
votes
1answer
232 views
OOP when using a GUI Designer
I usually do database and web development but at the moment I'm learning desktop development with Mono and Gtk# using using the MonoDevelop IDE. I'm also using the Stetic GUI Designer inside ...
3
votes
7answers
271 views
Naming guard clauses that throw exceptions
I have a function evaluate() that parses a String for some variables and replaces them with their corresponding value:
public String evaluate() {
String result = templateText;
for ...
0
votes
1answer
188 views
How can my code structure be improved? [closed]
I am looking for advice on the neatest way to structure my code.
class Password
{
private string cipher;
Password(string cipher)
{
this.cipher = cipher;
}
public string ...
5
votes
2answers
198 views
Domain Services as facades
I read .NET Domain-Driven Design with C#: Problem - Design - Solution and I noticed that the author created a domain service for each aggregate root.
However, the domain services were only facades to ...
5
votes
2answers
502 views
Event Driven Programming: A sequence of unfortunate events
I have a very basic game loop whose primary purpose is to check for updates & changes to a list.
I have contemplated using event driven programming to replace the game loop/list idea with an ...
3
votes
4answers
200 views
Should we validate a state transition before attempting it in the State Pattern?
When applying the State Pattern illegal transitions should result in an exception being thrown (or at least that's what I understood from the pattern)
I know exceptions are for "unexpected behavior" ...
1
vote
3answers
512 views
Best Practices Returning Read-Only Object
I have "best practices" question about OOP in C# (but it sort-of applies to all languages).
Consider having library class with object that is to be exposed to public, say via property accessor,
but ...
3
votes
2answers
188 views
Can I apply SOLID concepts to entire solution designs rather than just the internal components?
So maybe the quick answer is 'Yes' absolutely (or no I suppose), but let me explain my question angle to get a better derived answer.
We all commonly use SOLID design principals when making up the ...
0
votes
3answers
238 views
How can I understand aggregation and containment?
I'm confused between aggregation and containment. I'm wondering if the following represent an aggregation or containment?
class Auto
{
private string model;
private int speed;
class ...
13
votes
3answers
526 views
Does the state Pattern violate Liskov Substitution Principle?
This image is taken from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET
This is the class diagram for the State Pattern where a SalesOrder can have different states during ...
1
vote
2answers
554 views
Static variable - Usage and Implications on Threading
I have some confusion regarding the use of static variables/references in a class. It feels like I may not have entirely figured out the implications of keeping something static.
When I say a ...
2
votes
2answers
142 views
Designing entities to be self-manageable
Although this is a gamedev project, the question is about general OOP practices, so I believe it goes here. Here's the problem:
(note: I will call any equivalent of real-world physical objects ...
1
vote
3answers
337 views
Setting up ASP.NET structure for code
I've always coded in C# MVC3 when developing web applications. But now i wanted to learn a bit more about developing web sites with just ASP.NET.
But now i'm wondering what a good setup for my code ...
5
votes
3answers
481 views
Manager/Container class vs static class methods
Suppose I have a Widget class that is part of a framework used independently by many applications. I create Widget instances in many situations and their lifetimes vary. In addition to Widget's ...
3
votes
6answers
902 views
How get and set accessors work
The standard method of implementing get and set accessors in C# and VB.NET is to use a public property to set and retrieve the value of a corresponding private variable. Am I right in saying that ...
6
votes
2answers
198 views
How far should an entity take care of its properties values by itself?
Let's consider the following example of a class, which is an entity that I'm using through Entity Framework.
- InvoiceHeader
- BilledAmount (property, decimal)
- PaidAmount (property, ...
1
vote
3answers
139 views
Figuring out the Call chain [closed]
Let's say I have an assemblyA that has a method which creates an instance of assemblyB and calls its MethodFoo().
Now assemblyB also creates an instance of assemblyC and calls MethodFoo().
So no ...
7
votes
5answers
723 views
Abstract DAL - Use Interface with Internal Class?
We have a business logic layer (BLL) that is tightly coupled to our data access layer (DAL). We make calls like this:
using (FooData data = new FooData())
{
data.DoSomething();
}
It's important ...
4
votes
5answers
2k views
Best way to load application settings
A simple way to keep the settings of a Java application is represented by a text file with ".properties" extension containing the identifier of each setting associated with a specific value (this ...
2
votes
5answers
2k views
How to create a common interface for classes with different subsets of members
Don't know how to put it, But I'll try to be as clear as possible
I have a project in which I am creating lots of classes and those classes have some common properties and methods but those methods ...
20
votes
5answers
945 views
Pass ID or Object?
When providing a business logic method to get a domain entity, should the parameter accept an object or an ID? For example, should we do this:
public Foo GetItem(int id) {}
or this:
public Foo ...
1
vote
1answer
294 views
Abstraction Layer over ORM Generated Entities
I am learning LINQ to SQL (and planning to learn Entity Framework). Initially I used a abstraction layer to convert LINQ to SQL entities into a domain objects. Later I discovered the “Inheritance ...
2
votes
3answers
301 views
Starting C++ Programming (for a C# Developer)
I am a C# developer. I am planning to learn C++. (I hope I will be able to leverage the OOP concepts from C#]
I have a Windows 7 machine.
What are the tools that I need to install for C++ ...
19
votes
3answers
10k views
Programming SOLID Principles
Over time I could understand two parts of SOLID – the “S” and “O”.
“O” – I learned Open Closed Principle with the help of Inheritance and Strategy Pattern.
“S” – I learned Single Responsibility ...
8
votes
7answers
905 views
Difference between Pattern and Principle
What is the difference between Object Oriented Design Patterns and Principles? Are they different things? As far as I understood both of them try to achieve some common goal (e,g. flexibility). So can ...
7
votes
1answer
622 views
Using visitor pattern with large object hierarchy
Context
I've been using with a hierarchy of objects (an expression tree) a "pseudo" visitor pattern (pseudo, as in it does not use double dispatch) :
public interface MyInterface
{
void ...
2
votes
5answers
855 views
I feel unprepared to start my first job out of college… how can I improve? [closed]
I just graduated from university with a degree in Computer Science/Engineering and was fortunate enough to land a job working in the pharmaceutical industry as a developer. My title is System ...
7
votes
3answers
1k views
websites that show real world scenarios for OOP beginners so that they can implement them
Since programmers learn more by implementing the real world scenarios rather then by gaining theoretical knowledge and concepts about programming, I wanted to know that is there any website that tells ...
3
votes
4answers
255 views
As a tooling/automation developer, can I be making better use of OOP?
My time as a developer (~8 yrs) has been spent creating tooling/automation of one sort or another. The tools I develop usually interface with one or more API's. These API's could be win32, WMI, ...
14
votes
4answers
4k views
what is message passing in OO?
I've been studying OO programming, primarily in C++, C# and Java. I thought I had a good grasp on it with my understanding of encapsulation, inheritance and polymorphism (as well as reading a lot of ...
2
votes
1answer
1k views
Object orientated data structures in database driven applications
I've started working for a company that maintains a small/medium sized commercial website. The website is written in c# asp.net, and uses SQL Server as a database. The structure of the code is very ...
2
votes
2answers
216 views
Putting it all together
I've been reading a few books on c# development over the last few months (clr via c#, architecting applications for the enterprise, c# 4 in nutshell just to give you an idea). I really feel it's been ...
3
votes
5answers
409 views
Using XML field Vs. creating a table for unstable organization
I am in the middle of design an application to issue and store invoices for an organization. The problem is the organization is not stable at all. There are many types of invoices and they may ...
6
votes
4answers
568 views
Object-oriented design question
I am using a class through a dll to which I do not have direct control. So in effect, I am only a client of this class.
The class represents a form that can be printed, sent to clients and tracked ...
6
votes
4answers
605 views
What is the best way to access multiple child properties?
I have a situation where I have to access several "sub-properties" of an object and find it quite appalling to write such code.
I was wondering how best to deal with this situation:
void Main()
{
...
6
votes
6answers
462 views
Organizing Class Members in Regards to Access Modifier
If we look at typical implementation of a Class, we usually see the private members defined at the beginning and public( mostly functions and Accessors) defined towards the bottom. Now, is this a ...
1
vote
2answers
350 views
Implications of handles between forms
I was developing a WindowsForm application in C#, with 2 forms. Regardless of what they both did specifically I needed to access values in form2 and send them to form1 and vice versa. For this to ...
5
votes
3answers
376 views
Architecture Question
I am writing a rules/eligibility Module.
I have 2 sets of data, one is the customer data and the other is the customer products data.
Customer data to Customer products data is one to many.
Now I ...
2
votes
5answers
268 views
What is the better design decision approach?
I have two classes (MyFoo1 and MyFoo2) that share some common functionality. So far it does not seem like I need any polymorphic inheritence but at this point I am considering the following options:
...
4
votes
4answers
566 views
Why are public and private accessors considered good practice? [duplicate]
Possible Duplicate:
When are Getters and Setters Justified
Why exactly is having public and private accessors like these:
private string foo;
public string Foo
{
get
{
...
11
votes
4answers
2k views
Using static classes as namespaces
I have seen other developers using static classes as namespaces
public static class CategoryA
{
public class Item1
{
public void DoSomething() { }
}
public class Item2
{
...
2
votes
4answers
393 views
Which is most important to learn OOP first or to learn the OOP language you want to learn?
I face a problem nowadays, I have a really good book that explain OOP but it uses a language which I do not want to learn which is Java because my goal is to learn C#. And I don't know if I should ...
0
votes
2answers
121 views
Is hooking Data access method on wrong object detrimental for a developer
In a simple application I am creating there are Admin and users where admin can create users. Right now I am creating Classes that encapsulate database CRUD calls with methods.
For example: ...
12
votes
3answers
4k views
Which is a better practice - helper methods as instance or static?
This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well.
Anyway, ...
9
votes
4answers
3k views
In simple words what are are the purposes of abstract classes and/or interfaces?
I have to explain to some students the use of abstract classes and interfaces, as I have a very tecnical background, I would like to know if you would help me to define an easy explanation for junior.
...
7
votes
6answers
827 views
Object-Oriented Class Design
I was wondering about good object oriented class design. In particular, I have a hard time deciding between these options:
static vs instance method
method with no parameters or return value vs ...
3
votes
2answers
224 views
Application design question regarding saving files
I am working on an application in C# and I am having some extreme difficulty solving this design issue.
Basically the application allows users to create cook books. A user can click "new book" and ...
9
votes
4answers
2k views
Abstract Base Class with Interfaces as Behaviors?
I need to design a class hierarchy for my C# project. Basically, class' functionalities are similar to WinForms classes so let's take WinForms toolkit as an example. (However, I can't use WinForms or ...


