[go: up one dir, main page]

WO2024088781A1 - Method for testing a computer program programmed in an object-oriented scripting language, and system, computer program and computer-readable storage medium - Google Patents

Method for testing a computer program programmed in an object-oriented scripting language, and system, computer program and computer-readable storage medium Download PDF

Info

Publication number
WO2024088781A1
WO2024088781A1 PCT/EP2023/078431 EP2023078431W WO2024088781A1 WO 2024088781 A1 WO2024088781 A1 WO 2024088781A1 EP 2023078431 W EP2023078431 W EP 2023078431W WO 2024088781 A1 WO2024088781 A1 WO 2024088781A1
Authority
WO
WIPO (PCT)
Prior art keywords
abstract
class
computer program
inheriting
members
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/EP2023/078431
Other languages
German (de)
French (fr)
Inventor
André Netzeband
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Volkswagen AG
Original Assignee
Volkswagen AG
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Volkswagen AG filed Critical Volkswagen AG
Priority to EP23790262.2A priority Critical patent/EP4609292A1/en
Publication of WO2024088781A1 publication Critical patent/WO2024088781A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3604Analysis of software for verifying properties of programs
    • G06F11/3612Analysis of software for verifying properties of programs by runtime analysis
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented

Definitions

  • One aspect of the invention relates to a method for testing a computer program programmed in an object-oriented scripting language.
  • Interfaces are abstract classes that only have abstract methods and abstract attributes.
  • These programming languages have a compiler that compiles a written program code before the program code is executed. The program code is checked for errors and translated into machine code. The compiler checks at compile time whether all interfaces and assignments within a program are consistent. This means that programs based on compiled program code run fail-safe because errors are detected before execution.
  • scripting languages that are not compiled, errors only occur at runtime. However, scripting languages offer other advantages over programming languages that are compiled.
  • the invention is based on the object of enabling advantages of compiled programming languages for scripting languages.
  • One aspect of the invention relates to a method for testing a computer program programmed in an object-oriented scripting language, preferably comprising the following steps: Providing a computer program part for generating abstract classes; providing at least one abstract class which has at least one abstract member, in particular only abstract members, by means of the computer program part;
  • the proposed method can be a computer-implemented method.
  • the method is carried out on an electronic computing unit.
  • the tested computer program can be executed on this computing unit or, after transfer, on another computing unit.
  • a vehicle can be controlled, in particular autonomously, in particular semi-autonomously.
  • it is a method for operating an electronic computing unit.
  • the method also improves the operation of a computing unit.
  • the computing unit can therefore also operate with fewer errors and, in particular, faster and more efficiently.
  • the execution of a computer program on a computing unit is improved.
  • a method for carrying out the execution of a computer program on a computing unit is therefore also provided.
  • scripting languages that do not have built-in type checking and/or interface definition.
  • the computer program part particularly newly and additionally provided, for generating abstract classes is not necessarily part of the computer program. However, it can be added to the computer program.
  • the computer program part can also be integrated into the computer program as a library. If the selected programming language is Python, for example, The Abstract Base Class (abc) library is integrated for this purpose.
  • Python for example, The Abstract Base Class (abc) library is integrated for this purpose.
  • At least the computer program part now makes it possible to carry out the steps mentioned and thus improve a conventional computer program programmed in an object-oriented scripting language with regard to error generation and error detection. It is therefore now possible to use such computer programs with their advantages compared to compiler-based computer programs and still offer the better analysis capability with regard to error detection that is available with compiler-based computer programs.
  • abstract classes are classes that have at least one abstract method or at least one abstract attribute. Methods and attributes of a class can be referred to as members of the class. Interfaces are a special case of abstract classes. They normally only have abstract members, which means that they only have abstract methods and abstract attributes, for example. An interface can be understood as a contract that describes which members a class should have. An abstract member is in particular a member that does not use an implementation, but only a definition, which can be referred to as a signature. For example, a class only becomes an abstract class if it has at least one abstract member. In general, an abstract class can also have non-abstract members. However, an interface usually does not.
  • an abstract class is provided, in particular programmed, in particular added to the computer program.
  • some interfaces in particular only interfaces, are provided.
  • the computer program part is used for this purpose. Examples of a type of a member can be a method, an attribute, a class method (Class Method) or a static method (static Method).
  • This example code can be used to provide an interface as a special case of an abstract class. Specifically, executing this example code creates an interface.
  • Non-abstract classes can inherit from abstract classes, especially from interfaces. All members of the abstract class must be implemented by the inheriting class, so that each abstract member of the abstract class corresponds to a non-abstract member of the inheriting class with the same properties.
  • a class can implement an interface by inheriting from it and overwriting the corresponding members with a real implementation. A realization is in particular the concrete implementation of an interface. In particular, all previously abstract members must actually be implemented.
  • a class can represent a realization of several interfaces.
  • An object can be derived from the inheriting class and created. This can be referred to as instantiation of the inheriting class. This gives the object a reference to the abstract class, in particular to the interface, from which the inheriting class inherits. In particular, a reference is a kind of address under which an object can be addressed. In some programming languages, it is possible for references to be represented directly by memory addresses. In Python, for example, this is not the case. If a class is instantiated, the object in particular is created in the memory of the processing unit, in particular a computer. In particular, this object is then passed on to functions or other classes in the form of a reference so that they can access it. The memory address may not be sufficient for access, but additional information is required as to which object it is.
  • the object represents the reference to the abstract class, in particular to the interface. Because the reference of the object refers to the abstract class, in particular the interface, it can be addressed from outside via the methods and attributes of the interface. It is therefore particularly important that members of the interface are correctly and completely inherited, in particular implemented, by the members of the inheriting class with regard to their properties. This makes it possible to achieve a loose coupling between software components.
  • a software component that uses an object of an inheriting class is only given the bare minimum to use the object. Such a software component can be called a client and the object a service.
  • a client which can be another class or a function, can depend on the interface instead of a specific class. This makes it possible to later replace the implementation with another class that implements the same interface. This creates a loose coupling between classes.
  • the software code can thus be built in a more modular way and is therefore easier to maintain. It also makes the software code easier to reuse, especially in different contexts.
  • the comparison of the properties of the abstract members with the properties of the non-abstract members is triggered by the instantiation.
  • the comparison is carried out for all abstract members with all non-abstract members.
  • the comparison is triggered by the instantiation if another computer program part, in particular an integrated library, enables this.
  • the comparison is not triggered without the other computer program part.
  • the procedure checks whether an instance is even able to realize an interface.
  • the method is particularly advantageous because it enables or facilitates the use of common software engineering concepts such as "dependency injection” and numerous object-oriented patterns (oop patterns).
  • dependency injection and numerous object-oriented patterns (oop patterns).
  • oop patterns object-oriented patterns
  • the concept of using interfaces is fundamentally unknown. Therefore, it is not yet possible to check in Python whether an implementation is consistent and/or whether a passed reference is compatible with the interface.
  • an entry is created in an error list.
  • An error is recognized, for example, if not all abstract members of the abstract class, in particular of the interface, can be assigned to a non-abstract member of the inheriting class. Then, in particular, the error list is output as an error message. Outputting the error list can mean that the error list is displayed to a user, acoustically or visually, in particular on a screen. Alternatively or additionally, the error list can be output or made available to an external system. In particular, the error list contains information about which properties of which members do not match.
  • the method comprises the following further steps: checking all objects referenced by a software component of the computer program to determine whether the respective referenced object represents a reference to the associated abstract class; and if at least one checked object referential to a software component does not represent the reference to the associated class, a further error message is output.
  • the associated abstract class is an expected abstract class, in particular one specified in the program code.
  • the passed references of the object passed object references
  • an error message may be issued, in particular issued to a user and/or made available to an external system.
  • the check can also be called runtime type checking, since this check takes place especially at runtime and the type of the abstract class, which has a reference to the object is checked.
  • the type of the abstract class specifically indicates the name of the abstract class.
  • the check ensures that only objects from the expected class that implement an abstract class, in particular an interface, can be passed as an argument to a function or method.
  • this checks whether a reference can be formally assigned to an expected interface.
  • the consistency of the computer program can be ensured. This makes it more fail-safe and less prone to errors.
  • the following properties of the members are compared: names of the members,
  • the type of a member indicates whether the member is an attribute or a method.
  • the arguments of the member the name and number of arguments of a method are compared in particular.
  • Arguments are in particular transfer parameters.
  • the respective data type of the arguments is also compared.
  • a function decorator is a function that takes another function and extends the behavior of the latter function without explicitly changing it.
  • a function decorator is a function that wraps another function. In particular, from the outside it looks as if the actual function is being called, but the decorator is executed first, which then internally executes the actual function and then returns the return value of this function as well. If for every abstract member of the abstract class, in particular the interface, a non-abstract member of the inheriting class can be identified that matches an abstract member in all properties, then this comparison is successful. This ensures that the inheriting class is a correct implementation of the abstract class, in particular the interface. This makes the computer program more reliable and less prone to errors.
  • an object is created for the, in particular for each, inheriting class of the computer program before executing a main part of the computer program. It is checked whether the respective creation is successful.
  • this can be referred to as a module test or unit test.
  • the creation of the object which can also be referred to as instantiating the inheriting class, triggers the comparison of the properties of the abstract members with the properties of the non-abstract members. If the comparison is unsuccessful, the object cannot be created. In particular, an error message is then issued.
  • the unit tests especially for all inheriting classes, can be created and/or executed automatically.
  • the main part can be a part of the computer program that is, for example, executed continuously as long as the computer program is running.
  • code that is not part of the unit test is executed in the main part of the computer program.
  • the last two lines may not be necessary for the module test. However, they increase the security and reliability of the consistency of the computer program. In particular, these two lines check whether the created instance is an instance of the inheriting class that implements an abstract class, in particular an interface.
  • all software components of the computer program are dependent on abstract classes, in particular only.
  • the dependencies of the software components, in particular those that inherit from abstract classes, are generated and transferred centrally.
  • dependency injection can be referred to as a design pattern that regulates the dependencies of an object at runtime. If, for example, an object requires another object when it is instantiated, this dependency is stored in a central location, i.e. it is not created by the initialized object itself. This central location can be referred to as the composition root. In particular, location refers to a place in the computer program.
  • constructor dependency injection it is possible that the dependencies of other classes are made available via constructors. This can be referred to as constructor dependency injection.
  • composition root of the computer program is called directly after the program starts, especially before the main part of the computer program is executed. This ensures that the dependencies are checked right at the start of the computer program. This means that all objects referenced by a software component of the computer program can be checked at this point to see whether the respective referenced object has a reference to the associated, in particular expected, abstract class.
  • the computer program is programmed and tested in a Python programming language.
  • This programming language offers many advantages. In particular, it is considered the standard in the field of data science and machine learning. In particular, Python 3 is used.
  • a further aspect of the invention relates to a method for executing a computer program.
  • the computer program is tested before a main part of the computer program is executed. If an entry is made in the error list or an error message is output, the execution of the main part is prevented. If no entry is made in the error list or an error message is output, the main part of the computer program is started, in particular automatically.
  • the method for testing according to the invention is carried out at least once when the execution of the main part has already started, in particular when an object derived from an inheriting class is created.
  • the error is identified by the method according to the invention and automatically corrected by the external system.
  • the tested computer program can be used for the, in particular autonomous, in particular semi-autonomous, control of a vehicle.
  • the testing according to the invention increases the reliability of the computer program. The increased reliability can ensure safer operation of the vehicle.
  • a further aspect of the invention relates to a system for carrying out a method, comprising means for carrying out the steps of the method according to one of the preceding claims.
  • the system can comprise an electronic test unit and/or an electronic computing unit.
  • a further aspect of the invention relates to a computer program which is tested according to a method according to the above-mentioned aspect, in particular is loadable into a memory unit and is executable by a processor.
  • a further aspect of the invention relates to a computer-readable storage medium comprising instructions which, when executed by a computer, cause the computer to carry out the steps of the method according to one of claims 1 to 7.
  • the invention also includes combinations of the features of the described embodiments.
  • Fig. 1 is a class diagram of an embodiment of a computer diagram
  • Fig. 1 shows an example class diagram 1 of an embodiment of a computer program.
  • the abstract class 2 "Interface” can have an attribute 3 called “Attribute” and a method 4 called “Operation”. All attributes and methods are abstract in this embodiment. Therefore, this abstract class 2 is an interface 2.
  • the attribute 3 is of the data type String 5.
  • the attribute 3 can in particular be a character string.
  • the method 4 "Operation” expects a transfer parameter 6 "Value" of the data type String 7.
  • a return value of the method 4 "Operation” is of a Boolean data type 8.
  • the inheriting class 9 "inheriting class” implements the interface 2. This means that the inheriting class 9 also has an attribute 10 "attribute” and a method 11 "operation".
  • the inheriting class 9 may have further attributes and methods. It may also inherit from another interface. In particular, the inheriting class 9 has all the attributes and methods of the interface 2. The methods and attributes of the inheriting class are all non-abstract.
  • the return value of the member "Operation" of the interface 2 is a Boolean data type 8 and the return value of the member "Operation” of the inheriting class 9 is also a Boolean data type 15. Since for all abstract members 3, 4 of interface 2 a non-abstract member 10, 11 of the inheriting class 9 can be found that matches with respect to all compared properties, it can be assumed that the inheriting class 9 has correctly inherited from interface 2. To ensure that the members of the correct inheriting class are compared with respect to the members of the correct interface, a connection between interface 2 and the inheriting class 9 can be checked by checking for the object to be created whether it was derived from both the inheriting class 9 and the interface 2.
  • This method is particularly advantageous if it is carried out before a main part is executed, particularly as part of a module test. This can shorten the time until a type I error is detected.
  • a type I error occurs in particular when not all abstract members are implemented in the inheriting class 9 or when the member in the inheriting class 9 does not match the abstract member in terms of its properties.
  • a software component "client” accesses interface 2 when it accesses an object that is an instance of a class inheriting from interface 2. To ensure that the object is an instance of a class 9 inheriting from interface 2, this is checked in one embodiment. For example, a function decorator @typechecked can be used for this purpose.
  • this check is also carried out before the main part is executed.
  • the check is carried out in a module test and/or in a composition root at the beginning of the execution of the computer program when constructors are called.
  • it is referred to as a type II error if a software component, in particular according to a program code, accesses an object via an interface that does not belong to the object, in particular does not reference the object.
  • an error message is output. If necessary, the execution of the main part is prevented.
  • the error message can be output to a user and/or made available to an external system. In particular, the external system can automatically correct the error of the first type and/or the error of the second type. If a type I error is detected during instantiation, an exception is generated. An example of an incorrect implementation is: from happy. typing import Abstractclass, abstractmethod, typechecked
  • # - bar is not a property that CTestlncorrect(ITest): def foo(self, value:int) -> str: def bar(self) -> float:
  • a computer program part in particular the "happy. typing” library, extends the "Abstract Base Class” (ABC implementation) with an implementation that only accepts a realization of interfaces if:
  • the decorators of the abstract member are the same as in the interface.
  • the complete signature of the member is checked, not just the name, as the original ABC implementation does. However, this still means that the check takes place at runtime, when the class is instantiated for the first time. To ensure that the implementation of a class matches an interface, the class must be instantiated. Therefore, it is sufficient to create a simple unit test that simply creates an instance of the class. If the unit test succeeds, the implementation of the class is consistent with the interface.
  • the strict consistency check thus takes place at unit test time, which is much earlier than the runtime of the application and is very similar to "compile time" of normal, especially compiled, programming languages.
  • Every function/method that is assigned a reference to the interface should use a type hint for this interface and it should use the "@typechecked" decorator to perform a runtime check of the reference. If the reference is not an instance of the interface, the check would fail at runtime. This means that only classes that implement the interface can be assigned to the argument of this function/method. However, this check only takes place at runtime, which is too late for a "compile-time-like check”.
  • Dependency injection is a pattern in which software components never directly depend on other software components, but on abstractions, especially interfaces. In addition, the instances of all dependencies are created in a single place in the application. This place is called the "composition root”.
  • the dependencies are passed to the constructors of other classes to build a dependency tree. If an instance does not match the expected type of the interface, the type check at runtime of the constructor will fail. This error occurs in the composition root, which is performed directly when the application starts. The error is visible immediately at startup.
  • the composition root can also be checked in a simple unit test by executing the code without further checks. This testing procedure makes interfaces available in Python, which can be used like in other programming languages to increase the reusability, maintainability and stability of applications.
  • the computer program in particular the one tested, can be used for web applications that contain artificial intelligence algorithms (AI algorithms) and/or are used by specialist departments.
  • AI algorithms artificial intelligence algorithms
  • the computer program tested can be used in a vehicle, for example for web applications in the vehicle.
  • the type of implementation of a realization of an interface corresponds to a common pattern from other programming languages (derivation from the interface) and does not require any special keywords, which can be forgotten if necessary.
  • a complete check of the properties of all abstract attributes takes place so that no accidental incorrect realization of an attribute can occur.
  • the check of the realization for completeness only takes place during instantiation, which means that the class can still be extended at runtime after definition, or it can still be derived from it and completeness is then established in the derivation.
  • function decorators are taken into account as properties, especially if they have been specially prepared, which is extremely important for a runtime type check, especially with the @typechecked decorator.
  • the first check takes place implicitly when the "Realization" class is instantiated. Here, the implementation is checked for completeness using the concept described.
  • the second check takes place after this and checks whether the instantiated class is actually derived from the expected interface. If every implemented class receives such a test, it is ensured that every implementation fully realizes the respective interface. The check no longer actually takes place at runtime (which means that errors are only noticed later), but already at the time of the unit test. In this way, Python achieves the same level of security in interface programming as is otherwise only known from compilable OOP programming languages.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to a method for testing a computer program programmed in an object-oriented scripting language, comprising the following steps: - providing a computer program part for generating abstract classes (2); - providing at least one abstract class (2), which comprises at least one abstract member (3, 4), by means of the computer program part; - providing a class (9) which inherits from the abstract class (2) and which comprises only non-abstract members (10, 11); - generating an object derived from the inheriting class (9), the object therefore constituting a reference to the abstract class (9), - wherein properties of the non-abstract members (10, 11) are compared with the properties of the abstract members (3, 4); and - if there is at least one abstract member (3, 4) of the abstract class (2) for which no non-abstract member (10, 11) of the inheriting class (9) having the same properties is found, an entry is generated in an error list and said error list is then output as an error message.

