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

2
votes
1answer
56 views

Can this architecture of base + derived classes be coded more efficient? [on hold]

I've got some architecture in my code similar to this. It is about the Construct method in the base class in the example below. This method contains the logic for constructing a building, which is the ...
1
vote
1answer
28 views

Simple inheritance with functions in subclasses [on hold]

It seems like there are many ways implementing inheritance in JavaScript. Which version do you prefer or would you suggest another solution? The code should run in IE8+ so my first version would not ...
2
votes
0answers
39 views

Forcing base class functions to be used from the base class [closed]

The answer to this question is probably "W-what!? What the !@#$-- Stop!! That's a terrible idea!", but I would like to hear your thoughts... I have two classes and one inherits from the other. ...
2
votes
3answers
55 views

Raising error if method not overridden by sub-class

Background I have a base (only 2 classes inherit from it, and only from it) abstract (meaning I don't want it to be used directly) class that implements some common functionality. Some of it depends ...
9
votes
1answer
67 views

DataLayer Interfaces Genericized

I have some concerns on my refactoring for the data layer in my current Project. Just for a small info, I am currently building a CRM as "training JEE application". But enough of talk, let's talk ...
6
votes
2answers
158 views

Class for printing class hierarchy as text

I'm coding a little class hierarchy printing tool for easy show hierarchies of java classes. This is my current code: ...
5
votes
1answer
48 views

Prototype inheritance with Knockout observables

I'm trying to write a JavaScript library to allow inheritance with knockout. The fundamental problem when implementing inheritance in Knockout is that each Knockout observable is its own instance, ...
2
votes
3answers
81 views

Color vision checkup

I have this old project I wrote years ago and it's all classes and methods all over the place. I am trying to learn/understand how I can apply a more OOP principle. It is very large and can't paste ...
3
votes
2answers
82 views

Using properties efficiently in inheritance

I have a class called Mailer which has some properties like this ...
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
677 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
514 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
71 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
27 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
71 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
28 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
78 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
193 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: ...
7
votes
1answer
118 views

Moving method from derived class to base

I've some classes (Derived1, Derived2, etc.) derived from class Base. All of derived classes ...
5
votes
3answers
104 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 ...
8
votes
3answers
308 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: ...
0
votes
1answer
71 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 ...
3
votes
1answer
56 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 ...
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: ...
1
vote
1answer
83 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: ...
1
vote
0answers
118 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
139 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
759 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 ...
3
votes
1answer
230 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 ...
0
votes
0answers
152 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
86 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 ...
1
vote
2answers
222 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
161 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 ...
5
votes
0answers
70 views

Out of order class resequencer

I got bored recently and wrote a tool to re-order out of order classes in Python files. This can occur with some auto-generation code tools for databases and the like; these files can sometimes be ...
4
votes
1answer
459 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 ...
1
vote
1answer
203 views

Javascript Nested Classes

Are there any potential issues with the following Javascript code: ...
3
votes
2answers
297 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
1k 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#: ...
2
votes
3answers
152 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
236 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. ...
1
vote
2answers
178 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
80 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 ...
2
votes
2answers
842 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
103 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 ...
0
votes
1answer
81 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
88 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
249 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
229 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
103 views