inheritance

Overloading and overriding

What is difference between overloading and overriding. ...

Are static inner classes a good idea or poor design?

I'm find I have several places that having public static inner classes designed that extend "helper" classes makes my code a lot more type safe and, in my opinion, readable. For example, imagine I have a "SearchCriteria" class. There are a lot of commonalities for the different things I search for (a search term and then a group of searc...

Joomla: Parameters of List Section Layout are not inherited

Hi, I am Joomla I have a menu item that lists categories in a section. I have changed some of the parameters (like 'do not display headers'). It works on the initial category listing, however after navigating into categories from that page, these parameters no longer apply. For example, lets say we have a menu item 'News' with some pr...

NHibernate - Is it OK to use an abstract base to provide functionality instead of an interface?

I'm fairly new to NHibernate and have run into a strange inheritance chaining issue with my repository classes. I've been using Gabriel Schenker's FAQ as a reference, and following his examples I've been creating interfaces to define contracts for DAO operations in "repository" classes. The data schema I'm working with is rather extens...

Unable to make static reference to generic subclass (Java)

Hi, I have the following code: class SuperClass { public static String getName() { return "super"; } } class SubClass extends SuperClass { public static String getName() { return "sub"; } } public class Dummy<T extends SuperClass> { public void print() { System.out.println("SuperClass: " + SuperClass.getName()); ...

Weird Select/Delete query generation in Linq2SQL

Hi For some or other reason Linq2SQL generates the following on 1 of my tables for a delete: DELETE FROM [dbo].[Tag] WHERE ([TagId] = @p0) AND ([Type] = @p1) -- @p0: Input UniqueIdentifier (Size = 0; Prec = 0; Scale = 0) [fb538481-562d-45f2-bb33-3296cd7d0b28] -- @p1: Input TinyInt (Size = 1; Prec = 0; Sc...

Java inheritance - added methods

Hi all, I want to have a base class, BaseConnect, which contains an OutputStream and children classes ObjectStreamConnect and DataStreamConnect. In my BaseConnect class I have OutputStream os; And in my Two children classes I have the constructors that do "os = ObjectOutputStream(...)" or "os = DataOutputStream(...)", respectively. ...

How do I make a field global to my site?

Okay, this is a bit abstract, but here goes: I'm creating a website and I want to have a field, "foo", that I can access from any page on the site. I figured the best way to do this would be to create a subclass of Page called "bar", add the protected field "foo" to it, and then have all my webpages inheret from "bar". Ta-da. Every ...

C# - using polymorphism in classes I didn't write

What is the best way to implement polymorphic behavior in classes that I can't modify? I currently have some code like: if(obj is ClassA) { // ... } else if(obj is ClassB) { // ... } else if ... The obvious answer is to add a virtual method to the base class, but unfortunately the code is in a different assembly and I can't m...

Using interfaces on abstract classes in C#

I'm learning C# coming from C++ and have run into a wall. I have an abstract class AbstractWidget, an interface IDoesCoolThings, and a class which derives from AbstractWidget called RealWidget: public interface IDoesCoolThings { void DoCool(); } public abstract class AbstractWidget : IDoesCoolThings { void IDoesCoolThings.DoCo...

Getting my head around an inheritance problem

I wish to extend a base class in C# with some additional functionality. I have existing code which returns an array of the base class objects (Account) which I need to convert into the extended version. So I have the extended version: class AccountXtra : Account { public int Period { get; set; } public int Visitors { get; set;...

Is there a way to override class variables in Java?

Hi, class Dad { protected static String me = "dad"; public void printMe() { System.out.println(me); } } class Son extends Dad { protected static String me = "son"; } public void doIt() { new Son().printMe(); } The function doIt will print "dad". Is there a way to make it print "son"? Thanks! Dikla ...

Casting Entity Framework Entities in the "Wrong" Direction

I am using the Entity Framework and have an inheritance structure with a base Entity (let's call it Customer) and a derived Entity, let's call it AccountCustomer. The difference is that an AccountCustomer has extra details (such as payment terms etc.) stored in a separate table in the database and therefore extra properties in the Entity...

Best practices for defining your own exception classes?

I have some special exception cases that I want to throw and catch, so I want to define my own exception classes. What are the best practices for that? Should I inherit from std::exception or std::runtime_error? ...

How To Subclass A Form in Delphi? Best Practices?

I've got a base form in Delphi 2007 that I'd like to reuse in another project, adding some other buttons and such. I'm familiar with subclassing a non-GUI object, but it is possible to subclass a Form in the same fashion? Can you make changes to the subclass Form in design mode? How do you go about doing this and what are some things ...

Linq2SQL inherited types and OfType query

Hi I have a setup where I used Linq2SQL inheritance. To make queries easier, I expose the derived types in the DataContext as well, like the following: public IQueryable<Derived> Derivations { get { return Bases.OfType<Derived>(); } // filter list on type } Calling this works perfectly, and I can see the SQL being correctly genera...

How to allocate array in base constructor with size based on derived class?

I have a hierarchy of classes. The base class uses some tuning parameters that are loadable from file (and reloadable during runtime). Each derived class may add some additional parameters. I am looking for a way to allocate a correctly sized parameters array in the base constructor, so that I don't have to deallocate and reallocate ...

[Java] Ensuring method is called

I have this class: public abstract class AbstractIncomingCall { /* class properties */ public void changeStatus(/*some parameters*/){ //store parameters in class properties isValid(); } protected abstract boolean isValid(); } ...which is extended by this class: public class IncomingCallImpl ...

Issue with component creation: field ends up nil

This is a continuation of the project I was working on here: http://stackoverflow.com/questions/692173/circular-reference-issue-with-classes-which-use-each-other The advice received there fixed the ciruclar reference problem (again, thanks for the help). Now I'm wrestling w/something else: TcmDataPanel.FObservingDataPanels always ends...

How method hiding works in C#?

Why the following program prints B B (as it should) public class A { public void Print() { Console.WriteLine("A"); } } public class B : A { public new void Print() { Console.WriteLine("B"); } public void Print2() { Pr...