Vineeth Menon

Ranch Hand
+ Follow
since Aug 08, 2011
Vineeth likes ...
IntelliJ IDE Tomcat Server Java
Merit badge: grant badges
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 Vineeth Menon

Hi Bruno,

Not sure if this is relevant here, but here is my two cents. Studying how to crack interviews (for different companies) is quite different from learning how to code. The reason why I am mentioning this is because usually these days most of the companies ask a lot of Data structures and algorithm questions combined with System design questions (E.G. Design a video sharing webite which can handle more than 5 million requests per second). I personally find that the former involves less logic and more "getting used to interview questions" involved. As a programmer I have never inverted a Binary tree or never had to find the starting point of a cyclic Linked List. If you are preparing for interviews, practicing such questions and understanding the core-concepts of interview related questions is the only factor. If you have to look at YouTube and understand it by no means is a reflection of your intellect. I am mentioning this since for the longest time (almost 7 years) I though I was dumb as a bag of hammers until I cracked an Amazon SDE III and after 2 months only to forget everything!!! And by forget everything does not mean a complete hard disk wipe, but more like; what used to take me 10 - 15 minutes, now would probably take 45 minutes - 1 hour. There are some stuff like time and space complexity which are quite useful for everyday programming. I am yet to come across a person solve something like this in less than 30 minutes if they are seeing this question for the first time. I personally never look at interview questions unless I have to attend an interview.

Learning how to code, is a bit different. It involves understanding the language/framework, spending time exploring and obviously doing some real world examples. I personally prefer a video tutorial where I can view a chapter and then play around that understand what it does and then move forward. E.G. I learned Spring Boot from Udemy. I watch each section, explore it by myself, poke around stuff until I'm satisfied and then move ahead with the next section.

Hope this helps...
1 year ago
Hi there,

Welcome to the ranch. I would say Head First Java is an amazing book to start out with. I would also recommend to try out and practice the problems which are there in the book. That is what will help you the most!!! Happy Coding.
1 year ago
Hi Tim,

Thanks for your reply. On a side note, if I were to return the object myCustomObject or myCustomObject2 based on some condition inside myCustomFunction, would that be a bad design as well? My main concern is that at a later point of time the whoever maintains the code needs to have strict standards, else she/he can ideally return any object from myCustomFunction and that sounds like danger to me.
5 years ago

This is more of a design question. I have a function which has Object as the return type. Based on the outcome of the function, I will return either my custom object or I will return an exception, so that I will be able to guide to code accordingly. E.G. In the below code, the function foo is calling myCustomFunction which is returning an Object. Now based on the Object's instance I am deciding the subsequent actions. Is the below design a good, bad, or depends on the situation, but try to avoid kind?

5 years ago
Hi Nan Jordan,

Welcome to the Ranch . I think you should read about upcasting and downcasting. This link seems to offer a pretty good example which ought to clear up your doubts.
5 years ago
Hi Campbell,

Thanks a lot for your reply. I was quite amazed to know that byte[] is not a primitive. So, how will a List<byte[]> be considered as an object? Is that how Java treats in internally? I'm quite fascinated.
5 years ago

I have a function where the return type is a byte[] (primitive). This function will be called multiple times and I need to store an list of byte[] (primitive type). I tried using Guava's but then it get's converted into Java object and then I am able to get it as a byte and not a byte array. E.G.
I hope the question is clear. Basically, how can I store a list of byte[] as primitive and then use it at a later point in time.
5 years ago
Nope, I do get your point. And thanks for pointing out rather than sugarcoating the message.  
6 years ago

Liutauras Vilda wrote:
So it is Google Guava library code. However, I am still thinking the same. What a weird method name. Method requires “true”, otherwise exception is thrown, while the method says checkState. If you ask me to check temperature, most likely I would tell you what the temperature is.

Why not checkStateIsTrue, better probably ensureStateIsTrue, verifyStateIsTrue, requireStateTrue, why “state” at all, requireTrue, ensureIsTrue.

I know...It's seriously weird. I need to pay more attention to the docs. The crazy part is that it needs "true", and my function was failing since "version.length() < 1" was not true so I had to do a !(version.length() < 1).

