class-design

Is there any point to an interface if only one class implements it?

Looking at the (mature) codebase at my new job, there is an interface, and only one class implements it (as far as I can tell). Can/should I get rid of the interface? ...

MyClassBase or BaseMyClass?

Possible Duplicates: Using Base in a Class Name C# Class naming convention: Is it BaseClass or ClassBase or AbstractClass Naming Conventions for Abstract Classes What is the better way to name base abstract classes? I still can't decide where to put 'Base' word. Should it be 'BaseMyClass' or 'MyClassBase'? How do you name...

why is java.lang.Throwable a class?

In java adjectives ending in -able are interfaces Serializable, Comparable etc... So why is Throwable a class? Wouldn't exception handling be easier if Throwable were an interface? (Edit: e.g. Exception classes don't need to extend Exception/RuntimeException.) Obviously, changing it now is out the question. But could it be made abstract...

Best way to have common class shared by both C++ and Ruby?

I am currently working on a project where a team of us are designing a game, all of us are proficient in ruby and some (but not all) of us are proficient in c++. Initially we made the backend in ruby but we ported it to c++ for more speed. The c++ port of the backend has exactly the same features and algorithms as the original ruby code....

Is passing a struct value to a method by-reference in C# an acceptable optimization?

Say I have a struct: struct MyStruct { public int X public int Y } And a method in some class that is iterated over many times elsewhere: public bool MyMethod( MyStruct myStruct ) { return ... } Is changing the MyMethod signature to the following an acceptable optimization? public bool MyMethod( ref MyStruct myStruct )...

ERD-CLASS design

Hello guyz,i am new to daatbase and class diagram.I just get scenarios from internet and try to develop ERD and Class Diagram for them.But the following scenario has caused me some problems, and i am not sure about my design. "Whenever an employee fills leave application form, the leave application should be appeared for approval to his...

STLifying C++ classes

I'm trying to write a class which contains several std::vectors as data members, and provides a subset of vector's interface to access them: class Mesh { public: private: std::vector<Vector3> positions; std::vector<Vector3> normals; // Several other members along the same lines }; The main thing you can do with a mesh is add pos...

An issue on object orientation in php

Hello people, I have come up to issues while I'm trying to write some classes, here is an example: I have this class called TwitterGrub and I cant call it like that: $c = new TwitterGrub(); $c->twitterDisplay(); here is the class itself: <?php class TwitterGrub{ function twitterCapture($user = 'username',$password = 'pass')...

Help required in adding new methods, properties into existing classes dynamically

Hi All, I am not sure whether it is possible to achieve this kind of implementation in Dot Net. Below are the information Currently we are on an application which is done in COM+, ASP, XSL, XML technologies. It is a multi tier architecture application in which COM+ acts as the BAL. The execution steps for any CRUD operation will be def...

Using nested classes for constants?

What's wrong with using nested classes to group constants? Like so: public static class Constants { public static class CategoryA { public const string ValueX = "CatA_X"; public const string ValueY = "CatA_Y"; } public static class CategoryB { public const string ValueX = "CatB_X"; pu...

What's a common practice of completing abstract class?

You have a class, that perfectly fits to be an abstract, but this class cannot work normally without data supplied from derived class. It's not convenient to pass all data to constructor because not all of it may be needed, and many of them can be dynamic (result from child function). What are the best practices to compose such structur...

Python: How should I make instance variables available?

Suppose I have: class myclass: def __init__(self): self.foo = "bar" where the value of foo needs to be available to users of myclass. Is it OK to just read the value of foo directly from an instance of myclass? Should I add a get_foo method to myclass or perhaps add a foo property? What's the best practice here? ...

What options are there for visualising class relationships in a Python program

I am maintaining a Python program, and am struggling to understand the relationships between the various classes. I think it would be helpful to see a diagram of how the classes interact. What options are there available that might allow me to do this? ...

Python - help on custom wx.Python (pyDev) class

I have been hitting a dead end with this program. I am trying to build a class that will let me control the BIP's of a button when it is in use. so far this is what i have (see following.) It keeps running this weird error TypeError: 'module' object is not callable - I, coming from C++ and C# (for some reason the #include... is so much e...

Object oriented n-tier design. Am I abstracting too much? Or not enough?

Hi guys, I'm building my first enterprise grade solution (at least I'm attempting to make it enterprise grade). I'm trying to follow best practice design patterns but am starting to worry that I might be going too far with abstraction. I'm trying to build my asp.net webforms (in C#) app as an n-tier application. I've created a Data Acc...

Class design: is creating an object just for creation of objects from child classes bad form?

I currently have a message system which writes to two tables, sent and received, which largely have the same schema. I wrote a class called Message which populates the user inputted data before instantiating the two child classes which use a common method in Messageto set the rest of the properties and writing each to the database. The...

Objective-C partial implementation of classes in separate files

I am using core data and am generating classes from my data model. I implement custom methods in these classes, however when i regenerate i generate over the top so i end up copying and pasting a bit. What i would like to do is split my implementation files ('.m') so i can have one header file with multiple '.m' files. then i can keep m...

QT: View class hierarchy of any project (based on object instances or ... )

Hi, Is there any way to view class hierarchy of any QT project graphically? (Project made by using QT-Creator.) I have a big code bundle .. very badly managed code. I need to start working with it. but first I need to study it nicely. Some tool : Class viewer like one in VC++ (.NET)!? I want the QT project class hierarchy, look like th...

C# generics - Can I make T be from one of two choices?

Suppose I have the following class hierarchy: Class A {...} Class B : A {...} Class C : A {...} What I currently have is Class D<T> where T : A {...} but I'd like something of the form Class D<T> where T in {B,C} This is due to some odd behavior I'm not responsible for where B and C have common methods which aren't in A, but ...

Is it a good practice to call methods from constructors?

Is it a good practice to call methods from constructors? ...