Description

Beschreibung Description

Verfahren zum Testen eines in einer objektorientierten Skriptsprache programmierten Computerprogramms sowie System, Computerprogramm und computerlesbares Speichermedium Method for testing a computer program programmed in an object-oriented scripting language, as well as system, computer program and computer-readable storage medium

Ein Aspekt der Erfindung betrifft ein Verfahren zum Testen eines in einer objektorientierten Skriptsprache programmierten Computerprogramms. One aspect of the invention relates to a method for testing a computer program programmed in an object-oriented scripting language.

Es sind objektorientierte Programmiersprachen bekannt, welche mit dem Konzept eines Interfaces und der Injektion von Abhängigkeiten (Dependency Injection) arbeiten. Interfaces sind abstrakte Klassen, welche ausschließlich abstrakte Methoden und abstrakte Attribute aufweisen. Diese Programmiersprachen weisen einen Kompilierer (Compiler) auf, welcher einen geschriebenen Programmcode vor Ausführung des Programmcodes kompiliert. Dabei wird der Programmcode auf Fehler hin überprüft und in Maschinencode übersetzt. Der Kompilierer überprüft zu einer Kompilierzeit, ob alle Interfaces und Zuweisungen innerhalb eines Programms konsistent sind. Dadurch laufen Programme, die auf kompilierten Programmcode basieren, ausfallsicher, da Fehler bereits vor der Ausführung erkannt werden. There are object-oriented programming languages that work with the concept of an interface and the injection of dependencies (dependency injection). Interfaces are abstract classes that only have abstract methods and abstract attributes. These programming languages have a compiler that compiles a written program code before the program code is executed. The program code is checked for errors and translated into machine code. The compiler checks at compile time whether all interfaces and assignments within a program are consistent. This means that programs based on compiled program code run fail-safe because errors are detected before execution.

Bei Skriptsprachen, welche nicht kompiliert werden, treten Fehler erst zur Laufzeit auf. Skriptsprachen bieten aber andere Vorteile gegenüber Programmiersprachen, die kompiliert werden. With scripting languages that are not compiled, errors only occur at runtime. However, scripting languages offer other advantages over programming languages that are compiled.

Daher liegt der Erfindung die Aufgabe zugrunde Vorteile von kompilierten Programmiersprachen für Skriptsprachen zu ermöglichen. Therefore, the invention is based on the object of enabling advantages of compiled programming languages for scripting languages.

Die Aufgabe wird durch die Gegenstände der unabhängigen Patentansprüche gelöst. Vorteilhafte Weiterbildungen der Erfindung sind durch die abhängigen Patentansprüche, die folgenden Beschreibung sowie der Figur beschrieben. The object is achieved by the subject matter of the independent patent claims. Advantageous developments of the invention are described by the dependent patent claims, the following description and the figure.

Ein Aspekt der Erfindung betrifft ein Verfahren zum Testen eines in einer objektorientierten Skriptsprache programmierten Computerprogramms, vorzugsweise aufweisend folgende Schritte: Bereitstellen eines Computerprogrammteils zur Erzeugung abstrakter Klassen; Bereitstellen wenigstens einer abstrakten Klasse, welche mindestens ein abstraktes Mitglied, insbesondere nur abstrakte Mitglieder, aufweist, mittels des Computerprogrammteils; One aspect of the invention relates to a method for testing a computer program programmed in an object-oriented scripting language, preferably comprising the following steps: Providing a computer program part for generating abstract classes; providing at least one abstract class which has at least one abstract member, in particular only abstract members, by means of the computer program part;

Bereitstellen einer von der abstrakten Klasse erbenden Klasse, die nur nicht abstrakte Mitglieder aufweist; Providing a class that inherits from the abstract class and has only non-abstract members;

Erzeugen eines von der erbenden Klasse abgeleiteten Objektes, wodurch dieses eine Referenz auf die abstrakte Klasse darstellt, wobei Eigenschaften der nicht abstrakten Mitglieder der erbenden Klasse mit den Eigenschaften der abstrakten Mitglieder der abstrakten Klasse verglichen werden; und falls es mindestens ein abstraktes Mitglied der abstrakten Klasse gibt für welches kein nicht abstraktes Mitglied der erbenden Klasse mit den gleichen Eigenschaften gefunden wird, wird ein Eintrag in einer Fehlerliste erzeugt und diese dann als Fehlermeldung ausgegeben. Creating an object derived from the inheriting class, whereby it represents a reference to the abstract class, comparing properties of the non-abstract members of the inheriting class with the properties of the abstract members of the abstract class; and if there is at least one abstract member of the abstract class for which no non-abstract member of the inheriting class with the same properties is found, an entry is created in an error list and this is then output as an error message.

