subclassing

Best way to decide which subclass is needed

I am working on a large-scale checkout application for a current project. This checkout has many cases depending on the user's admin level, how they got to the checkout, and what type of item they are checking out, and so the process is abstracted away from the .aspx pages via a set of context classes. These classes all subclass from a ...

Subclassing in Python

This solves my issue. No subclassing needed. class DrvCrystalfontzProxy(Text): @classmethod def get(cls, model, visitor, obj=None, config=None): if model not in Models.keys(): error("Unknown Crystalfontz model %s" % model) return model = Models[model] if model.protocol == 1: ...

utility class vs subclassing .net controls

I want to reuse some code I wrote to add some functionality to a datagridview. I want the default datagridview properties and events to be exposed, so I didn't want to create a new custom component. so I tried writing a subclass, which works fine. but it also occurred to me that I could write a standalone utility class that takes a datag...

OOP. Choosing objects

I'm a relative newbie to thinking in OOP terms, and haven't yet found my ‘gut instinct’ as to the right way to do it. As an exercise I'm trying to figure out where you'd create the line between different types of objects, using the drinks on my desk as an example. Assuming I create an object Drink, that has attributes like volume and te...

ASP.Net Treeview: Strange postback behavior

I have a ASP.NET treeview populated with custom treenodes (ExtensionRangeTreeNode subclassed from TreeNode). On postback the treeview is populated with TreeNodes, not my custom treenode class. What's up with this? Thanks, BP ...

Database and relationship design when subclassing a model.

I have a model "Task" which will HABTM many "TaskTargets". When it comes to TaskTargets however, I'm writing the base TaskTarget class which is abstract (as much as can be in Rails). TaskTarget will be subclassed by various different conceptualizations of anything that can be the target of a task. So say, software subsystem, customer ...

Instanceof and Type-casting Techniques

I have a question about technique and implementation, rather than an actual problem to solve. Recently I created an abstract class, let's called it A, which defines the common behaviors of its subclasses. I use this to construct several subclasses B, C, and D, which are then passed to some other method outside of the superclass-subclas...

UIImageView subclass does not display

I am using a custom subclass of UIImageView, but I can't figure out why it's not being displayed. The relevant code from my UIImageView subclass: -(id) initWithImage:(UIImage*)image{ if(self = [super initWithImage:image]){ } return self; } And from the view controller for the view that will be displaying my subclass: UII...

Need suggestions on an approach to take...

We have a solution with two different projects, one with the requirement that it be done using the .Net 2.0 framework. The other uses .Net 3.5, and we follow MVVM, though I suspect this is less about MVVM than good patterns. The .Net 2.0 has several different objects (let's say of type Fruit) which could potentially require a different ...

Doing it right in Django - subclassing instead of hacking

I am using the threadedcomments module and need two changes: - an additional field on the ThreadedComment model - different fields on the form I know the answer is to subclass but I'm not sure how to go about doing this - where does the code go? ...

How to cast 'Class A' to its subclass 'Class B' - Objective-C

I'm using a framework which defines and uses 'ClassA', a subclass of NSObject. I would like to add some variables and functionality so naturally I created 'ClassB', a subclass of 'ClassA' Now my problem is this. Many of the methods within this framework return instances of 'ClassA' which I would like to cast to my subclass. For exampl...

subclassing int to attain a Hex representation

Basically I want to have access to all standard python int operators, eg __and__ and __xor__ etc, specifically whenever the result is finally printed I want it represented in Hex format. (Kind of like putting my calculator into Hex mode) class Hex(int): def __repr__(self): return "0x%x"%self __str__=__repr__ # this certainly he...

C++: Is there a way to forbid subclassing of my class?

Hi all, Say I've got a class called "Base", and a class called "Derived" which is a subclass of Base and accesses protected methods and members of Base. What I want to do now is make it so that no other classes can subclass Derived. In Java I can accomplish that by declaring the Derived class "final". Is there some C++ trick that can...

Globally intercept window movement

I am having trouble getting a global system hook to work. I want to be notified whenever a window is moving, as early as possible, and change the window size. This means the CBT hook HCBT_MOVESIZE won't cut it, it only happens after the window has been moved. I want to hook the actual movement of the window, and be able to change the win...

Can't figure out where to start subclassing a UIControl!

Hi there, I want to create my own control that will consist of several UILabels and a couple of UITextFields. The problem is I'm not sure where to start! Do I directly subclass UIControl, then create my subviews and add them to the main view in init:? Or do I use layoutSubviews? And will I need to override drawRect:? I'm used to creati...

Subclassing a window with a functor (Win32)

Quick sanity check: Is it possible to subclass a window using a functor? I'm running into a situation where I want to have some data available in the win proc, but GWLP_USERDATA is already being used. A functor seems like a good alternative, but I'm having trouble getting it to work. Here's the basics: class MyWinProc { // Win Proc Fun...

Making NSScroller larger

I'm making a Cocoa application optimized for external touch sensitive screens, so I want to make a large scollbar in an NSScrollView. I've tried just to resize the scrollers frame, but both drawing and mouse events only happens in the scroll area, it doesn't get wider (it's the vertical scroller). This is the code I'm using (from the sub...

Process All Windows Messages Generated By A Compact Framework Application

Hi Folks, Hoepfully someone can shed some light on a problem - I am trying to listen to\intercept all windows messages generated by an application and dispose of certain types, for example Notify or Gesture messages. I have been reading articals on how to do this using the Microsoft.WindowsCE.Forms.MessageWindow and creating a class wh...

Subclassing a external window in C# .NET

Hi, I'm trying to subclass an external window in C#. I have used something similar before in VB6 without any problem BUT the below code just won't work. Can anybody help me out? //API [DllImport("user32")] private static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr newProc); [DllImport("user32")] private static extern...

Making a thinner UITabBar

I would like to be able to thin the UITabBar's height by removing each item's titles and reclaiming the vertical space they take up, a la Tweetie 2. This doesn't seem settable in the .xib or programmatically. Will I have to subclass the UITabBar and roll my own? ...