I opted for a normal if condition... Simple life...
6 years ago
Wow that's a lot of comments...  this community is loads better than StackOverflow... Love the place..  
@Liutauras Thanks for your comments. Here are my 2 cents

1. Method name isXcui() is poor.
1.1 You wrote javadoc for it, and javadoc has better explanation which could be reflected in method name. i.e.: mustBeXcuiTested() or something, what explains right away what is all about.
1.2 If method throws an exception, there is a notation in javadoc for that @throws.

1. I have change the method name. (I think it's a bit better now)
1.2 Since it's a RuntimeException and since the function is not throwing it (using throws) I did not use the @throws in javaDoc. However, I did specify in the description that the function will throw a runtimeException. Is this a right thing to do?

This line is poor in two ways:
2.1 method name checkState doesn't give a sense to a user what happens after checking state.
2.2 You are checking if version length is less than 1. Technically length shorter than 1 can be only 0.  So why you don't check version.length == 0 or version.isEmpty() ?

Yeah, Preconditions does throw people into unwanted confusion (especially if they are not familiar with Guava). I have replaced it with a normal if condition and now checking version.length()==0

3. Why the base version is hardcoded in the method? What would happen when base version would change? You'd create new isXcui() variant? Or you would change the method?

It's not going to change. Apple set the rules for XCUITest, not me.  

Because like me, he learned via Z80 assembler on a TRS-80 where you had 64k total memory, 16k used by the display.

@Jim, I so wish I had the opportunity. But I started coding on a Pentium 3. However I did have a pretty good teacher who worked on assembler and he did leave a lasting impression on me.

Old habits die hard, I still spend more time than I should trying to save a few bytes here and there. It's not lost on me my code now runs on a laptop with 6 gigs of memory backed by a petabyte of swap space and I want to store my small numbers in 8 bits instead of 32.......

Amen to that brother.... can't agree more. I can relate to that so very much...

That older code might work correctly if version 12.0 counts as a greater version number than version 11.9999999999999999999

@Campbell Anything above 11.99 will throw a IllegalStateException, I think you missed the osVersionConvertor function. There is a regex check there.

Also what happens if you pass version 9.3?

If I pass 9.3 it will return false. The Business Logic also dictates that anything below 9.3 and 9.3 should not use XCUITest.

As per your suggestion, I have changed the boolean variable flag to something a bit more meaningful.
Yes, you are right. Illegal Argument is a better one than Illegal State.  

There was a small change as well. The base version of the code should be 9.3.0 not 9.3, was a miss from my side.    Here is my updated code...please let me know the comments

Once again, thank a lot for the comments guys... Appreciate all the help.
6 years ago
Thanks to both of the Marshals for the quick reply   . This is how I originally wrote the code. if the actualVersion is greater than the base version then return true, else false. Guess I got carried away. Marshal Campbell, you did also mention that there are other style issues as well, can you please point that out as well?

6 years ago

In the below piece of code Line #15 I am calling the osVersionConvertor function rather than firstly assigning the value of that to a variable. My intention was to reduce memory footprint as much as possible. Is this the right way?

6 years ago

I've got a set of API's which returns a set of data (JSON format). 95% of the data is static and the rest of the data would change every minute or so, and I need to test these API's. The requirements are
1. Check if the key-value pair are matching (assert) for the static part of the data.
2. Check if the key(s) are present in the dynamic part of the data.

I did look around in Jackson and simpleJsonParser but could not find anything. Is there any library which helps me to do this? Or would I have to write the logic for this from scratch?

7 years ago
Hi Stephan,

I'm using the JSON Library. I feel the problem was that the, inside the new JSONArray was being considered as an object and not as a String (Hence the error message "JSONArray initial value should be a string or collection or array"). So when I added .toString() at the end, the code is working. Not sure if it's a correct hypothesis, but please do correct me if I am wrong.
8 years ago
Hi Folks,
Why would does this code work

And this not work.

I get the exception “JSONArray initial value should be a string or collection or array”. The transportDetails is an array, I guess I'm not sure what is going wrong. Can anyone help me out?
PS: In both the cases the transportDetails has value in it.
8 years ago