Insbesondere kann es sich bei dem vorgeschlagenen Verfahren um ein computerimplementiertes Verfahren handeln. Insbesondere wird das Verfahren auf einer elektronischen Recheneinheit ausgeführt. Das getestete Computerprogramm kann auf dieser Recheneinheit oder nach Übertragung auf einer weiteren Recheneinheit ausgeführt werden. Durch das Ausführen des Computerprogramms kann ein Fahrzeug, insbesondere autonom, insbesondere teilautonom, gesteuert werden. Gegebenenfalls handelt es sich um ein Verfahren zum Betreiben einer elektronischen Recheneinheit. Insbesondere wird durch das Verfahren auch der Betrieb einer Recheneinheit verbessert. Insbesondere da somit auch die Recheneinheit fehlerminimierter, insbesondere somit auch schneller und effizienter, arbeiten kann. Insbesondere wird der Ablauf eines Computerprogramms auf einer Recheneinheit verbessert. Es ist also auch ein Verfahren zum Durchführen eines Ablaufs eines Computerprogramms auf einer Recheneinheit bereitgestellt. In particular, the proposed method can be a computer-implemented method. In particular, the method is carried out on an electronic computing unit. The tested computer program can be executed on this computing unit or, after transfer, on another computing unit. By executing the computer program, a vehicle can be controlled, in particular autonomously, in particular semi-autonomously. If appropriate, it is a method for operating an electronic computing unit. In particular, the method also improves the operation of a computing unit. In particular because the computing unit can therefore also operate with fewer errors and, in particular, faster and more efficiently. In particular, the execution of a computer program on a computing unit is improved. A method for carrying out the execution of a computer program on a computing unit is therefore also provided.

Insbesondere handelt es sich um Skriptsprachen, welche keine eingebaute Typüberprüfung und/oder Schnittstellendefinition besitzen. In particular, these are scripting languages that do not have built-in type checking and/or interface definition.

Der insbesondere neu und zusätzlich bereitgestellte Computerprogrammteil zur Erzeugung abstrakter Klassen ist nicht zwingend Teil des Computerprogramms. Er kann aber insbesondere dem Computerprogramm hinzugefügt werden. Der Computerprogrammteil kann insbesondere auch als Bibliothek in das Computerprogramm eingebunden werden. Handelt es sich bei der gewählten Programmiersprache beispielsweise um Python, kann dafür die Abstract Base Class (abc) Bibliothek eingebunden werden. Zumindest das Computerprogrammteil ermöglicht es nun, die genannten Schritte durchzuführen und somit ein herkömmliches, in einer objektorientierten Skriptsprache programmierten Computerprogramm im Hinblick auf Fehlergenerierung und Fehlererkennung zu verbessern. Somit ist es nun möglich, solche Computerprogramme mit ihren Vorteilen im Vergleich zu compilerbasierten Computerprogrammen zu nutzen und dennoch die bessere Analysefähigkeit im Hinblick auf Fehlererkennung, wie sie bei compilerbasierten Computerprogrammen vorhanden ist, anzubieten. The computer program part, particularly newly and additionally provided, for generating abstract classes is not necessarily part of the computer program. However, it can be added to the computer program. The computer program part can also be integrated into the computer program as a library. If the selected programming language is Python, for example, The Abstract Base Class (abc) library is integrated for this purpose. At least the computer program part now makes it possible to carry out the steps mentioned and thus improve a conventional computer program programmed in an object-oriented scripting language with regard to error generation and error detection. It is therefore now possible to use such computer programs with their advantages compared to compiler-based computer programs and still offer the better analysis capability with regard to error detection that is available with compiler-based computer programs.

Abstrakte Klassen sind in der objektorientierten Programmierung Klassen, welche mindestens eine abstrakte Methode oder mindestens ein abstraktes Attribut aufweisen. Methoden und Attribute einer Klasse können als Mitglieder der Klasse (member) bezeichnet werden. Interfaces sind ein Spezialfall abstrakter Klassen. Sie weisen regulär nur abstrakte Mitglieder auf, das bedeutet, sie weisen beispielsweise nur abstrakte Methoden und abstrakte Attribute auf. Ein Interface kann als Vertrag verstanden werden, der beschreibt, welche Mitglieder eine Klasse haben soll. Ein abstraktes Mitglied ist insbesondere ein Mitglied (member), welches keine Implementierung, sondern nur eine Definition, welche als Signatur bezeichnet werden kann, benutzt. Beispielsweise wird erst durch ein Vorhandensein mindestens eines abstrakten Mitglieds eine Klasse zu einer abstrakten Klasse. Eine abstrakte Klasse kann allgemein auch nicht abstrakte Mitglieder besitzen. Ein Interface in der Regel jedoch nicht. In object-oriented programming, abstract classes are classes that have at least one abstract method or at least one abstract attribute. Methods and attributes of a class can be referred to as members of the class. Interfaces are a special case of abstract classes. They normally only have abstract members, which means that they only have abstract methods and abstract attributes, for example. An interface can be understood as a contract that describes which members a class should have. An abstract member is in particular a member that does not use an implementation, but only a definition, which can be referred to as a signature. For example, a class only becomes an abstract class if it has at least one abstract member. In general, an abstract class can also have non-abstract members. However, an interface usually does not.

Insbesondere wird eine abstrakte Klasse bereitgestellt, insbesondere programmiert, insbesondere dem Computerprogramm hinzugefügt. Insbesondere werden einige Interfaces, insbesondere nur Interfaces, bereitgestellt. Dazu wird insbesondere der Computerprogrammteil benutzt. Beispiele für einen Typ eines Mitglieds kann eine Methode, ein Attribut, eine Klassenmethode (Class Method) oder eine statische Methode (static Method) sein. In particular, an abstract class is provided, in particular programmed, in particular added to the computer program. In particular, some interfaces, in particular only interfaces, are provided. In particular, the computer program part is used for this purpose. Examples of a type of a member can be a method, an attribute, a class method (Class Method) or a static method (static Method).

Beispielcode für Python: from happy. typing import Abstractclass, abstractmethod, typechecked Example code for Python: from happy. typing import Abstractclass, abstractmethod, typechecked

# Definition des Interfaces class ITest(AbstractClass): # Definition of the interface class ITest(AbstractClass):

@abstractmethod @abstractmethod

@typechecked def foo(self, value:int) -> str: @typechecked def foo(self, value:int) -> str:

©property ©property

@abstractmethod def bar(self) -> float: @abstractmethod def bar(self) -> float:

Durch diesen Beispielcode kann ein Interface als Spezialfall einer abstrakten Klasse bereitgestellt werden. Durch Ausführen dieses Beispielcodes wird insbesondere ein Interface erzeugt. This example code can be used to provide an interface as a special case of an abstract class. Specifically, executing this example code creates an interface.

Nicht abstrakte Klassen können von abstrakten Klassen, insbesondere von Interfaces erben. Dabei müssen alle Mitglieder der abstrakten Klasse von der erbenden Klasse realisiert werden, sodass jedem abstraktem Mitglied der abstrakten Klasse ein nicht abstraktes Mitglied der erbenden Klasse mit den, insbesondere gleichen, Eigenschaft zugeordnet entspricht. Eine Klasse kann ein Interface realisieren, indem sie von ihr erbt und die entsprechenden Mitglieder mit einer echten Implementierung überschreibt. Eine Realisierung ist insbesondere die konkrete Implementierung zu einem Interface. Insbesondere müssen alle zuvor abstrakten Mitglieder tatsächlich implementiert sein. Eine Klasse kann eine Realisierung mehrerer Interfaces darstellen. Non-abstract classes can inherit from abstract classes, especially from interfaces. All members of the abstract class must be implemented by the inheriting class, so that each abstract member of the abstract class corresponds to a non-abstract member of the inheriting class with the same properties. A class can implement an interface by inheriting from it and overwriting the corresponding members with a real implementation. A realization is in particular the concrete implementation of an interface. In particular, all previously abstract members must actually be implemented. A class can represent a realization of several interfaces.

Beispielcode für Python: Example code for Python:

# korrekte Realisierung dass cTest(ITest): # correct implementation that cTest(ITest):

@typechecked def foo(self, value:int) -> str: @typechecked def foo(self, value:int) -> str:

... # Hier erfolgt die Implementierung ... # Here the implementation takes place

©property def bar(self) -> float: ©property def bar(self) -> float:

... # Hier erfolgt die Implementierung ... # Here the implementation takes place

Von der erbenden Klasse kann ein Objekt abgeleitet und erzeugt werden. Dies kann als Instanziierung der erbenden Klasse bezeichnet werden. Dadurch erhält das Objekt eine Referenz auf die abstrakte Klasse, insbesondere auf das Interface, von der die erbende Klasse erbt. Insbesondere ist eine Referenz eine Art Adresse, unter der ein Objekt angesprochen werden kann. Bei manchen Programmiersprachen ist es möglich, dass Referenzen direkt durch Speicheradressen dargestellt werden. Bei Python beispielsweise ist dies nicht der Fall. Wird eine Klasse instanziiert, wird insbesondere das Objekt im Speicher der Recheneinheit, insbesondere eines Computers, angelegt. Insbesondere wird anschließend dieses Objekt in Form einer Referenz an Funktionen oder andere Klassen weitergeleitet, so dass diese drauf zugreifen können. Gegebenenfalls reicht die Speicheradresse nicht für einen Zugriff, sondern es wird zusätzlich eine Information benötigt, um welches Objekt es sich handelt. Dabei ist es beispielsweise nötig, die zugehörige Klasse des Objektes für einen Zugriff zu übergeben. Dann ist es möglich, das Objekt über die Referenz korrekt anzusprechen. Gemäß des erfindungsgemäßen Verfahren stellt das Objekt die Referenz auf die abstrakte Klasse, insbesondere auf das Interface, dar. Dadurch, dass die Referenz des Objekts auf die abstrakte Klasse, insbesondere das Interface verweist, kann es über die Methoden und Attribute des Interfaces von außen angesprochen werden. Insbesondere ist es deshalb wichtig, dass Mitglieder des Interfaces den Mitgliedern der erbenden Klasse bezüglich ihrer Eigenschaften korrekt und vollständig vererbt, insbesondere implementiert, werden. Dadurch kann eine lose Kopplung zwischen Softwarekomponenten erreicht werden. Eine Softwarekomponente, die ein Objekt einer erbenden Klasse benutzt, bekommt nur das nötigste mitgeteilt, um das Objekt zu nutzen. Eine solche Softwarekomponente kann als Client bezeichnet werden und das Objekt als Service. Ein Client, der eine andere Klasse oder eine Funktion sein kann, kann von dem Interface abhängen anstatt von einer bestimmten Klasse. Dies ermöglicht es, die Implementierung später durch eine andere Klasse zu ersetzen, die das gleiche Interface realisiert. Dadurch entsteht eine lose Kopplung zwischen Klassen. Der Softwarecode kann dadurch modularer aufgebaut werden und ist damit leichter zu pflegen. Außerdem ist der Softwarecode dadurch leichter wiederverwendbar, insbesondere in verschiedenen Kontexten. An object can be derived from the inheriting class and created. This can be referred to as instantiation of the inheriting class. This gives the object a reference to the abstract class, in particular to the interface, from which the inheriting class inherits. In particular, a reference is a kind of address under which an object can be addressed. In some programming languages, it is possible for references to be represented directly by memory addresses. In Python, for example, this is not the case. If a class is instantiated, the object in particular is created in the memory of the processing unit, in particular a computer. In particular, this object is then passed on to functions or other classes in the form of a reference so that they can access it. The memory address may not be sufficient for access, but additional information is required as to which object it is. For example, it is necessary to pass the associated class of the object for access. It is then possible to address the object correctly via the reference. According to the method according to the invention, the object represents the reference to the abstract class, in particular to the interface. Because the reference of the object refers to the abstract class, in particular the interface, it can be addressed from outside via the methods and attributes of the interface. It is therefore particularly important that members of the interface are correctly and completely inherited, in particular implemented, by the members of the inheriting class with regard to their properties. This makes it possible to achieve a loose coupling between software components. A software component that uses an object of an inheriting class is only given the bare minimum to use the object. Such a software component can be called a client and the object a service. A client, which can be another class or a function, can depend on the interface instead of a specific class. This makes it possible to later replace the implementation with another class that implements the same interface. This creates a loose coupling between classes. The software code can thus be built in a more modular way and is therefore easier to maintain. It also makes the software code easier to reuse, especially in different contexts.

