Hi,
I am currently working on assignment 5 (I know I'm a bit late, but anyways...) and I have no idea where to put responsibilty for the event extraction function. My design is (partially) the following:
The classes Skip, Assign, FunctionCall extend the class Statement and BooleanExp is a class independent of that. So I can't have a "superclass" where I could put some responsibilty for the event extraction function - also this wouldn't make sense, since Sequence/If/While are Statements that do not use the event extraction.
The event extraction function needs to know which concrete event is present, to decide which abstract events result. So how to design this in Java nicely? When I think about a "computeEventList()" method in Skip/Assign/FunctionCall/BooleanExp, it has to contain a "switch" statement to decide which rule is considered 4 times, which is rather ugly. Another possibilty would be an EventExtractor class, which has subclasses that implement a specialized function for each rule. But inside this EventExtractor I would have to check the type dynamically, to decide what concrete event is present, which I also find is not a nice design.
Do you understand my problem? How did you solve this? (I hope this question is abstract enough to discuss, without talking about the solution to the event extraction function itself)
design problem: event extraction function
Moderator: Secure Coding Lab
-
- Mausschubser
- Beiträge: 49
- Registriert: 28. Sep 2009 11:39
Re: design problem: event extraction function
Beitrag von DanielSchoepe »
That's how I solved it. Generally, I think that there's no solution for representing "sum types" (such as the one for the various alternatives for statements or expressions) in Java that's even remotely as nice as algebraic data types in ML-like languages. One either has to introduce a lot of superfluous complexity via design patterns including all the boilerplate they usually need, or use nested ifs that check the type dynamically with instanceof. There's no obvious winner here, in my opinion, although my dislike for design patterns may be somewhat uncommon. If you don't share that dislike, I think this issue can be handled by the Visitor pattern though.nt4u hat geschrieben: Another possibilty would be an EventExtractor class, which has subclasses that implement a specialized function for each rule. But inside this EventExtractor I would have to check the type dynamically, to decide what concrete event is present, which I also find is not a nice design.
For this reason I stopped to care that much about the structural elegance of my code, since I think that many of the concepts we discussed cannot be implemented very nicely in Java anyway. (Being allowed to use some ML- or Lisp-like language would have made this a lot nicer, but I suppose regretting this does nothing except making the whole thing more painful

Gehe zu Forum
- Allgemeines
- ↳ Neuigkeiten
- ↳ Ankündigungen
- ↳ Studienberatung
- ↳ Aktive Fachschaft
- ↳ Allgemein
- ↳ Forumsanregungen
- ↳ Inforz
- ↳ Das Wesentliche
- ↳ Vor dem Studium
- ↳ Studieninteressierte
- ↳ Vorkurs
- ↳ Archiv
- ↳ Ophase
- ↳ Archiv
- ↳ Studium
- ↳ Allgemein
- ↳ Ausland
- ↳ Bachelorpraktikum
- ↳ Archiv
- ↳ RBG/Rechner
- ↳ Studienorganisation
- ↳ Teilzeitstudium
- ↳ Angebote
- ↳ Abschlussarbeiten
- ↳ Jobs
- ↳ Umfragen
- ↳ Veranstaltungen
- ↳ Sonstiges
- ↳ GnoM
- ↳ RPGnoM
- ↳ Offtopic
- ↳ TU Darmstadt Programming-Contest
- ↳ CrypTool
- ↳ Suche / Biete
- ↳ Archiv
- Pflichtveranstaltungen
- ↳ Grundstudium
- ↳ Aussagen- und Prädikatenlogik
- ↳ Archiv
- ↳ Algorithmen und Datenstrukturen
- ↳ AuD: Vorlesung
- ↳ Archiv
- ↳ AuD: Theoretische Aufgaben
- ↳ Archiv
- ↳ AuD: Arbeit mit Nabla
- ↳ Archiv
- ↳ AuD: Programmieraufgaben
- ↳ Archiv
- ↳ AuD: Rund um die Klausur
- ↳ Archiv
- ↳ Automaten, formale Sprachen und Entscheidbarkeit
- ↳ Archiv
- ↳ Betriebssysteme
- ↳ Archiv
- ↳ Digitaltechnik
- ↳ Archiv
- ↳ Einführung in den Compilerbau
- ↳ Archiv
- ↳ Funktionale und Objektorientierte Programmierkonzepte
- ↳ Archiv
- ↳ GdI 1: Vorlesung
- ↳ Archiv
- ↳ GdI 1: Übung
- ↳ Archiv
- ↳ GdI 1: Praktikum
- ↳ Archiv
- ↳ Mathematik für Informatik 1
- ↳ Archiv
- ↳ Mathematik für Informatik 2
- ↳ Archiv
- ↳ Mathematik für Informatik 3
- ↳ Archiv
- ↳ Rechnerorganisation
- ↳ Archiv
- ↳ Systemnahe und parallele Programmierung
- ↳ Archiv
- ↳ Weiterführende Pflichtveranstaltungen
- ↳ Architekturen und Entwurf von Rechnersystemen
- ↳ Archiv
- ↳ Computational Engineering und Robotik
- ↳ Archiv
- ↳ Computer-Netzwerke und verteilte Systeme
- ↳ Archiv
- ↳ Computersystemsicherheit
- ↳ Archiv
- ↳ Informationsmanagement
- ↳ Archiv
- ↳ Modellierung, Spezifikation und Semantik
- ↳ Archiv
- ↳ Software Engineering
- ↳ Archiv
- ↳ Visual Computing
- ↳ Archiv
- ↳ Nicht mehr angeboten
- ↳ FGdI 3
- ↳ Archiv
- ↳ GdI 3
- ↳ GdI 3: Vorlesung
- ↳ Archiv
- ↳ GdI 3: Übung
- ↳ Archiv
- ↳ GdI 3: Praktikum
- ↳ Archiv
- ↳ TGdI
- ↳ Archiv
- ↳ TGdI 1
- ↳ Archiv
- ↳ TGdI 2
- ↳ Archiv
- Wahlbereich
- ↳ IT-Sicherheit
- ↳ Einführung in die Kryptographie
- ↳ Archiv
- ↳ Elektronische Wahlen
- ↳ Embedded System Security
- ↳ Formal Methods for Information Security
- ↳ Archiv
- ↳ Forschungskurs "Angewandte Kryptographie"
- ↳ IT-Sicherheit
- ↳ Archiv
- ↳ IT-Sicherheits-Management
- ↳ Kryptographische Protokolle
- ↳ Multimedia Security
- ↳ Netzsicherheit
- ↳ Operating Systems
- ↳ Archiv
- ↳ Operating Systems II: Dependability and Trust
- ↳ Archiv
- ↳ Post-Quantum Cryptography
- ↳ Praktikum: CAPTCHAs
- ↳ Praktikum: Kryptographie
- ↳ Praktikum: Sichere Informationssysteme
- ↳ Praktikum: Smartphone-Sicherheit für Android Applikationen
- ↳ Praktikum in der Lehre: Informatik Ferienworkshop
- ↳ Privacy Enhancing Technologies
- ↳ Public Key Infrastrukturen
- ↳ Archiv
- ↳ Public Key Kryptoanalyse
- ↳ Archiv
- ↳ Quantenalgorithmen
- ↳ Secure, Trusted and Trustworthy Computing, Teil 1
- ↳ Seminar: PhD Seminar ITS
- ↳ Seminar: Post Quantum Kryptographie
- ↳ Seminar: Sicherheit in Car2Car-Kommunikation
- ↳ Seminar: Usable Security
- ↳ Verfahren zur automatischen Verifikation
- ↳ Netze und Verteilte Systeme
- ↳ Kommunikationsnetze 1
- ↳ Kommunikationsnetze 2
- ↳ Kommunikationsnetze 3: Mobilität in Netzen
- ↳ Archiv
- ↳ Peer-to-Peer und Grid Computing
- ↳ Archiv
- ↳ Peer-to-Peer II - Methods
- ↳ Archiv
- ↳ Praktikum: Internet
- ↳ Praktikum: Kommunikation in Peer-to-Peer-Netzen
- ↳ Praktikum: Peer-to-Peer-Middleware
- ↳ TK1: Rechnernetze, Verteilte Systeme und Algorithmen
- ↳ Archiv
- ↳ TK2: Web Engineering, Web Cooperation und E-Learning
- ↳ TK3: Ubiquitous / Mobile Computing
- ↳ Ubiquitous Computing in Geschäftsprozessen
- ↳ Robotik, Computational und Computer Engineering
- ↳ Algorithmen im Chip-Entwurf
- ↳ Archiv
- ↳ Compiler 1
- ↳ Archiv
- ↳ Compiler 2
- ↳ Archiv
- ↳ Echtzeitsysteme
- ↳ Eingebettete Systeme 1
- ↳ Eingebettete Systeme 2
- ↳ Geometrische Methoden des CAD/CAE
- ↳ Grundlagen der Robotik
- ↳ Hardwaremodellierungssprachen
- ↳ Lernende Roboter
- ↳ Mainframe Technologie
- ↳ Optimierende Compiler
- ↳ Archiv
- ↳ Optimierung statischer und dynamischer Systeme
- ↳ Archiv
- ↳ Praktikum: Adaptive Computersysteme
- ↳ Praktikum: Embedded Systems Hands-On 1
- ↳ Prozessorarchitekturen für rechenstarke eingebettete Systeme
- ↳ Archiv
- ↳ Rekonfigurierbare Prozessoren
- ↳ Seminar: Dynamisch und partiell rekonfigurierbare Architekturen
- ↳ Software-Systeme und formale Grundlagen
- ↳ Algorithmische Modellierung
- ↳ Applied Static Analysis
- ↳ Automated Code Analysis for Large Software Systems
- ↳ Automated Software Engineering
- ↳ Automated Theorem Proving
- ↳ Berechenbarkeitstheorie
- ↳ Archiv
- ↳ Concepts and Technologies for Distributed Systems and Big Data Processing
- ↳ Archiv
- ↳ Design and Implementation of Modern Programming Languages
- ↳ Designing code analyses for large software systems (DECA)
- ↳ Effiziente Graphenalgorithmen
- ↳ Enterprise Application Design
- ↳ Archiv
- ↳ Grundlagen des KI Planens
- ↳ Implementing code analyses for large software systems (ICA)
- ↳ Konzepte der Programmiersprachen
- ↳ Archiv
- ↳ Modellierungspraktikum
- ↳ Optimierungsalgorithmen
- ↳ Praktikum: Algorithmen
- ↳ Praktikum: Proof-Carrying-Code
- ↳ Archiv
- ↳ Programmanalyse und Transformation
- ↳ Secure Coding Lab
- ↳ Secure Software Development (SecDev)
- ↳ Seminar: Current Topics in Information Flow Security
- ↳ Seminar: Current Topics in Usage Control
- ↳ Seminar: Formale Spezifikation
- ↳ Seminar: Proof-Carrying-Code
- ↳ Archiv
- ↳ Seminar: Reading Group Runtime Monitoring
- ↳ Seminar: Reliable Security for Concurrent Programs
- ↳ Seminar: Softwaresystemtechnologien
- ↳ Software Engineering - Design and Construction
- ↳ Archiv
- ↳ Software Engineering - Projekt
- ↳ Archiv
- ↳ Software Engineering - Projektmanagement
- ↳ Software Engineering - Requirements
- ↳ Software Engineering - Wartung und Qualitätssicherung
- ↳ Archiv
- ↳ Software Engineering in industrial practice
- ↳ Archiv
- ↳ Static and Dynamic Program Analysis
- ↳ Archiv
- ↳ Technikgestaltung
- ↳ Type Systems of Programming Languages
- ↳ Web Services Technologien: Einführung, Komposition und Erweiterungen
- ↳ Visual & Interactive Computing
- ↳ Advanced Programming Techniques in Computer Vision
- ↳ Bildverarbeitung
- ↳ Capturing Reality
- ↳ Computer Vision
- ↳ Computer Vision 2
- ↳ Context-Awareness
- ↳ Einführung in die Computermusik
- ↳ Game Technology
- ↳ Archiv
- ↳ Geometric Algebra Computing
- ↳ Archiv
- ↳ Graphische Datenverarbeitung 1
- ↳ Archiv
- ↳ Graphische Datenverarbeitung 2
- ↳ Archiv
- ↳ Graphische Informationssysteme
- ↳ Informationsvisualisierung und Visual Analytics
- ↳ IT-Management und IT-Einsatz
- ↳ Probabilistische Graphische Modelle
- ↳ Programming Massively Parallel Processors
- ↳ Archiv
- ↳ Seminar: Probleme in Computergraphik und Computer Vision
- ↳ Statistisches Maschinelles Lernen
- ↳ Serious Games
- ↳ Archiv
- ↳ Virtual and Augmented Reality
- ↳ Archiv
- ↳ Web, Wissens- und Informationsverarbeitung
- ↳ Algorithms of Language Technology
- ↳ Business Intelligence and Data Warehousing
- ↳ Datenbanken 2
- ↳ Data Mining und Maschinelles Lernen
- ↳ Archiv
- ↳ Digitale Spiele / Digital Games
- ↳ Einführung in die Künstliche Intelligenz
- ↳ Innovative Operating System Elements
- ↳ Middleware
- ↳ Natural Language Processing and the Web
- ↳ Praktikum: Data-Mining
- ↳ Praktikum: Künstliche Intelligenz
- ↳ Praktikum: Question Answering Technologies Behind IBM Watson
- ↳ Semantic Web
- ↳ Seminar: Deep Learning for NLP and Speech
- ↳ Seminar: Knowledge Management in Web 2.0
- ↳ Web Mining
- ↳ Fachübergreifender Anteil
- ↳ Einführung in wissenschaftliches Arbeiten
- ↳ Archiv
- ↳ Nicht mehr angeboten
- ↳ Digital Storytelling
- ↳ Graphische Datenverarbeitung 3
- ↳ Archiv
- ↳ Grundlagen der Rechnertechnologie
- ↳ Grundlagen des CAE/CAD 2
- ↳ Mobile sichere Systeme
- ↳ Netzwerksicherheit
- ↳ Praktikum: Spielerische Edutainment-Anwendungen / Game Technology
- ↳ Archiv
- ↳ Rechnerarchitektur
- ↳ Rechnerentwurf und Mikroprogrammierung
- ↳ Archiv
- ↳ Robotik 0: Mobile und sensorgeführte Robotiksysteme
- ↳ Robotik 1: Grundlagen
- ↳ Archiv
- ↳ Robotik 2: Mobilität und Autonomie
- ↳ Archiv
- ↳ Seminar: Rechnerarchitektur
- ↳ Systementwurf mit Mikroprozessoren
- ↳ Archiv
- ↳ Seminar: Digital Storytelling
- ↳ Archiv
- Masterstudium
- ↳ Neben- und Anwendungsfächer
- ↳ Archiv
- ↳ Spezialisierungsmaster
- ↳ Abschlussarbeiten
- ↳ Studienorganisation
- Serviceveranstaltungen
- ↳ AI 1
- ↳ Archiv
- ↳ AI 2
- ↳ Archiv
- ↳ AI 3
- ↳ Archiv