class-design

Object/Class Design Question

Hi, I have a class as follows :- interface IFilterCondition { List<Name> ApplyFilter(List<Name> namesToFilter); } class FilterName : IFilterCondition { public NameFilterEnum NameFilterEnum{ get; set; } public List<Name> ExcludeList { get; set; } public char StartCharacter{ get; set; } #region IFilterCondition Me...

Input on Class design

Hi all, I currently have service classes that look something like this public class UserService : IUserService { private IAssignmentService _assignmentService; private ILocationService _locationService; private IUserDal _userDal; private IValidationDictionary _validationDictionary; public UserService(IAssignmentSer...

returning a pointer of a class through it's own functions

Is it possible to return a class through it's own function, so you can chain functions like below: class Foo; Foo.setX(12).setY(90); Can anyone confirm if this is possible, and how it would be achieved? ...

CRUD Class Library Design, to return useful messages about business logic failure, that is not exceptional

I'm building a basic CRUD library, that I anticipate use in both local (add reference) and wcf (add service reference) environments. What are the best return types for the Create, Uupdate, and Delete portions (that have more complex business rules) of a CRUD setup? I want to be able to minimize back-and-forth on the wire, but I also wa...

Design pattern for class with upwards of 100 properties

What advice/suggestions/guidance would you provide for designing a class that has upwards of 100 properties? Background The class describes an invoice. An invoice can have upwards of 100 attributes describing it, i.e. date, amount, code, etc... The system we are submitting the invoice to uses each of the 100 attributes and is submitte...

association as an object type or id reference

Which one is better: I have a class "User" and "Profile". in "User" I'll have a property that will be associated with the "Profile". The two classes will be stored in two different tables "Users" and "Profiles". In table "Profiles" there will be foreign key to "Users" table". In my "User" class, should I include a property of type "Pr...

lisp file pointers in classes

I'm running up against a problem in understanding the CLOS way of handling file access within a class. In c++ I would be able to do this: class Foo { Foo (string filename); // opens the file (my_file) requested by the filename ~Foo (); // close the file FILE * my_file; // a persistent file-handle DataStruct my_data; // ...

PHP5: const vs static

In PHP5, what is the difference between using const and static? When is each appropriate? And what role does public, protected and private play - if any. ...

Downside of this macro construct and possible alternatives

I recently saw some code using macros like #define CONTAINS(Class, Name)\ private:\ std::list<Class> m_##Name##s;\ public:\ void add_##Name(const Class& a_##Name) {\ m_##Name##s.push_back(a_##Name);\ }\ int get_##Name(int pos) {\ return m_##Name##s.at(pos);\ }\ ...

Using a class in its constructor C# - Does it smell?

Does the code below smell? I'm refactoring some code and have discovered this circular relationship where foo needs a class which needs an interface which foo itself implements. In the real code, foo is a Silverlight UserControl and ifoo has methods to do UI type things like raise a dialog box (eg ShowMessage). The needsAnIfoo class is ...

How to convert C++ class/struct to a primitive/different type/class/struct?

Hi all! I have the following class CppProperty class that holds value: template<typename TT> class CppProperty { TT val; public: CppProperty(void) { } CppProperty(TT aval) : val(aval) { } CppProperty(const CppProperty & rhs) { this->val = rhs.val; } virtual ~CppProperty(void) { ...

Design classes - OOPS features

Hi Friends, Actually I am interested in improving my designing capability(designing of classes with its properties, methods etc) when a problem is given. ie How to decide what could be the classes involved? and then decide the methods and properties? Can you guys suggest me good material for improving on this. Regards, Justin Samuel. ...

self = Descendant in Ruby?

Hi there, I have a text log from a game with (for example) two types of entries viz. Chat and Event. For the most part they are very similar so I have a LogEntry class defined as so; class LogEntry < Array def initialize(str) super str.split end def parse LogEntry.parse self end def LogEntry.parse(entry) # Proc...

Initialising classes inside another class in C++?

I have this definition in a header file: class Owner { private: // Fields Child* _myChild1; public: // Constructors Owner(); Owner(const char childName[]); }; and this implementation: Owner::Owner(const char childName[]) { //do some operations - children must be created after these ops _myChild = new Child(childName); } and th...

Policies Array Class-Design wrapper

Hi, i want to write an wrapper for different Array Classes with different Policies. For example: typedef ArrayType<useValArray,StdAllocator> Array; // one global assignment I want to use the class like a blitz++ Array for example: Array<double,2> x(2,2); //maps the Array to an Valarray or to a Blitz++ Array Array<double,2> x2(5,...

Object oriented programming - class design confusion

I am trying to wrap my head around object oriented programming. My understanding is that we have objects so we can design our programs to mirror real-life objects. Lets take a class hierarchy: Fruit (base) Apple Fruit has a function void Eat(). Obviously you can use Fruit polymorphically if Eat() is virtual. But does this make sen...

C# - A class-design problem - Loading property List.

Suppose I have a class like the following: public class Stage { public int ID {get; set;} public strint Code {get; set;} public string Name {get; set;} private List<Machine> _machines; public List<Machine> Machines { get{ return _machines; } set{ _machines = value; } } ......... ......... ...

Custom Actionscript 3.0 Events: Build separate Classes for different purposes or use one for all?

I'm using custom Events in Actionscript 3.0 for the first time and I'm unsure about how to best design them. I need a couple of Events. Some of them need to transport different kinds of data and some don't. Now I don't know whether I should use a single class to implement them all or use separate classes for different kinds of purposes. ...

Object representation of betting rounds at poker

Hi, I'm writing a HandConverter of a poker hand. This is my first project and I'm trying to do it right from the beginning. I got already the most parts, like lists of players, their position, stack sizes, cards for different boards, what game is being played and so on, but I struggle with the representation of the betting, especially t...

Passing around base class pointers

Scenario: I have the following defined classes. class Baseclass { }; class DerivedTypeA : public Baseclass { }; class DerivedTypeB : public Baseclass { }; // ... and so on ... class Container { list<Baseclass*> stuff; list<DerivedTypeA*> specific_stuff; // ... initializing constructors and so on ... public: void add(Basecla...