Beispielcode für Python: c = CT est() Example code for Python: c = CT est()

Insbesondere wird der Vergleich der Eigenschaften der abstrakten Mitglieder mit den Eigenschaften der nicht abstrakten Mitglieder durch die Instanziierung ausgelöst. Insbesondere wird der Vergleich für alle abstrakten Mitglieder mit allen nicht abstrakten Mitgliedern durchgeführt. Insbesondere wird der Vergleich durch die Instanziierung ausgelöst, wenn ein weiterer Computerprogrammteil, insbesondere eine eingebundene Bibliothek, dies ermöglicht. Insbesondere wird der Vergleich ohne den weiteren Computerprogrammteil nicht ausgelöst. Insbesondere wird durch das Verfahren überprüft, ob eine Instanz überhaupt in der Lage ist ein Interface zu realisieren. In particular, the comparison of the properties of the abstract members with the properties of the non-abstract members is triggered by the instantiation. In particular, the comparison is carried out for all abstract members with all non-abstract members. In particular, the comparison is triggered by the instantiation if another computer program part, in particular an integrated library, enables this. In particular, the comparison is not triggered without the other computer program part. In particular, the procedure checks whether an instance is even able to realize an interface.

Das Verfahren ist besonders vorteilhaft, da es eine Verwendung gängiger Software- Engineering Konzepte wie „Dependency Injection“ sowie zahlreicher objektorientierter Pattern (oop Pattern) ermöglicht oder erleichtert. Insbesondere in der Programmiersprache Python ist das Konzept von der Verwendung von Interfaces prinzipiell unbekannt. Daher kann in Python bisher nicht überprüft werden, ob eine Realisierung konsistent ist und/oder ob eine übergebene Referenz mit dem Interface kompatibel ist. The method is particularly advantageous because it enables or facilitates the use of common software engineering concepts such as "dependency injection" and numerous object-oriented patterns (oop patterns). In the Python programming language in particular, the concept of using interfaces is fundamentally unknown. Therefore, it is not yet possible to check in Python whether an implementation is consistent and/or whether a passed reference is compatible with the interface.

Tritt beispielsweise beim Vergleich ein Fehler auf, wird ein Eintrag in eine Fehlerliste erzeugt. Als Fehler wird beispielsweise erkannt, wenn nicht alle abstrakten Mitglieder der abstrakten Klasse, insbesondere des Interfaces, jeweils einem nicht abstrakten Mitglied der erbenden Klasse zugeordnet werden können. Dann wird, insbesondere die Fehlerliste, als eine Fehlermeldung ausgegeben. Das Ausgeben der Fehlerliste kann bedeuten, dass die Fehlerliste einem Benutzer, akustisch oder visuell, insbesondere auf einem Bildschirm angezeigt wird. Die Fehlerliste kann alternativ dazu oder zusätzlich an ein externes System ausgegeben bzw. zur Verfügung gestellt werden. Insbesondere enthält die Fehlerliste eine Angabe welche Eigenschaften welcher Mitglieder nicht übereinstimmen. If, for example, an error occurs during the comparison, an entry is created in an error list. An error is recognized, for example, if not all abstract members of the abstract class, in particular of the interface, can be assigned to a non-abstract member of the inheriting class. Then, in particular, the error list is output as an error message. Outputting the error list can mean that the error list is displayed to a user, acoustically or visually, in particular on a screen. Alternatively or additionally, the error list can be output or made available to an external system. In particular, the error list contains information about which properties of which members do not match.

In einem Ausführungsbeispiel weist das Verfahren folgende weitere Schritte auf: Überprüfen bei allen von einer Softwarekomponente des Computerprogramms referenzierten Objekten, ob das jeweilige referenzierte Objekt eine Referenz auf die zugehörige abstrakte Klasse darstellt; und falls wenigstens ein überprüftes von einer Softwarekomponente referenzielles Objekt nicht die Referenz auf die zugehörige Klasse darstellt, wird eine weitere Fehlermeldung ausgegeben. In one embodiment, the method comprises the following further steps: checking all objects referenced by a software component of the computer program to determine whether the respective referenced object represents a reference to the associated abstract class; and if at least one checked object referential to a software component does not represent the reference to the associated class, a further error message is output.

Insbesondere ist die zugehörige abstrakte Klasse, eine zu erwartende, insbesondere im Programmcode angegebene, abstrakte Klasse. Insbesondere muss für jede Funktion oder Methode des Computerprogramms geprüft werden, ob die übergebenen Referenzen des Objektes (übergebene Objektreferenzen) Instanzen der erwarteten abstrakten Klassen sind. Sind sie das nicht, wird gegebenenfalls eine Fehlermeldung ausgegeben, insbesondere an einen Benutzer ausgegeben und/oder einem externen System zur Verfügung gestellt. In particular, the associated abstract class is an expected abstract class, in particular one specified in the program code. In particular, for each function or method of the computer program, it must be checked whether the passed references of the object (passed object references) are instances of the expected abstract classes. If they are not, an error message may be issued, in particular issued to a user and/or made available to an external system.

Die Überprüfung kann auch als Laufzeittypüberprüfung bezeichnet werden, da diese Überprüfung insbesondere zur Laufzeit stattfindet und dabei der Typ der abstrakten Klasse, die eine Referenz auf das Objekt aufweist, überprüft wird. Der Typ der abstrakten Klasse bezeichnet insbesondere den Namen der abstrakten Klasse. The check can also be called runtime type checking, since this check takes place especially at runtime and the type of the abstract class, which has a reference to the object is checked. The type of the abstract class specifically indicates the name of the abstract class.

Beispielcode in Python: Example code in Python:

@typechecked def do_something(instance: Interface): instance. foo() @typechecked def do_something(instance: Interface): instance. foo()

Insbesondere können durch die Überprüfung nur Objekte von der zu erwartenden Klasse, die eine abstrakte Klasse, insbesondere ein Interface, realisieren, als Argument an eine Funktion oder Methode übergeben werden. Insbesondere wird dadurch überprüft, ob eine Referenz formal einem zu erwartenden Interface zugeordnet werden kann. In particular, the check ensures that only objects from the expected class that implement an abstract class, in particular an interface, can be passed as an argument to a function or method. In particular, this checks whether a reference can be formally assigned to an expected interface.

Bei diesem Ausführungsbeispiel kann die Konsistenz des Computerprogramms sichergestellt werden. Dadurch ist es ausfallsicherer und weniger fehleranfällig. In this embodiment, the consistency of the computer program can be ensured. This makes it more fail-safe and less prone to errors.

In einem Ausführungsbeispiel werden folgende Eigenschaften der Mitglieder verglichen: Namen der Mitglieder, In one embodiment, the following properties of the members are compared: names of the members,

Typ und Datentyp des jeweiligen Mitgliedes, und Argumente des jeweiligen Mitgliedes, und Datentyp des jeweiligen Arguments des Mitglieds, und Datentyp eines Rückgabewertes, Type and data type of the respective member, and arguments of the respective member, and data type of the respective argument of the member, and data type of a return value,

Der Typ eines Mitglieds bezeichnet beispielsweise, ob es sich bei dem Mitglied um ein Attribut oder um eine Methode handelt. Beim Vergleich der Argumente des Mitglieds wird insbesondere der Name und die Anzahl der Argumente einer Methode verglichen. For example, the type of a member indicates whether the member is an attribute or a method. When comparing the arguments of the member, the name and number of arguments of a method are compared in particular.

Argumente sind insbesondere Übergabeparameter. Insbesondere wird auch der jeweilige Datentyp der Argumente verglichen. Arguments are in particular transfer parameters. In particular, the respective data type of the arguments is also compared.

Insbesondere werden zusätzlich, insbesondere alle, Funktionsdekoratoren (function decorator) der Mitglieder verglichen. Insbesondere ist ein Funktionsdekorator eine Funktion, die eine andere Funktion aufnimmt und das Verhalten der letzteren Funktion erweitert, ohne sie explizit zu verändern. Insbesondere ist ein Funktionsdekorator eine Funktion, die eine andere Funktion umhüllt. Insbesondere sieht es von außen so aus, als ob die eigentliche Funktion aufgerufen wird, aber es wird zunächst der Dekorator ausgeführt, welcher dann intern die eigentliche Funktion ausführt und dann den Rückgabewert dieser ebenfalls zurück gibt. Kann für jedes abstrakte Mitglied der abstrakten Klasse, insbesondere des Interfaces, ein nicht abstraktes Mitglied der erbenden Klasse identifiziert werden, dass in allen Eigenschaften mit einem abstrakten Mitglied übereinstimmt, dann ist dieser Vergleich erfolgreich. Damit kann sichergestellt werden, dass die erbende Klasse eine korrekte Realisierung der abstrakten Klasse, insbesondere des Interfaces, ist. Dadurch ist das Computerprogramm ausfallsicherer und weniger fehleranfällig. In particular, all function decorators of the members are compared. In particular, a function decorator is a function that takes another function and extends the behavior of the latter function without explicitly changing it. In particular, a function decorator is a function that wraps another function. In particular, from the outside it looks as if the actual function is being called, but the decorator is executed first, which then internally executes the actual function and then returns the return value of this function as well. If for every abstract member of the abstract class, in particular the interface, a non-abstract member of the inheriting class can be identified that matches an abstract member in all properties, then this comparison is successful. This ensures that the inheriting class is a correct implementation of the abstract class, in particular the interface. This makes the computer program more reliable and less prone to errors.

In einem Ausführungsbeispiel wird zu den, insbesondere zu jeder, erbenden Klasse des Computerprogramms ein Objekt vor Durchführen eines Hauptteils des Computerprogramms erzeugt. Es wird überprüft, ob die jeweilige Erzeugung erfolgreich ist. In one embodiment, an object is created for the, in particular for each, inheriting class of the computer program before executing a main part of the computer program. It is checked whether the respective creation is successful.

Insbesondere kann dies als Modultest oder Unit-Test bezeichnet werden. Insbesondere löst das Erzeugen des Objektes, was auch als Instanziieren der erbenden Klasse bezeichnet werden kann, den Vergleich der Eigenschaften der abstrakten Mitglieder mit den Eigenschaften der nicht abstrakten Mitglieder aus. Ist der Vergleich nicht erfolgreich, dann kann auch das Objekt nicht erzeugt werden. Insbesondere wird dann eine Fehlermeldung ausgegeben. In particular, this can be referred to as a module test or unit test. In particular, the creation of the object, which can also be referred to as instantiating the inheriting class, triggers the comparison of the properties of the abstract members with the properties of the non-abstract members. If the comparison is unsuccessful, the object cannot be created. In particular, an error message is then issued.

Insbesondere können die Modultests, insbesondere für alle, erbenden Klassen automatisiert erstellt und/oder ausgeführt werden. In particular, the unit tests, especially for all inheriting classes, can be created and/or executed automatically.

Als Hauptteil kann ein Programmteil des Computerprogramms bezeichnet werden, der beispielsweise dauerhaft ausgeführt wird solange das Computerprogramm läuft. The main part can be a part of the computer program that is, for example, executed continuously as long as the computer program is running.

Insbesondere wird im Hauptteil des Computerprogramms Code ausgeführt, der nicht Teil des Modultests ist. In particular, code that is not part of the unit test is executed in the main part of the computer program.

