One of the four pillars of object-oriented programming (OOP), inheritance establishes a "is-a" relationship between objects. For example, a "Cat" object can be treated in code as any other "Animal" object because a "Cat" is-a "Animal".

learn more… | top users | synonyms

4
votes
1answer
46 views

dnaof() - inheritance made easy, my own make inheritance tool

https://github.com/exebook/dnaof I created this simple inheritance tool for JavaScript, could any one with deep knowledge in JavaScript prototyped inheritance review it? Here is the library itself: ...
14
votes
4answers
653 views

Modelling a Call Center

This is the requirement I have (from the book: Cracking the Coding Interview) Imagine you have a call center with three levels of employees: fresher, technical lead (TL), and product manager (PM). ...
7
votes
6answers
488 views

Fluent interface and polymorphism

EDIT: For further improvements see the related question: Variadic templates and pointers to member functions to achieve a named-parameters interface in C++ I would like to improve the interfaces of ...
4
votes
1answer
54 views

Improving XNA's default project template

I hope this isn't getting annoying, but I've asked a lot of questions about improving my game lately: How can I improve my game project design? Using the observer pattern with collision detection Is ...
1
vote
0answers
25 views

Inheritance and setting up for an API request

I am setting up a class to be used for an API request (with JavaScriptSerializer) I am using it to send a complaint to their ticketing systems. So for example I send Title, Description, Custom_Fields ...
5
votes
2answers
70 views

Avoiding casts in abstract types

I asked this question on Stack Overflow and in the comments someone had this to say. In a proper design, you should almost never have to do a dynamic_cast, even if it's hidden inside some nice ...
1
vote
1answer
23 views

Javascript subclasses instantiating superclass (check code)

I have a test which looks like this: create a base class Human Human class needs to have a method Talk the Human class needs to have to descendant class Man and Woman both Man and Woman should have ...
1
vote
2answers
72 views

Classical inheritance in JavaScript

I've been playing around with inheritance in JavaScript and I'm wondering if there are any drawbacks to this method which tries to emulate classical inheritance from C-based languages. ...
3
votes
1answer
130 views

Case class design in Scala

