Needing help with my first software engineering project (Hospital vital simulator)
208 Replies
⌛
This post has been reserved for your question.
Hey @springbean! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
I am happy to break it down:
1.
git checkout -b my-master master
- Preserve the changes you pushed to master in a new branch called my-master
2. git branch -D master
With my-master
checked out, delete your local master
because it is about to be replaced by the upstream master
3. git remote add upstream https://github.com/tpepels/signal_project.git
Add a new remote called upstream
to your local repo that refers to the prof's repo.
4. git checkout -t upstream/master
- Checkout the clean master
branch from upstreamUnknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
omg I was late to the party
I wanna pitch in whats happening
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
hmm they made classes? I think you sent a github repo imma check it out
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
also I was thinking although ive never tried it myself there should be subsystems for projects like these, making smaller subsytems and creating jars for them to use and then combining them all together sort of like references APIs
its a pretty big project fs fs
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah so its like the final stretch I getcha
Im thinking of forking and putting up pull requests for changes I make, that fine or do they expect this to be a one person project?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
ok ok sounds good then
adding on to this, you can make a complete utility class for this using generics to make it so that you can essentially use it for any type
shouldnt most of the classes like
Person
just be POJOsUnknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
icwym yeah I suppose making POJOs for them using a library wouldnt be effective
ok looking into the code rn brb
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
I though DataStorage would be storing the Patients you create into a table somewhere in a db but it looks like its just storing into a HashMap right?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
what about the patient class is confusing
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yep following the constructor
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
you have to use the addRecord
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yep
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View

Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah naturally that would do
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
wouldnt IOExceptions be unchecked? I feel as if they occur when running the program so you cant use
throws
right? It would make sense to try catch if you expect them to occurUnknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
sounds good sounds good
not really Patient.PatientRecords more like creating a patient object that will have a punch of patient records and you iterate through it and in order to do that you provide a start time and an end time.
the start time and end time is going to filter out all records that dont fit within that specific range and provide you a list of
PatientRecord
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
my first guess is to use streams
ill implement something hold up
I wont lie I think a little JUnit testing for single classes might be up for consideration
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
like creating some tests to see that the individual parts are working as intended in the program
alot more work tbf
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
oh ok that should be the easiest part
unless ofc we are testing for all cases
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
ah
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
streams are hardly covered in Java in general but they are really easy to read
I think it just looks shit above because its so big
but basically its filtering the List
where the range is between the startTime and the endTime for the timestamp of each record in patientRecords
collecting them and then converting it to a list to return
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
well for streams is basically just simplifying processing of collections (like list, arraylist, etc) and seqs of data.
I come from C# and in C# we use something like LINQ its very expressive and nice to have as it allows you to filter out data to get what you want
Streams is basically filtering out the data, based on a query and some limits and then returning whatever fits them
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
theres a whole guide on the most common methods used
lemme send them
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
probably because it doesnt exist
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
hmm
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
try this then
does it work?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
Eugen Paraschiv
Stackify
A Guide to Java Streams in Java 8 - Stackify
Java streams were a much anticipated Java feature. Learn how to use the supported operations to write cleaner and more concise code.
this should help although I dont know why the above stream isnt working for you
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
damn I just came back from the doctors
anyway what I miss
well yeah its an API that esentially helps with filtering data or processing it in a certain way
that along side a couple other things. Streams are mostly a functional paradigm concept so they us functional interfaces alongside other things
I can say for sure that streams make it 10x easier then using a for loop or any loop
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
@Override
i've started experimenting with streams
This message has been formatted automatically. You can disable this using
/preferences
.Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
ok looking into this code it takes in 2 params being
dataStorage
and filePath
but you dont actually use the first param anywhere within the code. You create a new DataStorage object and then do your usual guard clausing to check for nulls and what not when it can be done first and foremost
this is most likely an import issue, you might have either forgot to import (if you dont have it setup) or there might be another class that is exactly named thisUnknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
guard clausing is a technique that you used when you were checking wether the string is empty or null
think of it like a preliminary check for each of the parameters BEFORE the function uses them or needs them to do some task
Replace Nested Conditional with Guard Clauses
Problem: You have a group of nested conditionals and it’s hard to determine the normal flow of code execution.
Solution: Isolate all special checks and edge cases into separate clauses and place them before the main checks. Ideally, you should have a “flat” list of conditionals, one after the other.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yes you are already doing it but its best practice to start with it first and foremost without creating any objects or manipulating any data
yes which makes is kinda useless to create a new DataStorage object and use that when you can use the parameter provided
there are some ways I can think of but it might take me some time to write it out lemme get to it
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah that for the most part is fine there is nothing wrong with that but I believe the code for your stream could be simplified
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
came up with something like this
for this its not necessary to have
instanceof
and can be removed
yeah sure whats the issue with the alert generator?Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
its definitely not the way to setup a OOP oriented project I can understand that
package com.alerts;
import com.data_management.DataStorage;
import com.data_management.Patient;
/ ```java
* The {@code AlertGenerator} class is responsible for monitoring patient data
* and generating alerts when certain predefined conditions are met. This class
* relies on a {@link DataStorage} instance to access patient data and evaluate
* it against specific health criteria.
*/
public class AlertGenerator {
private DataStorage dataStorage;
/
* Constructs an {@code AlertGenerator} with a specified {@code DataStorage}.
* The {@code DataStorage} is used to retrieve patient data that this class
* will monitor and evaluate.
*
* @param dataStorage the data storage system that provides access to patient
* data
*/
public AlertGenerator(DataStorage dataStorage) {
this.dataStorage = dataStorage;
}
/
* Evaluates the specified patient's data to determine if any alert conditions
* are met. If a condition is met, an alert is triggered via the
* {@link #triggerAlert}
* method. This method should define the specific conditions under which an
* alert
* will be triggered.
*
* @param patient the patient data to evaluate for alert conditions
*/
public void evaluateData(Patient patient) {
// Implementation goes here
}
/
* Triggers an alert for the monitoring system. This method can be extended to
* notify medical staff, log the alert, or perform other actions. The method
* currently assumes that the alert information is fully formed when passed as
* an argument.
*
* @param alert the alert object containing details about the alert condition
*/
private void triggerAlert(Alert alert) {
// Implementation might involve logging the alert or notifying staff
}
} ```
This message has been formatted automatically. You can disable this using
/preferences
.Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
ok those are requirements that can be put into their own functions
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
I feel as if there are better ways to do this but the moving window would work the best for this situation. However you could also go ahead and use the Observer pattern with a few modifications where you would subscribe to an object holding the data you mentioned prior and if there are any changes it will notify all subscribers.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah sure so for the Observer pattern you would need a manager, a concrete publisher class which will publish at an interval (say every 5 seconds there could be a thread.sleep()) and subscribers which will be checking for requirements being the following:
heart rate drops or spikes
blood saturation below a certain threshold
etc
this guide is the best from refactoring guru: https://refactoring.guru/design-patterns/observer/java/example
Observer in Java / Design Patterns
Observer pattern in Java. Full code example in Java with detailed comments and explanation. Observer is a behavioral design pattern that allows some objects to notify other objects about changes in their state.
the manager is responsible for notifying every subscriber
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
ok sounds good lemme know how it goes
basically one object subscribes to the change of state of another object
in this case it would be the AlertGenerator subscribed to any changes in data within the DataStorage?
you would need a manager instance most likely a single instance so using a Singleton would work
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
from there it will orchestrate the subscriptions and manage them basically
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah just another class for managing everything
I was thinking it would be better to have a hashmap or some data structure that stores thresholds
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah the name is arbitrary it doesnt really matter the name
but thats the way to go about it
it would look something like this:

