Partheban Udayakumar

Ranch Hand
+ Follow
since Jul 04, 2013
Merit badge: grant badges
For More
Coimbatore, Tamil Nadu, India
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Partheban Udayakumar

Jesper de Jong wrote:That code is not very complex at all, so I wonder why you want to change it to lower complexity. Are you using some static code analysis tool that tells you that this method has a high runtime complexity? That's because there are many possible combinations of one or more of the parameters being empty or not. In fact, since there are 3 parameters, there are 23 = 8 possible combinations. In practice, this is not a problem at all, because the condition for each of the parameters is not dependent on the others.
If it really bothers you, you can make separate methods out of each of the if-statements. But I wouldn't worry about it.



We actually work for retail shops and we have around 250 retails shops and around 150 java classes depending on its website layout. So what they have done is One common parent class and 150 child classes. So the code I have mentioned below would not be in the common parent class but in those 150 classes.


I wanted to optimise it so I wrote the new code and gave them to add it to the parent class because they using it at least 3 times in a child class for 150 child classes and more over I have seen people using the wrong spelling for the keys like "Refferer" for "Referer" and spending the whole day not able to resolve the problem. But when I gave it for review they said we would be checking 3 if conditions every time and as you said putting the if conditions in a separate methods would only increase the code.

Paul Clapham wrote:First using the technical term "runtime complexity" to mean something different than its normal meaning. He could have said "amount of code" and be better understood. Although if he had said what he meant, it would have looked silly because he would have been telling you not to increase the amount of code in order to reduce code duplication. What Jesper said is a good response to that


I too didn't understand the phrase "runtime complexity" when he said it to me, I had to google it to check whether it meant something else and on clarification with him, he said it would increase the run time every time this method is called. I was like "WHOA". Anyway he is my senior in the project and he has sent my mail to his seniors to review but they haven't replied any thing. In case if they ask me questions, I have to be ready to justify this method so I posted the question.

Paul Clapham wrote:Second, premature optimization. The whole method you posted is just a small amount of code which doesn't use any external resources. Its runtime is going to be essentially zero -- maybe a couple of milliseconds at most. And it's only going to be used once in a process which is going to take much longer than that. So spending any time at all on considering whether to optimize it for speed would be a complete waste of time.


I didn't get this part. I should have mentioned the 150 child classes first, that would have given you clarity. Sorry my bad   I would like it to move it to the parent class and not the 150 classes if that's what you meant.

Actually I wanted to do something like this


How ever these guys are using only one of these 3 submit methods. I wanted to see the initial reaction for only that method and then propose this. Let's see. Please do let me know if you have any suggestions for this.
7 years ago

Paul Clapham wrote:Your first two if-statements test the same condition so they could be rolled into one if-statement.


Sorry paul the second if should have been


Paul Clapham wrote:Presumably "increase run time complexity" involves comparing your code to the previous version


Previous version would do some thing like this



This is for one form submit but there would be atleast 3 to 4 such form submits.

Paul Clapham wrote:unless perhaps their definition of "run time complexity" is different to what my understanding is.



He said and I quote "You shouldn't increase the runtime complexity of code to reduce code duplication. If there is no need of setting any of these params, everytime the method is called it would check all the if conditions. So this would increase the runtime." but as far as I have worked in this project, every form submit uses at least one of these params.
7 years ago
Hi all,

I have the following code but when I suggested it to my senior they said it will increase the run time complexity. Do you guys have any ideas on how to reduce it?



I did this for code reduction but as mentioned he said it would increase run time complexity. Is there a work around for this? Please help me guys.
7 years ago
If any one is looking for the answer, please go to this Stackoverflow answer
8 years ago

Henry Wong wrote:That topic did *not* earn any cows. If it had, and since you are the only poster on that topic, the cow would have been yours.


Ya I know that but the post listing showed cows. That is why I asked.

Henry Wong wrote:I am assuming that you noticed the cow in the forum listing?


Yes. Exactly

Henry Wong wrote:The forum listing's cow rating is the rating for the whole topic. This includes the total number of cows earned by the topic, along with other factors, such as the number of times the topic has been viewed. Arguably, it is unfortunate that the cow icon was used for it ... but oh well.


Oh I see. But something else should be used to indicate the views right? Will this post be considered?
8 years ago
Hi,

