Pattern design for a trading application

Do you know how trading sites/applications manage data and then display it?
e.g. prorealtime, tradingview, metatrader etc.
From our side, we receive raw data or already processed data that are just displayed?

I don’t understand why you down vote my post.
What is the difference with this kind of question?
Why does Java use :: for method references instead of .?

Is maintenance, feedback, or support an integral phase of SDLC?

They just ask questions

Go to Source
Author: antho

How to apply MVC pattern in JavaFX with nested classes

I am trying to create a Calendar application in JavaFX using MVC. What I have in mind is something as what is shown in the image below:

Calendar draft

Basically:

  • I have a CalendarView (red background) showing the title of the calendar (“Calendar for today”) and the labels of the hours of the day. This CalendarView includes a container (blue background), that works as a holder for the individual appointments.
  • I have an AppointmentView (green background) which is generated for each and every appointment in the calendar.

Based on this scenario, my idea would be doing something as follows:

  1. Create an AppointmentModel class as model for the appointment
  2. Create a CalendarModel class as model for the calendar. This class includes a list of AppointmentModel
  3. Create a controller for the appointment, called AppointmentController. This controller will include an instance of an AppointmentModel class and an AppointmentView class
  4. Create a controller for the calendar, called CallendarController. This controller will include an instance of a CalendarModel class and CalendarView class

I have written the following pseuocode to describe this scenario:

public class AppointmentModel {
    ...
}

public class CalendarModel {
    List<AppointmentModel> appointments;
    
    ...
}

public class AppointmentController {
    AppointmentModel model;
    AppointmentView view;

    ...
}
public class CalendarController {
    CalendarModel model;
    CalendarView view;

    ...
}

The problem I find now is how to link the calendar and the appointments. In the code above I have included List<AppointmentModel> appointments; inside CalendarModel, but by doing this, I do not know what to do with AppointmentController. Only thing I could think of is including a List<ApointmentControllers> ... in CalendarController and removing the List<AppointmentModel> ... from CalendarModel, but this does not make sense for me, as the CalendarModel, by definition, implies a list of appointments.

What am I missing in my reasoning?

Go to Source
Author: Fernando Cereijo

Is there a less complicated alternative to handling this simple mySQL query in Node?

To Put My Question In Better Context…

I am about done writing my first real-world Node application, which would be classified as a REST API. For myself, it was a bit challenging to wrap my head around Node’s Async event processing. I still don’t think I fully grasp it, as you will see by the specifics of this post. That being said…

Am I Making This Overly Complicated?

I found some code snippets online that helped me get my API working. Below is one function that deals with finding a client. I guess you would call the file this is in, a Controller, for those of you familiar with MVC. But this being Node, and NOT MVC, my question is this:

GET http://localhost/clients/3 -> brings me to this code…

// Find a single client with a Id
exports.findOne = (req, res) => {
  Client.findById(req.params.clientId, (err, data) => {
    if (err) {
      if (err.kind === "not_found") {
        res.status(404).send({
          message: `Not found Client with id ${req.params.clientId}.`
        });
      } else {
        res.status(500).send({
          message: "Error retrieving Client with id " + req.params.clientId
        });
      }
    } else res.send(data);
  });
};

What is the reason for this call to have a callback itself???

Client.findById(req.params.clientId, (err, data) => {

which in turn, looks like this:

Client.findById = (clientId, result) => {
  sql.query(`SELECT * FROM clients WHERE id = ${clientId}`, (err, res) => {
    if (err) {
      console.log("error: ", err);
      result(err, null);
      return;
    }

    if (res.length) {
      console.log("found client: ", res[0]);
      result(null, res[0]);
      return;
    }

    // not found client with the id
    result({ kind: "not_found" }, null);
  });
};

This seems like a lot of work for a simple query function. Coming from a PHP background, this could be done in very few lines of code there.

The whole thing seems complicated. Is all this really necessary for such a simple API that returns a client record of only four columns?

For that matter, do I even need that intermediate function (controller)? What’s the matter with just routing right to the final function (in this case, a function named findById ) ??

I’d sure appreciate some input on this before I get too far ahead. I have another dozen endpoints to code, so if I need to change directions, now would be the time.

Thanks!

Go to Source
Author: John S.