Questions tagged [abstract]

abstract is a keyword shared by a multitude of object-oriented programming languages. Methods and classes can be marked abstract to indicate that they do not contain the full implementation of application logic and have to be extended. Abstract classes can not be instantiated and serve the purpose of providing a uniform interface for their subclasses, as well as the implementation of common methods that don't have to be reimplemented for each subclass.

abstract is a keyword shared by a multitude of object-oriented programming languages.

Methods and classes can be marked abstract to indicate that they do not contain the full implementation of application logic. Abstract classes can not be instantiated and serve the purpose of providing a uniform interface for their subclasses, as well as the implementation of common methods that don't have to be reimplemented for each subclass.

The exact meaning of abstract depends on the programming languages in question, some of them being: Java, C#, php, C++, Delphi Pascal. Similar logic can also be implemented using different keywords in other languages ( for example, Oracle PL/SQL allows to create abstract classes and methods by declaring them NOT FINAL)

The power of abstract methods and classes is widely used by design patterns.

2521 questions
0
votes
2 answers

Java generics Factory Pattern with multiple Generics

I'm trying to learn how to use generics, but I am having a hard time with implementing a factory pattern. I want my DataFactory interface to have a method that returns an object of a class that extends Data. I believe the following code will work,…
csoler
  • 393
  • 2
  • 9
0
votes
1 answer

Python factory pattern - object is not subscriptable

I am working on some python code - trying to implement composition and factory pattern: from abc import ABC, abstractmethod import configparser import os from pathlib import Path import sys class LoggerAbstract(ABC): def __init__(self,…
Ubaidul Khan
  • 131
  • 3
  • 13
0
votes
0 answers

Create virtual function with unknown number of parameters

I am looking to have a virtual class used to ensure that all inheriting classes have the following functions Initialize() IsInitialized() Clear() Maybe there is another approach but the use of the abstract class seems to be the best options as far…
JCoder
  • 75
  • 5
0
votes
0 answers

Is there a way to inherit static function invoking constructor of child class with parameters?

I have got a lot of classes inheriting from an abstract class. I would like to have a static method returning new object for each one of them and was wondering if I can't shorten the code like this: class Foo : Bar { // I don't want to write…
Dave
  • 1
  • 3
0
votes
1 answer

C# add item in abstract list

For a project i am working with intherentance and an abstract class. with the help of a form i want to add items into a list, but get the following error during coding: cannot create an instance abstract type or interface 'Article'. does someone…
Jessy
  • 47
  • 7
0
votes
1 answer

Typescript using Pick for getbyid in generic repository class

So I have the following example, which works: const example = () => { const primaryKey: keyof Seller = `id`; type SellerPrimaryKeyOnly = Pick const sellerPrimaryKey: SellerPrimaryKeyOnly = {id: 2} }; and tried…
0
votes
1 answer

How to get a unique serial_number for a abstract base class in Django?

I have a abstract base model and two child models: class Component(models.Model): serial = models.PositiveIntegerField(unique=True) last_modified = models.DateTimeField(auto_now_add=True) class Meta: abstract = True class…
Bouni
  • 133
  • 10
0
votes
1 answer

How do I rearrange an array to be ordered with compatible neighbours?

I have a rather abstract problem that I thought of but couldn’t figure out an efficient solution to it. Problem Suppose we have a list of rules represented by an array of objects that all have an attribute that specifies an Array[3] of objects that…
Meknassih
  • 21
  • 4
0
votes
2 answers

how can solve out circular import error in django

I have created MeterModel and MeterAbstract in app MeterApp. MeterAbstract have Meter_number and MeterModel have related field of Meter. I used MeterAbstract in BillModel. from MeterApp import MeterModel class BillDetailModel(BillAbstract,…
0
votes
0 answers

TypeScript: Define an Argument Representing a Type Which Implements an Abstract Class

I have something akin to the following in TypeScript: abstract class foo { public static bar: string; } class baz implements foo { public static bar: string = 'qux'; } And would like to be able to do something like: function quxx(t:…
CoryG
  • 2,429
  • 3
  • 25
  • 60
0
votes
1 answer

XML type definition can not be abstract, no non-abstract type in xsd

I got an external xsd I want to create an valid xml to. The xsd contains a complex type definition:
Mr Beater
  • 3
  • 3
0
votes
1 answer

Typescript extend a class method to an array of methods

The basic idea is that I have an abstract class with a method that can be turned into an array of methods when extended by a subclass. The following is a working example but with workarounds: type ClassMethod = (food: string) => void type…
Susccy
  • 214
  • 2
  • 13
0
votes
2 answers

Square is not abstract and does not override abstract method area() in Shape class Square extends Shape{

I am trying to figure out abstraction for a project on Sololearn and I reached module 5. I am asked to create two classes ( Square and Circle) both with contructors taking parameters and to set up an abstract method inherited from an abstract class…
0
votes
2 answers

Making method call on abstract generic class variable in Java

Honestly i have a hard time with this problem. Let's say we have a base class: public abstract class Work { } And two realizations: public class SimpleWork extends Work { } public class HardWork extends Work { } Now i want abstract work…
Aleks
  • 17
  • 3
0
votes
0 answers

What is JSString and JSInt classes in dart?

When i search through the classes like num, String, int. I have noticed that they are all abstract classes. What suprised me that the implementation classes for String is JSString and for int JSint. And this made me think that does the code behind…
Solen Dogan
  • 139
  • 8