s ravi chandran

Ranch Hand
+ Follow
since Dec 20, 2010
s ravi likes ...
jQuery Java
Merit badge: grant badges
I am a  java developer. Working in Financial domain with an investment bank.
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by s ravi chandran

Thanks a lot for your responses. This is not the actual code from my project but a crude mock up with the scenario I wanted to show.  Apologies, if I was not clear earlier.

My actual application follows standard design principals and gets reviewed by our senior technical team members.  We are currently on JDK 8.

I do however am using the Clock class, will check the usage you had mentioned:

In current scenario, the Clock instance is part of a utility class which is shared across many classes of same service.
2 years ago
Thanks a lot. This issue had troubled for many days, I kept getting stuck at how to either mock the clock or zonedDateTime.

This solution is very helpful.
2 years ago
Hi All,
I have created a service which works based on time parameters. As part of the process, it also uses current time (ZonedDateTime.now()) method. Now I am stuck on this issue as I am unable to come up with a way to make the now() method return a static time so that my junit case run any time of the day and return fixed response.

I have created a crude mock up of my current implementation for reference :

Scenarios to test:
1. application start time is before host time
2. application end time is after host end time
3. process time within valid start and end time range, in this case start the process.

now my requirement is to somehow mock the NOW method of ZonedDateTime, so that I can perform all the expected results for this function.  

Please let me know any pointers on how I can do this.


2 years ago
Writing immutable classes makes the application more resilient. I believe its more a way of thinking once you become more familiar with handling immutable objects. The benefits include thread safety for multi threaded application, easy to debug for issues etc.

I am learning to write java lambdas since last year and still not comfortable in writing stateless code yet. I do try to refactor my code to make it as compact as possible though. Hoping to improve with time.
3 years ago
You can always use class diagram that reflects the sample view of your existing project. Its easier to understand the problem.

you can start with breaking down your requirement and code for each step.

taking your code snippet for reference with this crude mock up:

Also try to segregate the workflow into multiple methods, with each one doing a single action. so each step here would ideally go into a function.

do get back if you have more queries on this.
3 years ago
my bad  will correct the title again..

My sample is mostly different from the original example in two ways, one is use of Emp class instead of Employee class which I did not find anywhere and other is use of empBonusConsumer in method testBiConsumer(). So biconsumer empBonusAndHikeConsumer is created and not used anywhere.

Here is the code snippet from lesson:

But the confusion I had with this example is resolved.
4 years ago
Thanks for the responses. Yes, I see that the requirement for this example cannot be implemented with nested biconsumers. well I did understand the concept of biconsumer, only this example was confusing to me.

Meanwhile this lesson is from tutorial link and this particular lesson is from chapter "Additional Functions" section "Two Argument BiConsumers".

Edit: checked the lesson again, the presenter created empBonusAndHikeConsumer but did not use it anywhere. So in effect I was wrong to call it from testBiConsumer. Strangely though if this field is not used anywhere just defining the nested biconsumer does not seem that useful.
4 years ago
Sorry, I understood it to be biconsumer of biconsumer.

for the field empBonusAndHikeConsumer, how can I pass bonus of 5% and hike of 15%. That is the expected behavior.
4 years ago
Hi All,
I am going through a tutorial for lambda functions and came across an example using biconsumer of biconsumer.

Here is a sample code from that lesson:

The lesson did not explain one thing. If I create a biconsumer of biconsumer, how do I pass the arguments to it.

Would you please provide some insight into this scenario.


edit: corrected the title to reflect the proper question.
4 years ago

Paul Clapham wrote:

You could do that. I'm not sure what the difference would be if you used CompletableFuture instead but perhaps you could explain what you thought the difference would be when you planned to use it.

Thanks for the response. I updated my function with what you provided, hope this is how we should be handling the future results.

Coming back to by intention of using CompletableFuture, well I wanted to create sort of workflow pipeline and handle the result from all requests asynchronously.
But as I need the list of responses to process those further, that part is little murky for now.

Here is an incomplete code which I am trying to work out.
4 years ago
Hi All,
I have a multi threading problem where there are bunch of requests which will take varied time for processing. I want to  get response of all the requests and consume the responses.

My plan is to use CompletableFuture but not able to come up with how to code it. I created a mock up using ExecutorService and here too I am not sure how to handle the future result.
Would it be better to wait for a response with blocking call such as get() or should I use a while loop and loop around until all results are either done or canceled?

Here is the current mock up :




Would like to get advice on:
1) handling future result in current case.
2) if I use CompletableFuture, what should be the approach to this problem ?

4 years ago
Agreed. Automated algo trading is expanding at rapid rate..

AI CEOs would be a novel idea.
4 years ago
Thanks for the detailed explanation. Very informative. The type of commodities that can be traded is so vast I often loose track of it.

If we exclude proprietary aspects of a trading platform, there should be a generic architecture flow for all these systems, would that be correct assumption ?

For example, for any type of commodity to be traded, I can think of these many components needed in a basic trading system:

I think there would be some more components that would be required like risk evaluations, post trade feeds, trade report generators and some form of profit/loss stats for traders to know their overall position.

We would also have systems specific to commodity types.

Does this architecture seem reasonable ? With limited know how I have, I can think of these many components.
4 years ago
Hi All,
I would like to learn more about financial trading system (stock trading). I work on an java based equities trading platform but I only know the technical aspect of the service that I manage.

I would like to understand the overall architecture of trading systems and business usecase of each component. I also want to learn more about trader acronyms like long and short positions, hedging, ETF, RFQ etc.

I searched in google but all I find were things for actual traders, was unable to find something from developers perspective.

Please advice on where I can find resources for these.

Please move this thread to appropriate forum in case this is not the right platform, I was not sure which section this should belong to.
4 years ago
Sorry for delayed response.

Yes, I would like to get in touch with latest stuff in java development and also would like to understand things at software architecture level (top level view of enterprise applications).  

And regarding the books you have mentioned, is there any sequence that I should follow?
4 years ago