oo-design

How would you design OO classes to handle cryptosystems and their keys

This a wider question than my previous one but related. I want to implement oldish crypto systems in Ruby such as ADFGVX, VIC cipher and others, mostly for fun. These cryptosystems are built on top of more general systems like substitution (monoalphabetic such as Caesar or polyalphabetic like Vigenere) and transposition (simple, double...

Should a business object collection inherit from Collection<T> when it doesn't extend it?

I have a business object collection (representing data from the database) that inherits from Collection and has a static method that calls a stored proc and then populates its properties with the data returned. My question is; is it wrong to inherit from Collection as it doesnt really extend the class? or would it be better to not inher...

How to declare factory-like method in base class?

I'm looking for solution of C++ class design problem. What I'm trying to achieve is having static method method in base class, which would return instances of objects of descendant types. The point is, some of them should be singletons. I'm writing it in VCL so there is possibility of using __properties, but I'd prefer pure C++ solutions...

References vs information hiding C++

Hi, I need suggestions on how to solve the type of problems described below. I'm fairly new at C++ and OO-design. I've learnt: Pointers shall be avoided when ever they can be replaced by references. Objects shall have no knowledge of objects that they don't need to know about. But when creating objects having references to other o...

I need to search for a "customer" in a db, what would be a good design here?

Hi! We're a couple of students trying to implement a design to search for customer-information in a database. When the GUI-class is asking for any customer with the surname "Jensen", would a customer-class then create many objects for each customer with that surname, give all those objects to the GUI-class, let the GUI-class e.g change s...

Function/Class Design Guidelines

I asked a fellow colleague yesterday if a function has too many parameters whether it would be better to create a class with properties instead. Are there any guidelines that I can follow? ...

C# Implementation process blocks

In my C# winforms application I need to draw blocks. These blocks are so called process blocks. All the blocks together are a process. There are different kinds of process blocks. At this moment I have three kinds of process blocks: A, B, C. When I draw a process block it looks like this: A B B C A Every block has it's own backgrou...

OOP Design - In Python, is this a quality OO Design or an epic fail?

In a system that accepts orders which have payments which have gateway transactions should the objects be like this: class Order(object): ... Inside init ... self.total_in_dollars = <Dollar Amount> self.is_paid = <Boolean Value> class Payment(object): ... Inside init ... self.order = order_instan...

Inheritance vs specific types in Financial Modelling for cashflows

Hello, I have to program some financial applications where I have to represent a schedule of flows. The flows can be of 3 types: fee flow (just a lump payment at some date) floating rate flow (the flow is dependant of an interest rate to be determined at a later date) fixed rate flow (the flow is dependant of an interest rate determine...

Implementing something like std::vector.back()

I would like to implement something like this because my application is divided into scenes and this gets sort of messy: glEngine.scene[glEngine.current.currentScene].layer[glEngine.scene[glEngine.current.currentScene].currentLayer].Shapes.push_back(CGlShape()); instead I'd want to be able to do something like this: glEngine.Scene()....

XLINQ - Is it possible to have conditionals within a query?

In trying to teach myself ASP.NET and OO design in general, I decided to make a simple web-based game. It's a rudimentary role-playing game, where the player can create a character of a certain profession. These professions give the character certain kinds of attacks, and some of these abilities have status effects (poison on enemies, ...

MVC: In which component do details of data presentation specified?

Example is fake. ASP.NET MVC: I have a view that renders a student info. Student info consists of First Name, Last Name and (optional) Age (declared as int?). Student info is rendered something like, if age is not specified I want to show "not specified": <span><%= Model.Student.FirstName %></span> <span><%= Model.Student.LastName %><...

How to unit-test private code without refactoring to separate class?

Assume i have a private routine that performs some calculation: private function TCar.Speed: float { Result = m_furlogs * 23; } But now i want to begin testing this calculation more thoroughly, so i refactor it out to a separate function: public function TCar.Speed: float { Result = CalculateSpeed(m_furlogs); } private functio...

Namespaces with classes and structs?

Will be nice if I got 'nested members' in D language, so I have the inglorious idea to code class Keyboard { struct Unused { string key1 = "Wake Up"; string key2 = "Sleep"; string key3 = "Power"; } Unused unused; } int main() { Keyboard kb; kb.unused.key1 = "Scroll Lock"; return 0; } ...