Beispielcode für Python: def test_create(self): instance = Class() assert isinstance(instance, Interface) assert isinstance(instance, Class) Example code for Python: def test_create(self): instance = Class() assert isinstance(instance, Interface) assert isinstance(instance, Class)

Die letzten beiden Zeilen sind für den Modultest gegebenenfalls nicht notwendig. Sie erhöhen aber eine Sicherheit und Zuverlässigkeit der Konsistenz des Computerprogramms. Insbesondere wird in diesen beiden Zeilen überprüft, ob die erzeugte Instanz eine Instanz der erbenden Klasse ist, die eine abstrakte Klasse, insbesondere ein Interface, realisiert. The last two lines may not be necessary for the module test. However, they increase the security and reliability of the consistency of the computer program. In particular, these two lines check whether the created instance is an instance of the inheriting class that implements an abstract class, in particular an interface.

In einem Ausführungsbeispiel sind alle Softwarekomponenten des Computerprogrammes, insbesondere nur, von abstrakten Klassen abhängig. Die Abhängigkeiten der Softwarekomponenten, insbesondere solche, die von abstrakten Klassen erben, zentral erzeugt und übergeben. In one embodiment, all software components of the computer program are dependent on abstract classes, in particular only. The dependencies of the software components, in particular those that inherit from abstract classes, are generated and transferred centrally.

Die vorteilhafte Weiterbildung dieses Ausführungsbeispiels kann als Einbringen von Abhängigkeiten (Dependecy Injection) bezeichnet werden. Als Dependency Injection kann in der objektorientierten Programmierung ein Entwurfsmuster bezeichnet werden, welches Abhängigkeiten eines Objekts zur Laufzeit reglementiert. Benötigt ein Objekt beispielsweise bei seiner Instanziierung ein anderes Objekt, ist diese Abhängigkeit an einem zentralen Ort hinterlegt, es wird also nicht vom initialisierten Objekt selbst erzeugt. Dieser zentrale Ort kann als Compositon Root bezeichnet werden. Insbesondere ist mit Ort eine Stelle im Computerprogramm gemeint. The advantageous development of this embodiment can be referred to as the introduction of dependencies (dependency injection). In object-oriented programming, dependency injection can be referred to as a design pattern that regulates the dependencies of an object at runtime. If, for example, an object requires another object when it is instantiated, this dependency is stored in a central location, i.e. it is not created by the initialized object itself. This central location can be referred to as the composition root. In particular, location refers to a place in the computer program.

Dabei ist es beispielsweise möglich, dass die Abhängigkeiten von anderen Klassen über Konstruktoren zur Verfügung gestellt werden. Dies kann als Constructor Dependency Injection bezeichnet werden. For example, it is possible that the dependencies of other classes are made available via constructors. This can be referred to as constructor dependency injection.

Die Composition Root des Computerprogramms wird insbesondere direkt nach Start des Programms aufgerufen, insbesondere bevor der Hauptteil des Computerprogramms ausgeführt wird. Dadurch kann sichergestellt werden, dass die Abhängigkeiten bereits zu Beginn des Computerprogramms überprüft werden. Dadurch kann an dieser Stelle bereits bei allen von einer Softwarekomponente des Computerprogramms referenziellen Objekten überprüft werden, ob das jeweilige referenzierte Objekt eine Referenz auf die zugehörige, insbesondere erwartete, abstrakte Klasse aufweist. The composition root of the computer program is called directly after the program starts, especially before the main part of the computer program is executed. This ensures that the dependencies are checked right at the start of the computer program. This means that all objects referenced by a software component of the computer program can be checked at this point to see whether the respective referenced object has a reference to the associated, in particular expected, abstract class.

So können Fehler vor Durchführen des Hauptteil festgestellt werden. Auch dadurch ist das Computerprogramm ausfallsicherer und weniger fehleranfällig. This allows errors to be identified before the main part is carried out. This also makes the computer program more reliable and less prone to errors.

In einem Ausführungsbeispiel wird das Computerprogramm in einer Python Programmiersprache programmiert und getestet. Diese Programmiersprache bietet viele Vorteile. Insbesondere gilt sie als Standard im Bereich Datenwissenschaft und maschinelles Lernen. Insbesondere wird Python 3 verwendet. In one embodiment, the computer program is programmed and tested in a Python programming language. This programming language offers many advantages. In particular, it is considered the standard in the field of data science and machine learning. In particular, Python 3 is used.

Ein weiterer Aspekt der Erfindung betrifft ein Verfahren zum Ausführen eines Computerprogramms. Dabei wird ein Testen des Computerprogramms vor einer Ausführung eines Hauptteils des Computerprogramms durchgeführt wird. Falls ein Eintrag in die Fehlerliste erfolgt oder eine Fehlermeldung ausgegeben wird, wird das Ausführen des Hauptteils verhindert. Falls kein Eintrag in die Fehlerliste erfolgt oder eine Fehlermeldung ausgegeben wird, wird der Hauptteil des Computerprogramms, insbesondere automatisch, gestartet. Zusätzlich oder alternativ dazu wird das erfindungsgemäße Verfahren zum Testen bei einem bereits gestarteten Ausführen des Hauptteils zumindest einmal durchgeführt, insbesondere dann durchgeführt, wenn ein von einer erbenden Klasse abgeleitetes Objekt erzeugt wird. A further aspect of the invention relates to a method for executing a computer program. In this case, the computer program is tested before a main part of the computer program is executed. If an entry is made in the error list or an error message is output, the execution of the main part is prevented. If no entry is made in the error list or an error message is output, the main part of the computer program is started, in particular automatically. Additionally or alternatively, the method for testing according to the invention is carried out at least once when the execution of the main part has already started, in particular when an object derived from an inheriting class is created.

Wird der Hauptteil nicht ausgeführt, da ein Fehler vorliegt, kann dieser identifiziert und behoben werden. Insbesondere wird der Fehler durch das erfindungsgemäße Verfahren identifiziert und von dem externen System automatisiert behoben. If the main part is not executed because an error is present, this can be identified and corrected. In particular, the error is identified by the method according to the invention and automatically corrected by the external system.

Bei Computerprogrammen, die in einer Skriptsprache, insbesondere ohne Kompilierer, programmiert werden und nicht durch das erfindungsgemäße Verfahren getestet werden, ist es möglich, dass Fehler erst während der Ausführung des Hauptteils auftreten. Es ist möglich, dass dies erst nach einigen Stunden oder später der Fall ist. Durch das erfindungsgemäße Verfahren werden Fehler vor der Ausführung des Hauptteils erkannt. Dadurch kann Zeit und Energie gespart werden, da kein fehlerhaftes Programm unnötig lange ausgeführt wird. In the case of computer programs that are programmed in a scripting language, in particular without a compiler, and are not tested by the method according to the invention, it is possible that errors only occur during the execution of the main part. It is possible that this only occurs after several hours or later. The method according to the invention detects errors before the main part is executed. This saves time and energy, since no faulty program is executed for an unnecessarily long time.

Das getestete Computerprogramm kann zur, insbesondere autonomen, insbesondere teilautonomen, Steuerung eines Fahrzeugs verwendet werden. Durch das erfindungsgemäße Testen wird eine Ausfallsicherheit des Computerprogramms erhöht. Durch die erhöhte Ausfallsicherheit kann ein sichererer Betrieb des Fahrzeugs gewährleistet werden. The tested computer program can be used for the, in particular autonomous, in particular semi-autonomous, control of a vehicle. The testing according to the invention increases the reliability of the computer program. The increased reliability can ensure safer operation of the vehicle.

Ein weiterer Aspekt der Erfindung betrifft ein System zur Durchführung eines Verfahrens, aufweisend Mittel zur Ausführung der Schritte des Verfahrens nach einem der vorhergehenden Ansprüchen. Das System kann eine elektronische Testeinheit und/oder eine elektronische Recheneinheit aufweisen. Ein weiterer Aspekt der Erfindung betrifft ein Computerprogramm, welches nach einem Verfahren gemäß dem oben genannten Aspekt getestet ist, insbesondere in eine Speichereinheit ladbar ist und durch einen Prozessor ausführbar ist. A further aspect of the invention relates to a system for carrying out a method, comprising means for carrying out the steps of the method according to one of the preceding claims. The system can comprise an electronic test unit and/or an electronic computing unit. A further aspect of the invention relates to a computer program which is tested according to a method according to the above-mentioned aspect, in particular is loadable into a memory unit and is executable by a processor.

Ein weiterer Aspekt der Erfindung betrifft ein computerlesbares Speichermedium, aufweisend Befehle, die bei Ausführung durch einen Computer diesen veranlassen, die Schritte des Verfahrens nach einem der Ansprüche 1 bis 7 auszuführen. A further aspect of the invention relates to a computer-readable storage medium comprising instructions which, when executed by a computer, cause the computer to carry out the steps of the method according to one of claims 1 to 7.

Weitere Ausführungsformen des erfindungsgemäßen Systems, des erfindungsgemäßen Computerprogramms und des erfindungsgemäßen Speichermediums folgen unmittelbar aus den verschiedenen Ausgestaltungen des erfindungsgemäßen Verfahrens und umgekehrt. Insbesondere lassen sich einzelne Merkmale und entsprechende Erläuterungen sowie Vorteile bezüglich der verschiedenen Ausführungsformen zu dem erfindungsgemäßen Verfahren analog auf entsprechende Ausführungsformen des erfindungsgemäßen Systems, des erfindungsgemäßen Computerprogramms und des erfindungsgemäßen Speichermediums übertragen. Insbesondere ist das erfindungsgemäße System, das erfindungsgemäße Computerprogramm und das erfindungsgemäße Speichermedium zum Durchführen eines erfindungsgemäßen Verfahrens ausgebildet oder programmiert. Insbesondere führt das erfindungsgemäße System, das erfindungsgemäße Computerprogramm und das erfindungsgemäße Speichermedium das erfindungsgemäße Verfahren durch. Further embodiments of the system according to the invention, the computer program according to the invention and the storage medium according to the invention follow directly from the various embodiments of the method according to the invention and vice versa. In particular, individual features and corresponding explanations as well as advantages with regard to the various embodiments of the method according to the invention can be transferred analogously to corresponding embodiments of the system according to the invention, the computer program according to the invention and the storage medium according to the invention. In particular, the system according to the invention, the computer program according to the invention and the storage medium according to the invention are designed or programmed to carry out a method according to the invention. In particular, the system according to the invention, the computer program according to the invention and the storage medium according to the invention carry out the method according to the invention.

Die Erfindung umfasst auch die Kombinationen der Merkmale der beschriebenen Ausführungsformen. The invention also includes combinations of the features of the described embodiments.

Im Folgenden werden Ausführungsbeispiele der Erfindung beschrieben. Hierzu zeigt: In the following, embodiments of the invention are described.

Fig. 1 ein Klassendiagramm eines Ausführungsbeispiels eines Computerdiagramms; Fig. 1 is a class diagram of an embodiment of a computer diagram;

Bei den im Folgenden erläuterten Ausführungsbeispielen handelt es sich um bevorzugte Ausführungsbeispiele der Erfindung. Bei den Ausführungsbeispielen stellen die beschriebenen Komponenten jeweils einzelne, unabhängig voneinander zu betrachtende Merkmale der Erfindung dar, welche die Erfindung jeweils auch unabhängig voneinander weiterbilden und damit auch einzeln oder in einer anderen als der gezeigten Kombination als Bestandteil der Erfindung anzusehen sind. Des Weiteren sind die beschriebenen Ausführungsbeispiele auch durch weitere der bereits beschriebenen Merkmale der Erfindung ergänzbar. The embodiments explained below are preferred embodiments of the invention. In the embodiments, the components described each represent individual features of the invention that are to be considered independently of one another, which also develop the invention independently of one another and are therefore to be considered as part of the invention individually or in a combination other than that shown. Furthermore, the described Embodiments can also be supplemented by further features of the invention already described.

