Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:40:34+00:00 2026-06-16T01:40:34+00:00

I have a application and i need to user Observer to resolve. Since the

  • 0

I have a application and i need to user Observer to resolve. Since the code implementation is long i would like to sum the problem.

I start the application.

I have a LogInWindow where i can choose Secretary or Student.

The secretary can add students, courses and results for a student at a given course.
The student can only see its results.

I need to use Observer so that if a Secretary is Logged in an instance of that application and a Student is logged in another instance of that application, when the Secretary adds a result for that student at a course, that student sees instantly on its list that new course and its result.

The data is read from txt files.

My solution.
SecretaryWindow is an Observer
StudentWindow is an Observer
ResultRepositoryFile is the Observable object

When i click AddButton the controller Adds a Result(studentName, courseName, result) to the ResultRepositoryFile. The SecretaryWindow observer sees that, prints a message and saves the txt file containing the ResultRepositoryFile.

Now in StudentWindow i click a RefreshButton and the ResultRepositoryFile is reloaded in the list from this window, showing the newly added Result.class

Is this the right way to do it, because i have doubts.

How to sync the two instances of the same application using Observer ?

Thanks for reading and hope you can help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:40:35+00:00Added an answer on June 16, 2026 at 1:40 am

    If you’re going to have more than one person using your application at the same time, you should use a database, rather than text files. Text files can get corrupted if more than one person writes to them at the same time.

    I suggest a relational database like MySQL.

    Since your student window has a refresh button, your student window will always pull the most recent data from the database.

    When the secretary adds a result to the database, the database will lock, and not allow anyone to access that one and only result until after the add is committed to the database. The database allows access to other results at the same time the secretary is adding a result.

    You do not need an Observed and Observable, unless you want to signal a student that a secretary has added a result to the database.

    Edited to add:

    The secretary window is the Observed, and the Observable is the result that the secretary has added to the text file.

    The student window updates the window based on the Observable. The secretary window has to be able to access the student window instance based on the student id of the result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows phone application and I need to add a user control
I have a web application inside where i need to check whether the user
I have a simple application in which I need to let the user select
I have a client server application in which I need to transmit a user
I have an application I need to analyze. I have the source code here.
I have this application that need to do some things in protected paths (like
I have an application wherein the application will need to check whether one user
I have make an application. In this application client need that when user download
I have an application I'm working on, and I need the user to be
I'm working on a plugin system. Some plugins need user input. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.