GithubHelp home page GithubHelp logo

Inheritance about jugglingdb HOT 5 CLOSED

1602 avatar 1602 commented on July 18, 2024
Inheritance

from jugglingdb.

Comments (5)

1602 avatar 1602 commented on July 18, 2024

What are your expectations due to inheritance? How it should be affected in persistence? In relational database we can create new table for inherited class with relation 'belongs to' or 'has one'. This table will only contain attributes for child class.

To be honest, I don't like this idea. Inheritance for persistent classes increases difficulty badly, IMHO.

Let's discuss.

from jugglingdb.

juggy avatar juggy commented on July 18, 2024

My use case is what I described with Transaction.

  • Transaction
    • FreeTransaction
    • PaypalTransaction

Exact same fields, but the behaviors change.

Maybe it can be done as a mixin or something, but the obvious way is to inherit.

from jugglingdb.

bentruyman avatar bentruyman commented on July 18, 2024

I have a similar requirement. I have several schemas that look similar to the following:

Channel = {
  name: String,
  description: String,
  type: String,
  url: String,
  timeout: Number
}

ConfiguredChannel = {
  channel: Channel,
  timeout: Number
}

ChannelSet = {
  name: String,
  description: String,
  configuredChannels: [ConfiguredChannel]
}

ConfiguredChannelSet = {
  channelSet: ChannelSet,
  startTime: Number
}

Display = {
  name: String,
  configuredChannelSets: [ConfiguredChannelSet]
}

I'd like ConfiguredChannels to inherit their parent's attributes, like timeout. If no timeout is specified on the ConfiguredChannel, I'd use something like a pre-save hook to inherit that property from the parent. ChannelSets are comprised of ConfiguredChannels and a few other properties. Different Displays can reuse several predefined ConfiguredChannelSets but specify their startTime.

Maybe I'm modeling my data incorrectly — but this schema seems to "feel" right.

from jugglingdb.

1602 avatar 1602 commented on July 18, 2024

I think this feature is not for schema definition internals, you can do some inheritance outside, like $.extend in jquery: define some "abstract" attributes set and reuse it for different model definitions.

from jugglingdb.

wbw20 avatar wbw20 commented on July 18, 2024

This issue should be implemented. Yeah its really hairy, but other popular ORMs have it (hibernate, active record). For instance, people might want their hierarchy to share an ID namespace. This is more than just using $.extend to save code. That being said, I realize its a huge complexity overhead

from jugglingdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.