In der Figur sind funktionsgleiche Elemente jeweils mit denselben Bezugszeichen versehen. In the figure, functionally identical elements are provided with the same reference symbols.

In Fig. 1 ist ein beispielhaftes Klassendiagramm 1 eines Ausführungsbeispiels eines Computerprogramms gezeigt. Die abstrakte Klasse 2 „Interface“ kann ein Attribut 3, dass „Attribut“ heißt und eine Methode 4, die „Operation“ heißt, aufweisen. Alle Attribute und Methoden sind in diesem Ausführungsbeispiel abstrakt. Deshalb handelt es sich bei dieser abstrakten Klasse 2 um ein Interface 2. Das Attribut 3 ist in diesem Ausführungsbeispiel vom Datentyp String 5. Das Attribut 3 kann insbesondere eine Zeichenkette sein. Die Methode 4 „Operation“ erwartet einen Übergabeparameter 6 „Wert“ vom Datentyp String 7. Ein Rückgabewert der Methode 4 „Operation“ ist von einem booleschen Datentyp 8. Fig. 1 shows an example class diagram 1 of an embodiment of a computer program. The abstract class 2 "Interface" can have an attribute 3 called "Attribute" and a method 4 called "Operation". All attributes and methods are abstract in this embodiment. Therefore, this abstract class 2 is an interface 2. In this embodiment, the attribute 3 is of the data type String 5. The attribute 3 can in particular be a character string. The method 4 "Operation" expects a transfer parameter 6 "Value" of the data type String 7. A return value of the method 4 "Operation" is of a Boolean data type 8.

Die erbende Klasse 9 „erbende Klasse“ realisiert das Interface 2. Das bedeutet, dass auch die erbende Klasse 9 ein Attribut 10 „Attribut“ und eine Methode 11 „Operation“ aufweist. Gegebenenfalls weist die erbende Klasse 9 noch weitere Attribute und Methoden auf. Gegebenenfalls erbt sie zusätzlich von einem weiteren Interface. Insbesondere weißt die erbende Klasse 9 alle Attribute und Methoden des Interfaces 2 auf. Die Methoden und Attribute der erbenden Klasse sind alle nicht abstrakt. The inheriting class 9 "inheriting class" implements the interface 2. This means that the inheriting class 9 also has an attribute 10 "attribute" and a method 11 "operation". The inheriting class 9 may have further attributes and methods. It may also inherit from another interface. In particular, the inheriting class 9 has all the attributes and methods of the interface 2. The methods and attributes of the inheriting class are all non-abstract.

Wird ein Objekt erzeugt, welches von der erbenden Klasse 9 abgeleitet wird, dann wird für alle abstrakten Mitglieder des Interfaces 2 überprüft ob es jeweils ein nicht abstraktes Mitglied in der erbenden Klasse 9 gibt, welches die gleichen Eigenschaften besitzt. Beispielsweise weist das Interface 2 das Attribut 3 „Attribut“ auf. Auch die erbende Klasse 9 weist ein Attribut 10 mit der Bezeichnung „Attribut“ auf. Daher stimmt die Eigenschaft Name des Mitglieds überein. Bei beiden Attributen handelt es sich um ein Attribut und nicht um eine Methode. Daher stimmen diese Mitglieder auch bezüglich des Typs überein. Insbesondere wird auch der Datentyp der Attribute 5, 12 verglichen. Beide Attribute sind vom Datentyp String 5, 12. Deshalb stimmt auch diese Eigenschaft überein. Beim Vergleich der Methode 4 „Operation“ des Interfaces 2 mit der Methode 11 „Operation“ der erbenden Klasse 9 kann festgestellt werden, dass sie in der Eigenschaft des Namens übereinstimmen. Beim Vergleich ihrer Übergabeparameter kann festgestellt werden, dass diese den gleichen Namen „Wert“ 6, 13 haben und vom gleichen Datentyp „String“ 7, 14 sind. Der Rückgabewert des Mitglieds „Operation“ des Interfaces 2 ist ein boolescher Datentyp 8 und der Rückgabewert des Mitglieds „Operation“ der erbenden Klasse 9 ist ebenfalls ein boolescher Datentyp 15. Da für alle abstrakten Mitglieder 3, 4 des Interfaces 2 ein nicht abstraktes Mitglied 10, 11 der erbenden Klasse 9 gefunden werden kann, das bezüglich aller verglichenen Eigenschaften übereinstimmt, kann davon ausgegangen werden, dass die erbende Klasse 9 korrekt von dem Interface 2 geerbt hat. Um sicherzustellen, dass die Mitglieder der richtigen erbenden Klasse bezüglich der Mitglieder des richtigen Interfaces verglichen wird, kann ein Zusammenhang zwischen dem Interface 2 und der erbenden Klasse 9 überprüft werden, indem für das zu erzeugende Objekt überprüft wird, ob es sowohl von der erbenden Klasse 9 abgeleitet wurde und als auch von dem Interface 2. If an object is created which is derived from the inheriting class 9, then all abstract members of interface 2 are checked to see whether there is a non-abstract member in the inheriting class 9 which has the same properties. For example, interface 2 has attribute 3 "Attribute". The inheriting class 9 also has attribute 10 called "Attribute". Therefore, the member's name property matches. Both attributes are attributes and not methods. Therefore, these members also match in terms of type. In particular, the data type of attributes 5 and 12 is also compared. Both attributes are of the data type String 5 and 12. Therefore, this property also matches. When comparing method 4 "Operation" of interface 2 with method 11 "Operation" of the inheriting class 9, it can be seen that they match in terms of the name property. When comparing their parameters, it can be seen that they have the same name "Value" 6, 13 and are of the same data type "String" 7, 14. The return value of the member "Operation" of the interface 2 is a Boolean data type 8 and the return value of the member "Operation" of the inheriting class 9 is also a Boolean data type 15. Since for all abstract members 3, 4 of interface 2 a non-abstract member 10, 11 of the inheriting class 9 can be found that matches with respect to all compared properties, it can be assumed that the inheriting class 9 has correctly inherited from interface 2. To ensure that the members of the correct inheriting class are compared with respect to the members of the correct interface, a connection between interface 2 and the inheriting class 9 can be checked by checking for the object to be created whether it was derived from both the inheriting class 9 and the interface 2.

Dieses Verfahren ist besonders vorteilhaft, wenn es vor einer Ausführung eines Hauptteils durchgeführt wird. Insbesondere im Rahmen eines Modultests. Dadurch kann eine Zeit bis ein Fehler erster Art erkannt wird verkürzt werden. Ein Fehler erster Art ist insbesondere wenn nicht alle abstrakten Mitglieder in der erbenden Klasse 9 realisiert werden oder wenn das Mitglied in der erbenden Klasse 9 bezüglich seiner Eigenschaften nicht mit dem abstrakten Mitglied übereinstimmt. This method is particularly advantageous if it is carried out before a main part is executed, particularly as part of a module test. This can shorten the time until a type I error is detected. A type I error occurs in particular when not all abstract members are implemented in the inheriting class 9 or when the member in the inheriting class 9 does not match the abstract member in terms of its properties.

Eine Softwarekomponente „Client“ greift auf das Interface 2 zu, wenn es auf ein Objekt zugreift, dass eine Instanz einer von dem Interface 2 erbenden Klasse ist. Um sicherzustellen, dass das Objekt eine Instanz einer von dem Interface 2 erbenden Klasse 9 ist, wird dies in einem Ausführungsbeispiel überprüft. Dazu kann beispielsweise ein Funktionsdekorator @typechecked verwendet werden. A software component "client" accesses interface 2 when it accesses an object that is an instance of a class inheriting from interface 2. To ensure that the object is an instance of a class 9 inheriting from interface 2, this is checked in one embodiment. For example, a function decorator @typechecked can be used for this purpose.

Um die Zeit bis ein Fehler zweiter Art erkannt wird zu verkürzen, wird in einem Ausführungsbeispiel diese Überprüfung ebenfalls vor dem Ausführen des Hauptteils durchgeführt. Insbesondere wird die Überprüfung in einem Modultest und/oder in einer composition root zu Beginn der Ausführung des Computerprogramms, wenn Konstruktoren aufgerufen werden, durchgeführt. In diesem Ausführungsbeispiel wird es als Fehler zweiter Art bezeichnet, wenn eine Softwarekomponente, insbesondere entsprechend einem Programmcode, über ein Interface auf ein Objekt zugreift, dass nicht zu dem Objekt gehört, insbesondere das Objekt nicht referenziert. In order to shorten the time until a type II error is detected, in one embodiment this check is also carried out before the main part is executed. In particular, the check is carried out in a module test and/or in a composition root at the beginning of the execution of the computer program when constructors are called. In this embodiment it is referred to as a type II error if a software component, in particular according to a program code, accesses an object via an interface that does not belong to the object, in particular does not reference the object.

Wird in einem Ausführungsbeispiel ein Fehler erster Art und/oder ein Fehler zweiter Art erkannt, wird eine Fehlermeldung ausgegeben. Gegebenenfalls wird die Ausführung des Hauptteils verhindert. Die Fehlermeldung kann an einen Benutzer ausgegeben werden und/oder einem externen System zur Verfügung gestellt werden. Insbesondere kann das externe System automatisiert den Fehler erster Art und/oder den Fehler zweiter Art beheben. Wird ein Fehler erster Art während der Instanziierung erkannt, wird insbesondere eine Ausnahme (Exception) erzeugt. Ein Beispiel für eine fehlerhafte Realisierung ist: from happy. typing import Abstractclass, abstractmethod, typechecked If an error of the first type and/or an error of the second type is detected in an embodiment, an error message is output. If necessary, the execution of the main part is prevented. The error message can be output to a user and/or made available to an external system. In particular, the external system can automatically correct the error of the first type and/or the error of the second type. If a type I error is detected during instantiation, an exception is generated. An example of an incorrect implementation is: from happy. typing import Abstractclass, abstractmethod, typechecked

# Definition des Interfaces class ITest(AbstractClass): # Definition of the interface class ITest(AbstractClass):

@abstractmethod @abstractmethod

@typechecked def foo(self, value:int) -> str: @typechecked def foo(self, value:int) -> str:

©property ©property

@abstractmethod def bar(self) -> float: @abstractmethod def bar(self) -> float:

# inkorrekte Realisierung # incorrect implementation

# - foo besitzt nicht den Dekorator @typechecked # - foo does not have the @typechecked decorator

# - bar ist kein Property dass CTestlncorrect(ITest): def foo(self, value:int) -> str: def bar(self) -> float: # - bar is not a property that CTestlncorrect(ITest): def foo(self, value:int) -> str: def bar(self) -> float:

Beispielsweise wird die inkorrekte Realisierung folgendermaßen instantziiert: ci = CTestlncorrect() For example, the incorrect realization is instantiated as follows: ci = CTestlncorrect()

Durch die Instanziierung ausgelöst, wird für diese beispielhafte fehlerhafte Realisierung, folgende Fehlermeldung ausgegeben: Triggered by the instantiation, the following error message is issued for this example faulty implementation:

„Conflicting signature for function 'foo' (function(self, value: int) -> str) in class CTestlncorrect while abstract symbols in class ITest is @typechecked function(self, value: int) -> str. Conflicting signature for function 'bar' (function(self) -> float) in class CTestlncorrect while abstract symbols in class ITest is property[get](self) -> float. "Conflicting signature for function 'foo' (function(self, value: int) -> str) in class CTestlncorrect while abstract symbols in class ITest is @typechecked function(self, value: int) -> str. Conflicting signature for function 'bar' (function(self) -> float) in class CTestlncorrect while abstract symbols in class ITest is property[get](self) -> float.