with some modifications based on your needs
this reference gives more details on the implementation: https://github.com/ZanXusV/java-design-patterns/blob/master/observer-pattern/observer-design-pattern.md
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah basically thats the intention, the naming for it is kinda odd it should be ConcreteManager but it works
nw nw
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
I feel like this is the peak of a sigmoid curve for the difficulty of this project
I do love a challenge but its most likely going to get easier from here
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
I wish I could help out a bit more practically other than yapping but yeah its a good learning exercise fs fs
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
ask away
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
but?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
well my current understanding was looking at it this way
with what we have right now, I was thinking it would be better to make PatientRecord an actual record since its easier to work with, and provide some internal methods to datastorage and alertgenerator
the EventManager (Manager in this case) would be responsible for handling instances of DataStorage (which usually for something to publish there should be a topic it publishes data to) and instances for AlertGenerator (which usually for something to subscribe it would need a topic to subscribe to)
the manager class for now could be responsible for sending it back and forth
and then if there are any changes of data then it would notify its subscribers
for now this is a good rough layout before polishing everything
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
PatientRecord is a class with but if made into a record it would reduce the boilerplate, its not a necessity but it will make it easier
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
making those changes will save you the hassle of writing too much boilerplate
but this is a distraction from the implementation that needs to be done right now
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah and depending on how many instances you require it would make it more streamlined and easier to manage
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
its only dependent on the implementation, but I believe this design pattern is pretty sound proof
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
sounds good lemme know how it goes
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
honestly you might wanna give a bit of a synopsys of what's up at the moment since if anyone else would spring up to try and help I doubt they would wanna read over 900 messages
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
what is causing you headaches with the observer pattern?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah sure wsp
I feel like working with your teachers template is giving all the more headaches
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
what are the erros are they syntax wise or is there a stack trace to refer from?
we can work from there
wouldnt blame you, do you have to follow your teachers template?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
oh these errors are just from your Subject interface
you havent implemented some methods
just implement the methods from interface Subject
you can generate them by clicking alt+enter I believe
yeah that would work
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
try rebuilding your project
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
ok so for the args its just a @param so you can remove that
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah the error for args is nothing
have you overriden all of these methods?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
hmm it might not mean much but you can try rebuilding it
I only see DataProcessor.Observer
you have overloaded functions which take 2 different types of Observer
they are from different packages
which is hella confusing by the way
not to mention that the DataStorage on the first method of the interface is called Observer
this interface is incredibly messy
another thing to note your github repo isnt up to date with the latest changes youve made, after this probably push so its easier to view the full code
yeah I was also gonna say that
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
just take it slow
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
first of all why do you need two different types of Observers?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
I am not sure if I understand what you are trying to do
Okay, can you send me the code for your observer
and tell me what that Observer is supposed to be doing
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
package com.data_management;
import java.util.List;
This message has been formatted automatically. You can disable this using
/preferences
.Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
I believe you may be misunderstanding what the purpose of the Observer is supposed to be
okay, which classes implement the Observer interface?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
can you send me the code for one of these classes? For example the heart monitor
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
Okay here's a thing though
there is no point to be doing that in the Observer itself
Actually which is the class that notifies the Observers?
From what I can see it's the DataStorage class
how about this: Make all the necessary checks for all the patient information such as heart beat, blood pressure and such
if there is an abnormality that needs to be handled update the observers with that particular Patient object instead of passing the list with all the Patient objects
you can also add logic to indicate exactly what is wrong with this Patient
it can be some sort of int that holds flags as bits or if you want to make it simpler you can make it a class that just wraps a bunch of booleans like isHeartRateHigh or isBloodPressureHigh
(there are a multitude of ways to implement this, this is just the simplest one I can think of)
this way you also don't need 20 different classes that implement the Observer interface
you just need one that checks those booleans in its update method
and takes action depending on what's flagged and what's not
you could also considering going with Enums to represent different types of issues like
HIGH_HEART_RATE
or BLOOD_PRESSURE_LOW
, etc.You can but I wrote it out because like that it's hard to indicate multiple things at once
that's why I suggested an int flag variable instead
because you can't really send enums like HIGH_HEART_RATE | BLOOD_PRESSURE_LOW
of course you can make a workaround for it. I just feel like it's not worth the hassle as there are easier alternatives in this case
yeah there's definitely better alternatives what I was suggesting was something I would have to make rn but I have an example here
taking this code you can probably provide ranges for the enum lets say something like
BLOOD_PRESSURE(min, max)
which can be ints if they fall below the min or go higher than the max then you can just use these insteadUnknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
but this approach is much more time consuming
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah, that's why I just didn't suggest it
I'll make a simple example
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
Okay so here is a minimalistic example of how this might work
you don't need to follow it like some guide book, it's just something I quickly wrote up.
Here is your Observer interface:
Here is the implementation for the Observer interface:
Here is the Patient class:
and here is the DataStorage class:
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
you can copy them over somewhere so they can be formatted and not squished
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah also the PatientData class seems obsolete
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
just store all the Patient data as fields in the Patient class
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
It's not that you can't do it like that
but in my opinion it's way overcomplicating things
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
by the way I would just like to mention that I think that the observer pattern here is pointless as well
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
because it's unlikely you would need more than one object to do the handling of a Patient with abnormalities
let me modify the code a little bit to explain what I mean
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
okay so here is the new stuff
instead of an Observer interface we have this:
the implementation is this:
and this is the modified DataStorage class:
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
well I'd say that for your particular situation this is the best approach
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
you can move the patient state checking logic to the AbnormalityHandler interface as well if you would like
ah
in the checkAbnormalities method there should be a check for whether the patient is ok before firing the event
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
of course you can do that logic check in the actual AbnormalityHandler as well
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
it's just checking the isOk boolean
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
yeah. I'd say that in your situation this is probably the best approach
good luck!
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
alright, feel free to ask again if something else comes up.
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
I am not sure exactly what you mean by that
can you show me an example? Perhaps just your Patient class will be enough
I will probably be going to bed soon though so I'd say the earliest I'll respond after a bit is tomorrow
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
still here so maybe we can get this sorted out before I go to bed
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
can you not just make a getter?
Unknown UserOP•2y ago
Message Not Public
Sign In & Join Server To View
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.