In the Java world while writing the data access layer (for CRUD) and the model layer, I have done something like this: public abstract class AbstractDao<N extends AbstractModel>{ ...
7
votes
1answer
109 views

Moving method from derived class to base

I've some classes (Derived1, Derived2, etc.) derived from class Base. All of derived classes have a following methods (reduced sample): void Derived1::handleTimer(const StatusType &st) { if ...
5
votes
3answers
100 views

Object inheritance

I have written some example code to test object inheritance, but I'm not sure if it's really the best way for an object to inherit another's functions (like Java's extends). function Class() { ...
8
votes
3answers
300 views

Why would I want to always have to explicitly call a “base” method if I just want to use base functionality?

I recently worked with an architect who structured his base class like this: public abstract class Base<T> { public abstract T Get(int id); internal T InternalGet(int id, ...
0
votes
1answer
67 views

Coding convention when using differential inheritance

Ever since reading Crockford's "Good Parts" and Johansen's TDD book, I have wanted to use more of the differential inheritance pattern in my coding at work (as in avoiding new by using ...
3
votes
1answer
47 views

Get Ancestor Class Name that Defines CONST in PHP?

I have a class hierarchy in PHP and in some of the parent classes I have defined a constant, let's assume that constant is called TYPE for my example. I want to be able to pass in a valid value for ...
1
vote
1answer
53 views

Initialization of Extended class without too much overhead?

I am getting object of a class AAA from somewhere and I want to add more information in that object. So, I am creating a new class BBB which is derived from AAA. The class BBB has additional field ...
1
vote
1answer
39 views

Parent implementation different to child implementation

I have the following interface: struct IFilter { virtual enterClass(ClassData&, int recursiveLevel) = 0; virtual enterStructure(ClassData&, int recursiveLevel) = 0; virtual ...
1
vote
1answer
74 views

How to deal with interface inheritance and common properties? [closed]

I'm trying to design a generic caching system that takes keyed items and allows either read-only or read-write access to a cached version of it. The read-only backing interface is: public interface ...
1
vote
0answers
117 views

Do I need inheritance or no?

I'm using Pygame to create a small game with few rectangle shapes. However, I want to learn more about classes, and I'm trying to use them. I'm very new to classes and inheritance, but I want to ...
1
vote
2answers
133 views

Inheritance and forcing methods to be called inside another method

I've written a text parser that extracts useful information from a given text. Texts are formatted different, so there are different specialized parsers. I've designed them so that they all must ...
3
votes
2answers
674 views

Please check my improvement on John Resig's Simple JavaScript Inheritance

I've recently read this article, and I agree that the new keyword is not good practice. Thus, I've made an improvement on John Resig's Simple JavaScript Inheritance in order to use the Class.create ...
3
votes
1answer
216 views

A parent class, a singleton subclass, and a subclass uses a builder [closed]

There are three classes and an interface. The parent class is called MobileSignal. It contains info about mobile signal. E.g., CID, LAC, device ID, MCC, user location, signal strength, etc. ...
0
votes
0answers
143 views

Understanding OO JavaScript with a simple scenario

Coming from a Java kind of OOP, I miss a lot of things in JavaScript. I am working on a Node.Js project, and I would like to use an OO approach. Looking around and asking in StackOverflow I came up ...
1
vote
1answer
82 views

Please check if these two methods for inheritance and initialization are good or bad

I am new to JavaScript. I know that many inheritance and initialization methods have been written and use some advance features like Object.create: Simple JavaScript Inheritance Why Prototypal ...
1
vote
2answers
200 views

“fake” covariance in PHP type-hinting

Here's the situation: I've got several distinct objects, each with their own responsability and (therefore) each their own dependencies. As this is code that will be implemented in 2 existing ...
3
votes
2answers
160 views

Trying to use classes in my python code. Not sure if being done correctly

The point of my code is to: Read in the observed data from the a catalog of stars (whitespace separated table). Do some unit conversions on the observed data (math stuff). Apply an interstellar ...
4
votes
1answer
409 views

Cross-browser DOMTokenList object and wrapper function. Failures and improvements?

I have been looking for a Cross-browser solution for DOMTokenList and element.classList. I wasn't able to find much for DOMTokenList and the polyfills that I found for element.classList were mostly ...
1
vote
1answer
186 views

Javascript Nested Classes

Are there any potential issues with the following Javascript code: var BobsGarage = BobsGarage || {}; // namespace /** * BobsGarage.Car * @constructor * @returns {BobsGarage.Car} */ ...
3
votes
2answers
286 views

Classes and variables in PHP

First of all, I'm trying to learn OOP PHP, so any advise will be great. My idea is to create some kind of MVC Framework CMS kind of thing, just to learn OOP PHP and MVC well. Let's say that I've got ...
2
votes
2answers
949 views

Good implementation of Equals and GetHashCode for base class

Is this a good implementation for Equals and GetHashCode for a base class in C#: public abstract class Entity<TKey> //TKey = Type of the Key { private string FullClassName; private ...
2
votes
3answers
151 views

Flaws in this Design?

I need to find the flaws in this design. So far the only ones i can think of are: No use of generics the class Concept uses a parametrized constructor, which means every sub class would need to pass ...
5
votes
1answer
214 views

Generic pipe and filters

I made a template pipe and filters to replace an old pipe and filters implementation that used inheritance and had a very heavy base class. #include <iostream> #include <boost/bind.hpp> ...
1
vote
2answers
169 views

My take at OOP module/prototyping JavaScript

The last month I've been reading up on how to take my JavaScript code to the next level. I am a Java programmer at heart, so it feels nice when everything is encapsulated in classes/objects, and these ...
5
votes
2answers
79 views

Least amount of HTML and CSS to create a bottom border for every section?

I am doing a redesign and have some previously existing content in HTML that is similar to <p class="testimonial-text">Bacon ipsum dolor sit amet aliquip est tail occaecat bacon ad qui short ...
2
votes
2answers
713 views

My self-study inheritance and sub-class exercise.

I'm self-studying Java and have a question about one of the end-of-chapter exercises. The chapter focus is on inheritance and the book hasn't officially introduced polymorphism so I'm trying to stay ...
-1
votes
1answer
101 views

Should I use inheritance in my case? [closed]

UPDATE - I write in C#. The code is added below. I have 2 classes that should run a service when calling their Start method, but before it they should: Copy items to F folder Open S service in ...
0
votes
1answer
79 views

Ruby on Rails Single Table Inheritance [closed]

I'm trying to set up single table inheritance in Rails. I have single table called Finances, with a type set to Income or Expense. My code is here: https://gist.github.com/caser85/5096447 Ok, I got ...
1
vote
1answer
86 views

Inheritance selfmade or reinventing wheel

Background I like to code JavaScript in a typical style with "classes" and inheritance. My goal was to create an easy way to make inheritance available and keep classes that inherits from others ...
1
vote
2answers
233 views

PHP Class Inheritance / Object Instantiation / Object / Property Scope w/ Child / Parent Classes & Dependency Container Class

In PHP, I have a parent/child class and am using dependency container to load them. I am trying to use the same database connection on all of them without duplicating the object. CLARIFICATION: MY ...
2
votes
1answer
226 views

Instantiation/Inheritance Helper — Optimization / Pitfalls

For the sake of learning javascript better and getting used to the Google Chrome Extension Api, I'm currently writing a little Chrome Extension. To keep things simple and being able to make use of ...
3
votes
2answers
101 views

How would you improve this object model design to get around Covariance Issues with ObjectModel.Collection<T>?

Consider the following simple relationship. Code [DataContract(Name = "Wheel")] public class Wheel { } [DataContract(Name = "OffRoadWheel")] public class OffRoadWheel : Wheel { } ...
2
votes
0answers
202 views

Driver-layer from top-level app to hardware

I'm attempting to implement driver-layer from top-level app to hardware. Driver is shared library. Framework: Qt. In the first, I extracted interface functions, which further will be called from ...
3
votes
3answers
309 views

Creating students and instructors

It's simple. Person is a superclass. Student and Instructor are its subclasses. The program suppose to allow user create a student or an instructor. Run package com.exercise.inheritance1; import ...
10
votes
11answers
817 views

Design dilemma: extensibility vs simplicity

Here is my problem abstracted to Bird classes. I know that number of Birds will increase on the future and new behaviors might be needed. With 10 Birds first design might not look so simple and lead ...