TypeError: Can't instantiate abstract class CTestlncorrect with abstract methods bar, foo ci = CTestlncorrectO" TypeError: Can't instantiate abstract class CTestlncorrect with abstract methods bar, foo ci = CTestlncorrectO"

Weiterhin kann das Testen, insbesondere wenn die Programmiersprache Python verwendet wird, folgendermaßen durchgeführt werden: Ein Computerprogrammteil, insbesondere die „happy. typing" Bibliothek, erweitert die "Abstract Base Class" (ABC-Implementierung) um eine Implementierung, die nur dann eine Realisierung von Interfaces akzeptiert, wenn:Furthermore, testing, especially when the Python programming language is used, can be carried out as follows: A computer program part, in particular the "happy. typing" library, extends the "Abstract Base Class" (ABC implementation) with an implementation that only accepts a realization of interfaces if:

- jedes abstrakte Mitglied von der Klasse implementiert wurde, - every abstract member has been implemented by the class,

- der Typ des abstrakten Mitglieds derselbe ist wie in dem Interface, - the type of the abstract member is the same as in the interface,

- die Argumente des abstrakten Mitglieds die gleichen sind wie in dem Interface,- the arguments of the abstract member are the same as in the interface,

- die Typen der Argumente und der Rückgabetyp des abstrakten Member die gleichen sind wie in dem Interface, und - the types of the arguments and the return type of the abstract member are the same as in the interface, and

- die Dekoratoren des abstrakten Members die gleichen sind wie im Interface. Es wird dabei die komplette Signatur des Members, nicht nur der Name, wie es die ursprüngliche ABC-Implementierung tut, überprüft. Allerdings findet so die Prüfung immer noch zur Laufzeit statt, wenn die Klasse das erste Mal instanziiert wird. Um sicherzustellen, dass die Implementierung einer Klasse mit einem Interface übereinstimmt, muss die Klasse instanziiert werden. Daher reicht es aus, einen einfachen Unit-Test zu erstellen, der lediglich eine Instanz der Klasse erzeugt. Wenn der Unit-Test erfolgreich ist, ist die Implementierung der Klasse konsistent mit dem Interface. Die strenge Konsistenzprüfung findet so zur Zeit des Unit-Tests statt, was viel früher als die Laufzeit der Anwendung ist und sehr ähnlich zu einer "Kompilierzeit" normaler, insbesondere kompilierter, Programmiersprachen ist. Jede Funktion/Methode, die eine Referenz auf das Interface zugewiesen bekommt, sollte einen Typ-Hinweis für diese Schnittstelle verwenden und sie sollte den "@typechecked"-Dekorator verwenden, um eine Laufzeitprüfung der Referenz durchzuführen. Wenn die Referenz keine Instanz des Interfaces ist, würde die Prüfung zur Laufzeit fehlschlagen. So können nur Klassen, die das Interface realisieren dem Argument dieser Funktion/Methode zugewiesen werden. Diese Prüfung findet jedoch erst zur Laufzeit statt, was zu spät für eine "kompilierzeitähnliche Prüfung" ist. Dependency Injection ist ein Muster, bei dem Softwarekomponenten nie direkt von anderen Softwarekomponenten abhängen, sondern von Abstraktionen, insbesondere Interfaces. Außerdem werden die Instanzen aller Abhängigkeiten an einer einzigen Stelle in der Anwendung erstellt. Dieser Ort wird als "composition root" genannt. Innerhalb der Composition Root werden die Abhängigkeiten an die Konstruktoren anderer Klassen übergeben, um einen Abhängigkeitsbaum aufzubauen. Wenn eine Instanz nicht zum erwarteten Typen des Interfaces passt, wird die Prüfung des Typs zur Laufzeit des Konstruktors fehlschlagen. Dieser Fehler tritt in der composition root auf, die direkt beim Start der Anwendung durchgeführt wird. Der Fehler ist direkt beim Start sichtbar. Alternativ kann die composition root auch in einem einfachen Unit-Test überprüft werden, indem der Code ohne weitere Prüfungen ausgeführt wird. Durch dieses Testverfahren stehen in Python Interfaces zur Verfügung, die wie in anderen Programmiersprachen verwendet werden können, um die Wiederverwendbarkeit, Wartbarkeit und Stabilität von Anwendungen zu erhöhen. - the decorators of the abstract member are the same as in the interface. The complete signature of the member is checked, not just the name, as the original ABC implementation does. However, this still means that the check takes place at runtime, when the class is instantiated for the first time. To ensure that the implementation of a class matches an interface, the class must be instantiated. Therefore, it is sufficient to create a simple unit test that simply creates an instance of the class. If the unit test succeeds, the implementation of the class is consistent with the interface. The strict consistency check thus takes place at unit test time, which is much earlier than the runtime of the application and is very similar to "compile time" of normal, especially compiled, programming languages. Every function/method that is assigned a reference to the interface should use a type hint for this interface and it should use the "@typechecked" decorator to perform a runtime check of the reference. If the reference is not an instance of the interface, the check would fail at runtime. This means that only classes that implement the interface can be assigned to the argument of this function/method. However, this check only takes place at runtime, which is too late for a "compile-time-like check". Dependency injection is a pattern in which software components never directly depend on other software components, but on abstractions, especially interfaces. In addition, the instances of all dependencies are created in a single place in the application. This place is called the "composition root". Within the composition root, the dependencies are passed to the constructors of other classes to build a dependency tree. If an instance does not match the expected type of the interface, the type check at runtime of the constructor will fail. This error occurs in the composition root, which is performed directly when the application starts. The error is visible immediately at startup. Alternatively, the composition root can also be checked in a simple unit test by executing the code without further checks. This testing procedure makes interfaces available in Python, which can be used like in other programming languages to increase the reusability, maintainability and stability of applications.

Beispielsweise kann das, insbesondere getestete, Computerprogramm für Webanwendungen verwendet werden, die Künstliche-Intelligenz-Algorithmen (Kl Algorithmen) enthalten und/oder von Fachbereichen verwendet werden. Insbesondere kann das getestete Computerprogramm in einem Fahrzeug verwendet werden, beispielsweise für Webanwendungen im Fahrzeug. For example, the computer program, in particular the one tested, can be used for web applications that contain artificial intelligence algorithms (AI algorithms) and/or are used by specialist departments. In particular, the computer program tested can be used in a vehicle, for example for web applications in the vehicle.

Weiterhin kann folgendes bei der Durchführung des Verfahrens gelten: Die Art der Implementierung einer Realisierung von einem Interface entspricht einem gängigen Muster aus anderen Programmiersprachen (Ableitung vom Interface) und bedarf keiner speziellen Keywords, welche gegebenenfalls vergessen werden können. Insbesondere eine vollständige Prüfung der Eigenschaften aller abstrakten Attribute statt, so dass keine versehentliche falsche Realisierung eines Attributes stattfinden kann. Beispielsweise geschieht die Prüfung der Realisierung auf Vollständigkeit erst bei der Instanziierung, womit die Klasse nach der Definition noch zur Laufzeit erweitert werden kann, bzw. es kann von ihr noch abgeleitet werden und in der Ableitung wird dann die Vollständigkeit hergestellt. Insbesondere werden Funktionsdekoratoren als Eigenschaften mitberücksichtigt, insbesondere falls diese speziell präpariert wurden, was vor allem beim Dekorator @typechecked für eine Laufzeit-Typprüfung extrem wichtig ist. Zu beachten ist, dass das herkömmliche Konzept von Interfaces und deren Realisierung, in anderen OOP-Sprachen, insbesondere kompilierbare Programmiersprachen, immer zwischen Compilezeit und Ausführungszeit (Laufzeit) unterscheidet. Die Prüfung der Vollständigkeit einer Realisierung geschieht in diesen Programmiersprachen statisch während der Compilezeit. In Python gibt es keine Compilezeit, sondern nur die Ausführungszeit, weswegen die Prüfung zum Zeitpunkt der Instanziierung stattfindet. Dieses Problem kann jedoch durch die konsequente Verwendung des @typechecked Dakorators zusammen mit den hier genannten Interfaces umgangen werden, wenn die Klassen konsequent durch Unit-Tests und Integrations-Tests geprüft werden. In diesem Fall kann man trotz dem Nachteil der Prüfung zur Ausführungszeit anstatt zur Compilezeit eine gleiche Code-Qualität erreichen, da ein Abweichen einer Realisierung vom Interface somit sehr schnell auftritt. Hierzu reicht für jede Realisierung nur ein einziger Testcase aus. Dieser kann beispielsweise folgendermaßen programmiert werden: def test_realization(): instance = Realization() assert isinstance(instance, Interface) Furthermore, the following can apply when carrying out the procedure: The type of implementation of a realization of an interface corresponds to a common pattern from other programming languages (derivation from the interface) and does not require any special keywords, which can be forgotten if necessary. In particular, a complete check of the properties of all abstract attributes takes place so that no accidental incorrect realization of an attribute can occur. For example, the check of the realization for completeness only takes place during instantiation, which means that the class can still be extended at runtime after definition, or it can still be derived from it and completeness is then established in the derivation. In particular, function decorators are taken into account as properties, especially if they have been specially prepared, which is extremely important for a runtime type check, especially with the @typechecked decorator. It should be noted that the conventional concept of interfaces and their realization in other OOP languages, especially compilable programming languages, always distinguishes between compile time and execution time (runtime). The check of the completeness of a realization takes place statically in these programming languages during compile time. In Python there is no compile time, only execution time, which is why the check takes place at the time of instantiation. However, this problem can be avoided by consistently using the @typechecked decoder together with the interfaces mentioned here, if the classes are consistently checked by unit tests and integration tests. In this case, despite the disadvantage of checking at execution time instead of compile time, the same code quality can be achieved, since a deviation of a Realization of the interface occurs very quickly. For this, only a single test case is sufficient for each realization. This can be programmed as follows, for example: def test_realization(): instance = Realization() assert isinstance(instance, Interface)

Die erste Prüfung findet implizit statt, wenn die Klasse "Realization" instanziiert wird. Hier wird mit dem beschriebenen Konzept die Realisierung auf Vollständigkeit geprüft. Die zweite Prüfung findet danach statt und prüft, ob die instanziierte Klasse tatsächlich von dem zu erwartenden Interface abgeleitet ist. Wenn jede implementierte Klasse einen solchen Test bekommt, ist sichergestellt, dass jede Realisierung das jeweilige Interface vollständig realisiert. Die Prüfung findet also tatsächlich nicht mehr zur Laufzeit statt (wodurch Fehler erst spät auffallen), sondern bereits zum Zeitpunkt der Unit-Test. Somit erreicht Python hier die gleiche Sicherheit bei der Interface-Programmierung wie sie sonst nur von kompilierbaren OOP-Programmiersprachen bekannt sind. The first check takes place implicitly when the "Realization" class is instantiated. Here, the implementation is checked for completeness using the concept described. The second check takes place after this and checks whether the instantiated class is actually derived from the expected interface. If every implemented class receives such a test, it is ensured that every implementation fully realizes the respective interface. The check no longer actually takes place at runtime (which means that errors are only noticed later), but already at the time of the unit test. In this way, Python achieves the same level of security in interface programming as is otherwise only known from compilable OOP programming languages.

Bezugszeichenliste List of reference symbols

Klassendiagramm abstrakte Klasse, Interface Class diagram abstract class, interface

Klassenmitglied Class member

Klassenmitglied Class member

Datentyp Data type

Übergabeparameter Transfer parameters

Datentyp Data type

Datentyp erbende Klasse Data type inheriting class

Klassenmitglied Class member

Klassenmitglied Class member

Datentyp Data type

Übergabeparameter Transfer parameters

Datentyp Data type