I had posted a question and it has earned a cow. Will I be able to see the cow provider?
This is the question
8 years ago
Hi all,

I am currently working on a project with Spring 4, Spring Security 4, Hibernate 4, MySQL 5. When I login with the user credentials, it logs in but takes me to unauthenticated user page. I tried debugging the code in eclipse but I am not able to find out why it goes to the unauthenticated user page. We are using 4 different types of users for the project, so the database design given to me was a little different. I have added it as an image below.

Here are the codes I have used

SpringSecurityConfig:


MyUserDetailsService



All the values from the database are fetched correctly and passed in the UserDetails (details) object. But still it gives the same result.
8 years ago
Dave Tolls,

Thanks for the reply. So User object can be returned with null values and also that doesn't affect the response timing. So we don't have to be worried about making our output pretty.
8 years ago
Tapas Chand,

Thanks for the reply. I am eager in learning more. If you were in my situation what would you opt for MNC or startups?
8 years ago
Dave Tolls,

It is expecting a User object. The contract is something like getUserBasicDetails(). Just for showing a minimal profile page. I am writing this for an Android application. I am not against returning null values but just want to make my response pretty.
8 years ago
Tapas Chand,

Thanks for the reply. You just pointed out the number which I got to know by researching. I didn't want to include it as I thought it could have been like complaining. So can you give me an idea of what would be my designation if I am moving to new company. Should I go for startups/mid size company again or should I start searching for MNC's(Service/Product based)?
8 years ago
K.Tsang,

For single variable what you are suggesting is right. Let's take an example, say I am returning 4 variables of User class,
1) id(Integer)
2) fullName(String)
3) status(String)
4) createdDate(Date)
Then the whole bunch of other variables will be null. How should I proceed with this?

8 years ago
K.Tsang,

Thanks for the reply. I am sorry for the late reply as I was a little busy with my work in office. Thanks for the date formatting in json, it would help me a lot. I too use jackson. As for null values, Say I am sending only id back then all other variables in the User class would be null. As I said earlier, this is OK if it is 2 or 3 variables but for a whole bunch of variables, it is not in the pretty format. I have a doubt too. Does returning these null variables affect the performance? AFAIK I didn't observe anything as such until now.
8 years ago
Hi all,

I am Partheban. I have 3 years 6 months of experience in Java web development. I am currently working in a private firm in Coimbatore, Tamil Nadu, India. As far as I have researched, I think I am underpaid here for my experience (this is my personal view, I don't blame any one). I am paid around 17500 INR per month which is around 262 USD of which I receive only 14000 INR as take home which is 209 USD. I know the following technologies

In web:
Servlets, JSP, Spring, Hibernate, JSF and Primefaces, RESTful Webservices in Spring

EDIT: Sorry I forgot to include JQuery and AngularJS

In standalone :
Swing and JavaFX(currently learning)

I was working for 2 years 3 months in a startup in Bangalore and then I moved to Coimbatore due to my personal reasons and then I worked as an intern for 4 months in startup there and then I moved to my current company and I am working here for the past 9 months as Web Developer. I am currently working in Java 8 and I haven't done any certifications until now.

Now I need advice from you guys on how should I improve and how do I go ahead with my career. What would be my next step and how should I prepare for it? At least when I move to the next company, I should be able to get a better deserving salary. And if you guys don't mind, please comment on the current salary I am receiving. Whether is it a correct one or should I approach my manager for salary hike or any specific comments regarding my career path. Anything that would help me in my career is welcome.
8 years ago
Hi all,

I am developing RESTful WebServices using Spring. I have this thing bugging me. Say I have a custom object as below:



As you can see this is a hibernate model class and it has many parameters. Most of the time I won't add the Set's or the createdBy/updatedBy and createdTime/updatedTime to the response. So when I am returning this class as response it will convert to a JSON object and will return many null fields. How can this be avoided? Currently we are creating a new non Hibernate model class and we add the params to it. I don't think this would be the correct way. Also this increases the number of files used in the project. And if I have to send the date and time, it would be returned as Long from this class but we will have to format it to our required format and add it to the new class and send it. This is OK for many dates but for one date, I don't think we should create a new class just to return it in the required format. If my current method is wrong, kindly guide me to the correct way.
8 years ago