must Janik

Ranch Hand
+ Follow
since Jul 04, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
28
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by must Janik

Refresh. I really care about this.
1 month ago
Hey guys. I would like to hear opinions from people with bigger experience about KeyboardTeacher application.It fetches text from textfile, and show first line in console. If user rewrite the whole line correctly, then it shows the next line from the file, and so on till the end of the textfile. Otherwise it shows the first bad index and show again line which has been written badly. At the end it shows the result in seconds and save the result in textfile.

I added ranking system by which people can see who was the fastest.

I would like to know if I can change there anything, improve etc.

I will paste some main classes and at the end I wil put my link to the project on GH (if needed).

Main:

 

KeyboardEngine

 
KeyboardTeacherView - it implements GameMessage which is of course interface.

   

RankingSystem

   

RankingSystemFacade

 

ContentFileRetiever:

 

ConditionCheckerService

   



ContentFileServiceTest

 
RankingSystemServiceTest

   

Github: https://github.com/must1/KeyBoardTeacher

1 month ago
Hey guys. I would like to carry out the validation of input from cmd in application responsbile for fetching rate data from national polish bank.
I need to input 3 arguments for example: EUR 2013-01-28 2013-01-31.

I need to validate two dates, 2 arguments with:
1) first date needs to be before next
2) input is in good pattern. I mean it cannot be 28-01-2013, it needs to be 2013-01-28.

Im using LocalDate.
For now, I am parsing String to LocalDate with LocalDate.parse, and it throws the DateTimeParseException when date is not correct, but I would like to log that exception and show message for example "You put date in wrong format". How can I do that? I have already interface called ConditionChecker that looks like this:



My main looks like this:


Currency validation is also in main, but it looks fine, no try/catch blocks etc and I want to achieve same thing with LocalDate.
Returning to localdates validation. It should be in CondtionChecker or how should I make it?

NbpParserEngine (if needed):



1 month ago

My suggestion was to put a test for null at the top of the method, then do all the other stuff if it gets past the test.  So to be clearer:


Oh, I got it. Done!

Constants are both static and final, and usually are member variables (not local).



Ye, I know it, but the point is I think I used it in application properly. All constants are both static and final.

Greetings!
1 month ago
Thanks! It means a lot for me.

You're method and variable names are long, but long is often good.  It's more descriptive.  Here's one place where I might shorten a method name:


Done!

* I tend to put all my public-facing methods higher in the code and all the private methods lower.  This is so the API is more noticable.


Done!

* Sometimes if you have a very long then clause for an if statement...




yea, but in this situation I need to act when line is not null, if it is a null then nothing happens

* Don't use ALL_CAPS for variable names unless they are constants (static final).


I think I used it only when variables were constants.

If anybody has some other suggestions. Let me know!
1 month ago
If needed to paste all classes here, just tell me and I will do it. It's important to me to hear something from "bigger" brains than me :P
1 month ago
Hi guys. I would love to hear any opinions from your site about my application.
It is responsible for fetching data from National Polish Bank about buying rate and selling rate from days between given two dates. Next it calculates average buying rate from these days + standard deviation of selling rate.
For example we put 2018-01-28 and 2018-01-31 and it counts 28,29,30,31 of January.

I would like to hear:
1) if tests are properly written.
2) if NBPParserEngine is properly written (what does it mean? - if method names are good, if methods are not too long, if they are, how to shorten them)
3) if DataFetcher is properly written (same as 2) )

To sum up, Im not sure about methods names and if they have proper length.

I made pull request: https://github.com/must1/NBP-Parser/pull/1
If you want to "normal" version of GH: https://github.com/must1/NBP-Parser/tree/dev

I can paste also here some classes:

NBPParserEngine



DataFetcher



Here are tests: https://github.com/must1/NBP-Parser/tree/dev/src/test/java/pl/parser/nbp

Thanks a lot!
1 month ago
I got it. Forgot about `\n`, that's why everything was in one line.
Then, could you tell me if I should call deleteOnExit() on File?
I read, that TemporaryFolder deletes everything alone.
1 month ago

Junilu Lacar wrote:Have you tried this:



Ye, I have tried.
My method looks like this:


and I have java.lang.AssertionError: array lengths differed, expected.length=3 actual.length=1.

Is it necessary to overload the getContent method? Because I will use method with textFile as a parameter only in this unit test. I will paste the method I want to unit-test, too:




1 month ago
Im trying to write some strings to File created by TemporaryFolder. I need to provide 3 Strings:

Line1 a
Line2 b c
Line 3

1) I make this, but it does not add anything. Length of testedContent is still 0. I tried to flush FileWriter but nothing happened. What am I making wrong?



Stacktrace:



2) Should I do it in setup with @Before method or do it inside test?

3) I read that this folder will be deleted automatically, so I dont need to perform .deleteOnExit() on textFile?
1 month ago

Stephan van Hulst wrote:

must Janik wrote:Why dont we have the same solution as at normal web app? No main method in our code, just in container?


Because the container is just a generic piece of software that doesn't know that it has to start your web application. When you start it up by its own main method, it still needs to be told what web application to run. That's what the outer wrapper main method does.



Okay, so comparing to Spring MVC what is the difference? I mean, I want to quote

When you start it up by its own main method, it still needs to be told what web application to run.

, Spring MVC does not needs to be tolds what web application to run?
3 months ago
Two main methods? What is the sense of it. Why dont we have the same solution as at normal web app? No main method in our code, just in container?
3 months ago
I mean, why SpringBoot does not have the same solution as Spring MVC. Why not both has main method inside container or main method wrriten by ourselves.
3 months ago

Stephan van Hulst wrote:Do you mean "start" in your IDE?

When you press start for a Spring Boot app, your IDE starts the Java VM which in turn calls the main method.



Why SpringBoot container that is bundled with it  does not have main method as SpringMVC then?
That it because I can change type of container?
3 months ago

Stephan van Hulst wrote:
Web applications run inside a web application container. Usually, this is a piece of software that is already running on a server somewhere. These containers provide a main method, so web applications loaded by them don't need a main method.

Spring Boot applications are not deployed in a web application container. Instead, the container is bundled together with the web application, so you can run it without requiring that a container is already installed on the host system. It needs a main method to start up the container that is bundled with the application.



I do not understand it at all...
I need to press start to start up the container while deploying MVC app.
I need to press start to start up the container that is bundled with the application.

What is the difference? (I know that one has embedded container, the other not)
3 months ago