Datentyp Data type

Claims

Patentansprüche Verfahren zum Testen eines in einer objektorientierten Skriptsprache programmierten Computerprogramms, aufweisend folgende Schritte: Patent claims Method for testing a computer program programmed in an object-oriented scripting language, comprising the following steps: Bereitstellen eines Computerprogrammteils zur Erzeugung abstrakter Klassen (2);Providing a computer program part for generating abstract classes (2); Bereitstellen wenigstens einer abstrakten Klasse (2), welche mindestens ein abstraktes Mitglied (3, 4), insbesondere nur abstrakte Mitglieder, aufweist, mittels des Computerprogrammteils; Providing at least one abstract class (2) which has at least one abstract member (3, 4), in particular only abstract members, by means of the computer program part; Bereitstellen einer von der abstrakten Klasse (2) erbenden Klasse (9), die nur nicht abstrakte Mitglieder (10, 11) aufweist; Providing a class (9) inheriting from the abstract class (2) having only non-abstract members (10, 11); Erzeugen eines von der erbenden Klasse (9) abgeleiteten Objektes, wodurch dieses eine Referenz auf die abstrakte Klasse (9) darstellt, Creating an object derived from the inheriting class (9), whereby this object represents a reference to the abstract class (9), - wobei Eigenschaften der nicht abstrakten Mitglieder (10, 11) der erbenden Klasse (9) mit den Eigenschaften der abstrakten Mitglieder (3, 4) der abstrakten Klasse (2) verglichen werden; und falls es mindestens ein abstraktes Mitglied (3, 4) der abstrakten Klasse (2) gibt für welches kein nicht abstraktes Mitglied (10, 11) der erbenden Klasse (9) mit den gleichen Eigenschaften gefunden wird, wird ein Eintrag in einer Fehlerliste erzeugt und diese dann als Fehlermeldung ausgegeben. Verfahren nach Anspruch 1 , aufweisend folgende weitere Schritte: - wherein properties of the non-abstract members (10, 11) of the inheriting class (9) are compared with the properties of the abstract members (3, 4) of the abstract class (2); and if there is at least one abstract member (3, 4) of the abstract class (2) for which no non-abstract member (10, 11) of the inheriting class (9) with the same properties is found, an entry is created in an error list and this is then output as an error message. Method according to claim 1, comprising the following further steps: Überprüfen bei allen von einer Softwarekomponente des Computerprogramms referenzierten Objekten, ob das jeweilige referenzierte Objekt eine Referenz auf die zugehörige abstrakte Klasse (2) darstellt; und falls wenigstens ein überprüftes von einer Softwarekomponente referenzielles Objekt nicht die Referenz auf die zugehörige Klasse (2) darstellt, wird eine weitere Fehlermeldung ausgegeben. Verfahren nach Anspruch 1 oder 2, wobei folgende Eigenschaften verglichen werden: Checking all objects referenced by a software component of the computer program to see whether the respective referenced object represents a reference to the associated abstract class (2); and if at least one checked object referenced by a software component does not represent the reference to the associated class (2), a further error message is output. Method according to claim 1 or 2, wherein the following properties are compared: Namen der Mitglieder (3, 4, 10, 11), Names of members (3, 4, 10, 11), Typ und Datentyp (5, 12) des jeweiligen Mitgliedes (3, 4, 10 ,11), und Type and data type (5, 12) of the respective member (3, 4, 10 ,11), and - Argumente (6, 13) des jeweiligen Mitgliedes (4, 11), und - Arguments (6, 13) of the respective member (4, 11), and Datentyp (7, 14) des jeweiligen Arguments (6, 13) des Mitglieds (4, 11), und Datentyp (8, 15) eines Rückgabewertes, Verfahren nach einem der vorhergehenden Ansprüche, wobei zu jeder erbenden Klasse (9) des Computerprogramms ein Objekt vor Durchführen eines Hauptteils des Computerprogramms erzeugt wird und überprüft wird, ob die jeweilige Erzeugung erfolgreich ist. Verfahren nach einem der vorhergehenden Ansprüche, wobei alle Softwarekomponenten des Computerprogrammes, insbesondere nur, von abstrakten Klassen (2) abhängig sind, wobei Abhängigkeiten der Softwarekomponenten, insbesondere solche, die von den abstrakten Klassen (2) erben, zentral erzeugt und übergeben werden. Verfahren nach einem der vorhergehenden Ansprüche, wobei das Computerprogramm in einer Python Programmiersprache programmiert und getestet wird. Verfahren zum Ausführen eines Computerprogramms, bei welchem ein Testen des Computerprogramms vor einer Ausführung eines Hauptteils des Computerprogramms nach einem der vorhergehenden Ansprüche 1 bis 6 durchgeführt wird, und falls ein Eintrag in die Fehlerliste erfolgt oder eine Fehlermeldung ausgegeben wird, das Ausführen des Hauptteils verhindert wird, und falls kein Eintrag in die Fehlerliste erfolgt oder eine Fehlermeldung ausgegeben wird, der Hauptteil des Computerprogramms, insbesondere automatisch, gestartet wird, und/oder das Verfahren nach einem der vorhergehenden Ansprüche 1 bis 6 bei einem bereits gestarteten Ausführen des Hauptteils zumindest einmal durchgeführt wird, insbesondere dann durchgeführt wird, wenn ein von einer erbenden Klasse (9) abgeleitetes Objekt erzeugt wird. System zur Durchführung eines Verfahrens, aufweisend Mittel zur Ausführung der Schritte des Verfahrens nach einem der vorhergehenden Ansprüchen. Computerprogramm, welches nach einem Verfahren nach einem der Ansprüche nach 1 bis 6 getestet ist und in eine Speichereinheit ladbar ist und durch einen Prozessor ausführbar ist. Computerlesbares Speichermedium, aufweisend Befehle, die bei der Ausführung durch einen Computer diesen veranlassen, die Schritte des Verfahrens nach einem der Ansprüche 1 bis 7 auszuführen. Data type (7, 14) of the respective argument (6, 13) of the member (4, 11), and data type (8, 15) of a return value, Method according to one of the preceding claims, wherein an object is created for each inheriting class (9) of the computer program before executing a main part of the computer program and it is checked whether the respective creation is successful. Method according to one of the preceding claims, wherein all software components of the computer program, in particular only, are dependent on abstract classes (2), wherein dependencies of the software components, in particular those that inherit from the abstract classes (2), are created and transferred centrally. Method according to one of the preceding claims, wherein the computer program is programmed and tested in a Python programming language. Method for executing a computer program, in which testing of the computer program is carried out before executing a main part of the computer program according to one of the preceding claims 1 to 6, and if an entry is made in the error list or an error message is output, the execution of the main part is prevented, and if no entry is made in the error list or an error message is output, the main part of the computer program is started, in particular automatically, and/or the method according to one of the preceding claims 1 to 6 is carried out at least once when execution of the main part has already started, in particular when an object derived from an inheriting class (9) is created. System for carrying out a method, comprising means for carrying out the steps of the method according to one of the preceding claims. Computer program which is tested according to a method according to one of the claims 1 to 6 and can be loaded into a memory unit and can be executed by a processor. A computer-readable storage medium comprising instructions which, when executed by a computer, cause the computer to carry out the steps of the method according to any one of claims 1 to 7.
PCT/EP2023/078431 2022-10-24 2023-10-12 Method for testing a computer program programmed in an object-oriented scripting language, and system, computer program and computer-readable storage medium Ceased WO2024088781A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
EP23790262.2A EP4609292A1 (en) 2022-10-24 2023-10-12 Method for testing a computer program programmed in an object-oriented scripting language, and system, computer program and computer-readable storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
DE102022211270.9 2022-10-24
DE102022211270.9A DE102022211270A1 (en) 2022-10-24 2022-10-24 Method for testing a computer program programmed in an object-oriented scripting language, as well as system, computer program and computer-readable storage medium

Publications (1)

Publication Number Publication Date
WO2024088781A1 true WO2024088781A1 (en) 2024-05-02

Family

ID=88417011

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/EP2023/078431 Ceased WO2024088781A1 (en) 2022-10-24 2023-10-12 Method for testing a computer program programmed in an object-oriented scripting language, and system, computer program and computer-readable storage medium

Country Status (3)

Country Link
EP (1) EP4609292A1 (en)
DE (1) DE102022211270A1 (en)
WO (1) WO2024088781A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118642969A (en) * 2024-08-13 2024-09-13 杭州亚信云信息科技有限公司 A method, device and equipment for detecting domain model quality based on class diagram

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070256055A1 (en) * 2004-11-19 2007-11-01 Adrian Herscu Method for building component-software for execution in a standards-compliant programming environment
US7536679B1 (en) * 2004-08-18 2009-05-19 Sun Microsystems, Inc. System and methods for test tool class inheritance

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7536679B1 (en) * 2004-08-18 2009-05-19 Sun Microsystems, Inc. System and methods for test tool class inheritance
US20070256055A1 (en) * 2004-11-19 2007-11-01 Adrian Herscu Method for building component-software for execution in a standards-compliant programming environment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118642969A (en) * 2024-08-13 2024-09-13 杭州亚信云信息科技有限公司 A method, device and equipment for detecting domain model quality based on class diagram

Also Published As

Publication number Publication date
EP4609292A1 (en) 2025-09-03
DE102022211270A1 (en) 2024-04-25

Similar Documents

Publication Publication Date Title
DE69621381T2 (en) Method and device for internal versioning of objects using a file
DE69625636T2 (en) System and method for controlling and managing distributed object servers using first class distributed objects
DE69230578T2 (en) Language neutral objects
DE69627926T2 (en) Method and device for creating and installing distributed objects on a distributed object system
DE69525706T2 (en) Apparatus and method for generating the target language code using an object-oriented code generator
DE69932371T2 (en) Movable instrumentation tags for testing and troubleshooting a computer program
DE69621494T2 (en) Distributed debugger apparatus and method for debugging distributed application programs
EP0674784A1 (en) METHOD FOR TESTING AT LEAST ONE CLASS OF AN OBJECT-ORIENTED PROGRAM ON A COMPUTER.
DE112011103406T5 (en) Management of unmodified objects
EP3770766A1 (en) Method for testing a system
DE102022214443A1 (en) METHODS, SYSTEMS, AND COMPUTER READABLE MEDIA FOR ADAPTING DATA PLANE PIPELINE PROCESSING USING BERKELEY PACKET FILTER (BPF) HOOK ENTRY POINTS
DE112017003052B4 (en) Control system with a distributed service-oriented architecture
EP4609292A1 (en) Method for testing a computer program programmed in an object-oriented scripting language, and system, computer program and computer-readable storage medium
EP1723513A1 (en) Method for configuring a computer program
DE69328664T2 (en) Method and arrangement for connecting objects
DE102004025264A1 (en) Data processing device and method for restoring an operating state
EP1904923A1 (en) Method and software system for the configuration of a modular system
DE102024201069A1 (en) Method for testing a computer program programmed in an object-oriented scripting language, as well as system, computer program and computer-readable storage medium
DE102008048862A1 (en) Test module and method for testing an O / R imaging middleware
EP0662226B1 (en) Method of processing an application program on a parallel-computer system
EP1343078B1 (en) Modelling system and generation of software generating systems
DE102020213809A1 (en) Method for operating a control device when testing software in the control device and method for operating a test computer when testing software in a control device
DE102022208030A1 (en) Method for collaboratively creating a software product and method for responding to an error
DE102009038177B4 (en) Tracing in a running computer system
EP0996888B1 (en) Method and data processing system for testing an assembler program for transferability

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23790262

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2023790262

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2023790262

Country of ref document: EP

Effective date: 20250526

WWP Wipo information: published in national office

Ref document number: 2023790262

Country of ref document: EP