简体   繁体   English

使用Java设计阅读器和处理器

[英]Designing A reader and Processor using Java

I am writing a Core java module, where in there, there are events which are read and then those read events are needed to be organized into some form 我正在编写一个Core java模块,其中有一些要读取的事件,然后需要将这些读取的事件组织成某种形式

I have figured the OOPS deign something like this 我发现OOPS就是这样的

EventManager has Two Objects, EventReader and EventScheduler EventManager有两个对象,EventReader和EventScheduler

The EventReader reads the data from the text input file and gives back an array of Objects of type Event. EventReader从文本输入文件读取数据,并返回事件类型的Object数组。

The EventScheduler takes in as input the Event array object and processes them (including sorting the array as per its convince, then arrange them as using (KnapSackProblem) according to some criteria). EventScheduler接受Event数组对象作为输入并对其进行处理(包括按照其置信度对数组进行排序,然后根据某些条件使用(KnapSackProblem)对其进行排列)。

Inside the EventScheduler, I have kept methods which sorts and then arranges the Events as per the desired output. 在EventScheduler内部,我保留了一些方法,这些方法可以根据所需的输出对事件进行排序,然后进行排列。

So Is this design High Cohesion and Loose Coupling.. Threotically atleast.. Since I cannot share the entire diagram on the site. 因此,这种设计是否具有高内聚力和松散耦合性。

I need a good design and wanted to know what is the correct design for this scenario. 我需要一个好的设计,并且想知道什么是此方案的正确设计。

Kindly let me know if you need more design information in this regards to understand the scenario more. 请让我知道您是否在这方面需要更多的设计信息,以便更多地了解该场景。

Just a note, I am actually not aiming at improving the performance, but only a very clean design concept for such a scenario. 仅需注意,我实际上并非旨在提高性能,而只是针对这种情况的非常简洁的设计概念。

Any Help is most welcome! 任何帮助都是最欢迎的!

Thanks in Advance :) Cheers 在此先感谢:)干杯

This is just another sample of solving Producer/Consumer problem of Distributed Programming. 这只是解决分布式编程的生产者/消费者问题的另一个示例。

I was thinking if we can solve your event reading and processing sequentially but then I realize that your text input may change while time flows. 我在想是否可以按顺序解决您的事件读取和处理问题,但后来我意识到您的文本输入可能会随着时间的流逝而发生变化。 That means you need to read new inputs also. 这意味着您还需要阅读新的输入。

Here you need to figure out EventReader and EventScheduler are different processors. 在这里,您需要确定EventReader和EventScheduler是不同的处理器。 Reader needs to read and prepare event. 读者需要阅读并准备活动。 Scheduler needs to get event and schedule it for processing. 调度程序需要获取事件并将其调度以进行处理。 And yes should be loosely coupled. 是的,应该松耦合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM