2
votes
2answers
232 views

Implementing the Interface Segregation Principle

Does this IConvertible interface satisfy the Interface Segregation Principle (ie. the "I" in SOLID)? Here is the definition: public interface IConvertible { TypeCode GetTypeCode(); bool ...
3
votes
2answers
155 views

Is it an acceptable practice to Get a property, that involve parsing binary, that might throw an exception?

I have a property that is loaded lazily, any time after the ctor is called. It is possible that the binary that my property relies on is invalid. If invalid I might have to throw an exception. ...
2
votes
3answers
240 views

Empty virtual method on base class VS abstract methods

I couldn't find a question that was not too specific to some case, so I'll try to make this very generic. We need an extractor base class to a set of documents, for example. Each document has its ...
2
votes
2answers
155 views

Pattern for multiple datasources

I've already read this question on CodeReview. I was hoping for general advice. I'm writing a service which will go to numerous data sources. Each source requires getting copious amounts of data ...
-4
votes
1answer
96 views

what is the main utility of Interface in real world programming (OOPS) [duplicate]

what is the main utility of Interface. we know that we can implement dynamic behavior using interface but i guess it is not only the utility. so i like to know when we have to write interface and when ...
1
vote
1answer
103 views

When to use Interface variable = new class variable OOP

I saw often people use this code like interface IAnimal { void die(); } class Cat : IAnimal { void die() { ... } void meow() { ... } } IAnimal anAnimal = new Cat(); Cat aCat= new ...
0
votes
1answer
154 views

ASP.NET C# and MVC - Step by Step [closed]

I am totally new and do not know where to start learning. I am exposed to the IT industry in a broad manner at work with no specific thing to learn about. I definitely want to work with c# and MVC to ...
1
vote
1answer
337 views

A class with only methods

What's the name for a class that has only methods? There are no fields/properties. Just two methods with the ability to parse some file in two ways. I have named the class Parser, but it just doesn't ...
2
votes
5answers
327 views

Should I use automatic properties?

I'm new to C# coming from a Java background. I'm working on a take home assignment for a coding interview. I normally write my code as following(Java): public class Test { //fields private ...
1
vote
3answers
203 views

Pattern for costly precondition check before acting

Let's say I have a method DoTheThing() which requires the precondition-check CanTheThingBeDone() to return true. The latter method is time consuming as it accesses the database. I'm finding it hard ...
1
vote
1answer
97 views

Question on Graph

I am trying to implement a graph data structure in C#. I have the following interfaces: public interface IVertex<TValue> { TValue Value { get;} ...
0
votes
1answer
167 views

Need an OOP pattern or strategy for “pluggable” property

I'm using OOP and MVVM in a WPF c# application. The goal is for the resulting object (data-bound to user interface) to accurately represent a product. One specific area of the product is highly ...
0
votes
1answer
127 views

What's a similar functionality in JavaScript that insures the object has X data before any actions are taken?

If java/C#/etc one might do something like create a constructor with a parameter, the parameter being the thing the rest of the object may act upon. How is this done in JavaScript? I'm trying to ...
32
votes
3answers
1k views

Does Java development typically involve more subclassing than C#/.NET?

I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly ...
1
vote
3answers
293 views

Problems with Facades and then evolution in software

I initially started a project with Facades and Polymorphism as a way to create simple extensible design following SOLID Principles. Here is a sample code: public interface IInterface { void ...
0
votes
4answers
367 views

Problem regarding DRY principle and Polymorphism

I have a class that is 99% identical to its counter part. Sample code goes below: public abstract class BaseClass { void Method1() { } void Method2() { } void Method3() { } public ...
5
votes
1answer
425 views

Dictionary of objects

I have a dictionary of Objects of a class Columns Dictionary<double, Columns> Columns is a class of columns, i.e. name, post code, etc, mobile phone. I would like to make Columns class as ...
4
votes
5answers
493 views

How to model an address type in DDD?

I have an User entity that has a Set of Address where Address is a value object: class User{ ... private Set<Address> addresses; ... public setAddresses(Set<Address> ...
1
vote
3answers
411 views

C# vector class - Interpolation design decision

Currently I'm working on a vector class in C# and now I'm coming to the point, where I've to figure out, how i want to implement the functions for interpolation between two vectors. At first I came up ...
23
votes
3answers
3k views

Rich Domain Models — how, exactly, does behavior fit in?

In the debate of Rich vs. Anemic domain models, the internet is full of philosophical advice but short on authoritative examples. The objective of this question is to find definitive guidelines and ...
1
vote
2answers
437 views

Memory allocation of Classes that don't have any global data and locks

static void Main(string[] args) { var c2 = new Class2(); var c3 = new Class3(); var c1 = new Class1(c2, c3); c1.Method1(); } class Class1 { ...
1
vote
4answers
475 views

How do you evaluate learning C# from videos for a beginner? [closed]

I have an idea about programming in general so I know what a variable and a method is but I didn't program before. I liked C# because of Visual Studio and I only tried Hello word program in it. I ...
1
vote
2answers
150 views

Determining the aggregates in this domain

I'm working on an ordering system where we receive tab delimited files that look like this (I removed most of the columns for clarity): OrderId OrderLineId BuyerName BuyerAdress ...
1
vote
3answers
318 views

Does non-virtual-by-default lead us to composition-over-inheritance?

There are some design guidelines about testable code in “The Art of Unit Testing”. The first one is “Make methods virtual by default”. I’m curious to know your idea about non-virtual-by-default ...
3
votes
1answer
682 views

Cookie access within a HTTP Class

I have a HTTP class that has a Get, and Post, method. It's a simple class I created to encapsulate Post and Get requests so I don't have to repeat the get/post code throughout the application. In C#: ...
23
votes
1answer
1k views

Why is an anemic domain model considered bad in C#/OOP, but very important in F#/FP?

In a blog post on F# for fun and profit, it says: In a functional design, it is very important to separate behavior from data. The data types are simple and "dumb". And then separately, you ...
2
votes
3answers
339 views

Recommened design pattern to handle multiple compression algorithms for a class hierarchy

For all you OOD experts. What would be the recommended way to model the following scenario? I have a certain class hierarchy similar to the following one: class Base { ... } class Derived1 : ...
5
votes
4answers
3k 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
366 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 ...
4
votes
7answers
498 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
329 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 ...
7
votes
2answers
494 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
1k 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 ...
4
votes
4answers
341 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" ...
4
votes
3answers
2k 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
249 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
873 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 ...
15
votes
3answers
858 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
1k 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
178 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
638 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
2k 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 ...
2
votes
6answers
2k 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
314 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
222 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
1k 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 ...
7
votes
5answers
8k 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
4k 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 ...
24
votes
5answers
2k 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
382 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 ...