class-design

Accessing an object from a different class - Design

I have three classes, TImageProcessingEngine, TImage and TProcessing TImageProcessingEngine is the one which i am using to expose all my methods to the world. TImage is the one i plan to use generic image read and image write functions. TProcessing contains methods that will perform imaging operations. class TImageProcessingEngine {...

Pattern for class instantiation from only one single place?

C# .Net 4.0 I'd like to know how I can have a class which can only be instantiated from one single place. An example: I've got a Provider class. This class exposes a method called GetData. When GetData is called, the Provider will instanciate a Data class, populate and return it. The Data class cannot be instanciated by anybody differe...

My application works perfectly local but not in the remote server

When I upload the files on the remote server I get the following message: Object reference not set to an instance of an object And a few errors supposed to be happening in the ClassDesigner file and other few classes... I need help urgently please. What do you think is going on? Thank you! ...

Is there a way in C++ to render a class' interface private to all classes except a few?

I am writing a B-link tree and its attendant sub classes like a data page class and a node class etc. I was wondering is there a way to protect the public interfaces of the nodes and pages such that only the b-link tree class itself can access them, WITHOUT simultaneously exposing the private methods of the pages and nodes to the b-link...

Casting one object to another

I have to Classes. lets say Invoice and TempInvoice. Both have same properties(all are same). let say i created a object using Invoice Class. Can i cast that object to another object that i created using tempInvoice ?? ex: Invoice invoiceobj= getInvoice(int? id) //a method return a invoice object TempInvoice tempInvoiceObject = invoic...

Usage of Generalization over Aggregation.

Hi, I have this class model where, Bank is a class which is now going for computerized Banking network. This must have ATM(Automatic Teller Machine) and also Human Cashier. I used Generalization and have taken a class called AccountHandlers which inherits Bank class. This AccountHandlers further have ATM and HumanCashier aggregated to ...

C++ : Implement the copy-assignment operator in a class with *all* const data members. Does this make sense?

Hello, long-time reader, first-time poster here, with a (hopefully) straightforward question about C++ class design. Imagine I have a class used to represent some trivial numerical data, like a vector. I want this class to be immutable in terms of its members, but still support correct copy-assignment behaviour. This is what the shell ...

php tree class/array structure to breadcrumbs

Basically i received an API SOAP response of a list of categories in an class format as in array kind of way with CatID, name, parentID, level. What is the best way to turn this into an array of breadcrumbs for each CatID. I want to try reduce the number of operation as the array will be created on the fly to populate a drop down me...

How to have an abstract method return an abstract type with concrete implementations?

I have three classes that will each return a slightly different result. // interfact to a king public interface IKing{ public Result Get(); } // main abstract class public abstract class King:IKing{ public abstract Result Get(); } // main abstract result public abstract class Result{ public int Type {get;set;} } // KingA result...

Do you know any editor, that can handle the Xcode xcclassmodel-files ?

Any time i do a class-diagramm with the Xcode-internal solution, any inheritance-link is missing. But anytime another.. it is not even the same link, that is missing. so, has anyone an idea, how to edit the files manually ? ...

Assign class methods from YAML file.

In short,I've written an application that parses text files in specified formats from different email feeds. Currently, there are two formats allowed by users in order to correctly upload information. I've also included a simple YAML file that allows people with non-programming backgrounds (ie sysadmins) to define the basics parsing pa...

Looking for a way to hide a class' base class

I'm building a library where I've got a pattern like the following: public class Foo : Foo_Impl { } public class Foo_Impl { } I don't want other developers to accidentally use the Foo_Impl class. What options are available to me to hide this? I'd also like to hide it from other classes in the same assembly it's defined in. Ideally...

Is anything good/bad/unnecessary about this use of a public member?

Here is a synopsis of my code which is a moderately complex WinForms GUI. The context of the dependencies is the model view presenter pattern. public class StatSyncherFormView : Form, IView { ... } public class Presenter { // Here is the member I made public public readonly IView view; public Presenter(IView view) { ...

Large scale usage of Meyer's advice to prefer Non-member,non-friend functions?

For some time I've been designing my class interfaces to be minimal, preferring namespace-wrapped non-member functions over member functions. Essentially following Scott Meyer's advice in the article How Non-Member Functions Improve Encapsulation. I've been doing this with good effect in a few small scale projects, but I'm wondering...

Mixed vs. separated class mutability

In a partially mutable class, is it better to mix mutable fields with its immutable ones, or create a new class (or classes) that encapsulate them? Here's an example in C# of what I'm talking about: interface IBedroom { int Volume { get; } string Color { get; } void Paint(string newColor); } Here's an implementation wit...

Class members that are objects - Pointers or not? C++

Hi, If I create a class MyClass and it has some private member say MyOtherClass, is it better to make MyOtherClass a pointer or not? What does it mean also to have it as not a pointer in terms of where it is stored in memory? Will the object be created when the class is created? I noticed that the examples in QT usually declare class ...

Should I use struct or class?

I am in a classic design dilemma. I am writing a C# data structure for containing a value and measurement unit tuple (e.g. 7.0 millimeters) and I am wondering if I should use a reference type or a value type. The benefits of a struct should be less heap action giving me better performance in expressions and less stress on the garbage co...

SSIS: Curious: why is the last parameter in FireInformation method a ref bool?

I'm currently working on a SSIS package and after the 80th time using FireInformation inside a Script Task, I have to wonder: why would the method require you to pass in a ref boolean as its last parameter? The documentation doesn't state anything about how you should respond to the value once the method returns. Am I missing something h...

python global object cache

Hello Little question concerning app architecture: I have a python script, running as a daemon. Inside i have many objects, all inheriting from one class (let's name it 'entity') I have also one main object, let it be 'topsys' Entities are identified by pair (id, type (= class, roughly)), and they are connected in many wicked ways. ...

Problem Implementing Function With Existing Class Design

I've currently started on my semester project for my programming course- programming a fully autonomous driving simulator. All cars are steered through AI and the map is printed in the console. The first sheet wants us to create a couple of basic classes: FCCompact (The car), Scanner (AI), ID (terrain), and World (The map). The Scann...