简体   繁体   中英

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

I have figured the OOPS deign something like this

EventManager has Two Objects, EventReader and EventScheduler

The EventReader reads the data from the text input file and gives back an array of Objects of type Event.

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).

Inside the EventScheduler, I have kept methods which sorts and then arranges the Events as per the desired output.

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. Reader needs to read and prepare event. Scheduler needs to get event and schedule it for processing. And yes should be loosely coupled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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