Win a copy of Python Continuous Integration and Delivery this week in the Python forum!

Stefano Carniel

Greenhorn
+ Follow
since Aug 01, 2013
Stefano likes ...
Android Java Spring
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Stefano Carniel

Hello all,
I need to implement a client/server application that works in this way:

1 - On server side I have some values, picked from the sensors on a machine. These values change randomly, they could also stay constant
2 - I have a publisher/subscriber mechanism that notifies me when one or more variable change
3 - I need a web page that connect to the server and shows data in real time, I guessed I can use React with socket-io.client
4 - What I don't know is how to implement the server  side; I would like to use Webflux with WebSockets, but how can I bind a Flux to an unpredictable train of variable-changed events? As far as I know, Flux implements a continuous emission of data, for example the record from a database table, but how to deal with random events?

I hope the problem is clear, I would like a suggestion on how to structure the application.

Thank you
2 months ago
If you can, take a look at this book. It explains very well these concepts, not only, it teaches how to implement classes that support this programming style (methods cascade).
Honestly, what your book states is not in contrast whith what mine states. Functional programming can help to essentially produce safer and more concise code, but for sure this code is less readable (but not necessarily less clean).
1 year ago
Don't know what that book focus on, but functional programming states the opposite. In particular, afaik, with the introduction of the stream (in Java >= 8), it is common practice to call method in "cascade" style.
1 year ago
a suggestion: change the name of your getters and setters to be clearer (getFirstname(), setFirstname(String firstname),...).

then, to print the firstname:


In your code you're applying the indexing to an object of type Employee, which doesn't make sense.

Most elegant solution, for Java >= 8
1 year ago
1 year ago
If you want to have fun too while learning, try codingame. They have a lot of interesting problems (also from algorithmic point of view) and, after you solved, you can see a nice graphical representation
1 year ago
One example that come into my mind is grouping a set of utilities functions that can be invoked frequently and does not require the instantiation of an object. A typical example is the Math class, which includes lot of static functions.
1 year ago
They can be used to store matrix, for example to represent a maze, or a chessboard, but also in lot of mathematical application, to solve linear sytems,...
1 year ago
If I'm not mistaken, BlueJ is an IDE, what's the problem to use it with version 8 of Java?
1 year ago
What about Javafx? It's based on MVC pattern and you have complete separation between views (screens) and logic
1 year ago
If you use Java 8, take a look at the Stream interface. It provides a lot of functions to iterate through the list and reduce results
1 year ago
I read my first post again, well, it is wrong abut the loop upper limit, I explain better my idea in the second post
1 year ago
No, I don't create 10 indexes, I create Array.Size*p/100 indexes (2 if the array has 20 elements). Of course some round checks are required (what if array size = 23?) and of course I have to keep track of the already randomized indexes
1 year ago
If I understand well, this solution allows to modify only consecutive elements of the array. My solution allows to randomize x% of element in random positions
1 year ago
maybe there's something better, but as quick answer, you can do a loop from 0 to percent-1, generate a random index between 0 and the size of array - 1 and change that element with a random 0/1
1 year ago