Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Fraud Notification Frequency Calculator  RSS feed

 
Ranch Hand
Posts: 483
23
AngularJS Eclipse IDE Firefox Browser Java Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently solving problems on Hacker Rank  under the section Interview Preparation Kit. I have attempted one of the problem under the sub-section "Sorting" called Fraudulent Activity Notifications and I came up with 2 solutions. I will request you two have a look on my 2 versions and let me know the pros/cons in the design decisions i have taken.

I have hosted the 2 versions of the solution  on my Github Repository with the 2 versions on seperate branches:
master
RefineImpByAddingSorter

I have also open a pull request for the later branch commits to the master for making some notes about the review.

My thoughts: for adopting second version as a solution
I have designed the second version(the later one) as the evolution to what i had in my first version. there, i have refactored the Sorting related task by delegating it to the Containing Sorter interface(i have also written one of its implementation with the same logic as in my first version). this has a plus of modularity and Refactoring, also its easy to change the Sorter if needed to change at any point of time.

I have also written a unit test in the test folder on my github repo with the JUnit5 framework. i am also trying to learn the principles of TDD(Test Driven Development) but I have not read or practice much about it beside some of the APIs in the JUnit5 and have tried to apply in practice. Please review the tests also.

Some difficulties i need to know about in unit testing:
1.) How to test private methods: i have search about it and get answers like use reflection or some framework thats doing the same thing behind the scenes(i dont remember the name of framework but i think it's powermockito), some people argue that private methods are automatically tested during testing the units they are part of, i think its not be right to say this because it crosses the barriers of unit testing as later on somebody can also say testing the complete application implicitly test its all units. please advice. Is it a bad idea to temporarily change the private modifier to package private for testing purposes.
2.) Can somebody advice me some short book on TDD and Patterns in Unit testing.

Waiting to watch some Constructive Criticism and i will try myself to be a Egoless Programmer throughout the review!!

PS: I am learning git in parallel for getting comfortable with it through practice and since i have seen reviewers generally also advice about things done poorly there. so that's why i have attached the github link. if somebody is still not comfortable with github please let me know. i will post the code here.
 
praveen kumaar
Ranch Hand
Posts: 483
23
AngularJS Eclipse IDE Firefox Browser Java Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I think I should post the code here, I am posting them in different posts

Version 1
 
praveen kumaar
Ranch Hand
Posts: 483
23
AngularJS Eclipse IDE Firefox Browser Java Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Version 2
 
praveen kumaar
Ranch Hand
Posts: 483
23
AngularJS Eclipse IDE Firefox Browser Java Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unit Test
 
Marshal
Posts: 63792
209
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only a few things I have noticed:-
  • 1: You showed us three classes, but you only appear to have two GitHub links.
  • 2: Your formatting is inconsistent. Sometimes your comments start with /*newline and sometimes with /* text. Your lines are too long, which makes them difficult to read. You have the [] in the correct place for array declarations, but they shouldn't be preceded by a space.
  • 3: Why didn't you make the comments on all your constants into documentation comments?
  • 4: Some of your field identifiers are ambiguous: MAXM_SPENT_DAYS, for example. MAXM is harder to read than MAX/MAXIMUM. Does SPENT mean days spent doing something, days for spending money (see line 152), or days during which the offence is regarded as spent?
  • Only a few things, but I hope that gives you ides to improve the code.
     
    If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
    global solutions you can do in your home or backyard
    https://coderanch.com/t/708587/global-solutions-home-backyard
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!