Todor Kolev

Ranch Hand
+ Follow
since Sep 09, 2019
Todor likes ...
Python Java Linux Windows
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Todor Kolev

to be honest, I never intended this to be it's own thread, it wasn't my doing.

I think nobody even read anything that I wrote so I am going to step out.

Concatenation? Where do you even see concatenation?
(don't answer, I've had enough of this)
6 months ago
It has it's benefits and drawbacks.
Imagine having a lot of forms and you want to have a generic method of filling a field in those forms: updateValue
Then, since there are many form types and different ways to fill each form, one might want to just create a method that aggregates the usage of updateValue instead of exposing updateValue as raw usage in the parent code.
Also, the specific intention of filling this form that way way could stay constant, but the way the fields are updated could change (different field names, or maybe owner needs to also be populated as a new field, 'creator', for example).
You could address all of that in this method, instead of fishing for all the times someone tried to fill this form in that way and changing it in every instance there...

As for naming, it works out. You create a resource by picking up a template (empty form), fill that form by updating the empty fields and submit for resource creation.

Again, not so worried about the structure here. More about the recycling of the string object.
6 months ago
I wasn't going to ask the following question about some code I've seen yesterday but stumbling upon this question, I cannot resist

Here is some code I have inherited from a contractor that was hired (at £500 a day!) and left some time ago. It does work. So, it's lower on my priorities to address:

(I applied minor obfuscation here)


From 0 to 10, how "bad" is this code? I am not too worried about the repeating updateValue method - it does make usage of the method readable and it does make the method itself simple.
I am particularly interested in the "recycling" of the string object 'template'.

Can/should a java developer do this?
(again, it DOES work, the committed 'template' has all the values updated like the usage of 'updateValue' is trying to do)
6 months ago
More info about the two annotations mentioned in last paragraph:

@Retention
*********
Annotations in Java have three different retention policies:
1. RetentionPolicy.SOURCE
- Annotations are to be discarded by the compiler.
2. RetentionPolicy.CLASS
- Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time. This is the default behavior. [emphasis added]
3. RetentionPolicy.RUNTIME
- Annotations are to be recorded in the class file by the compiler and retained by the VM at run time, so they may be read reflectively.

@Target:
*******
Indicates the contexts in which an annotation type is applicable. The declaration contexts and type contexts in which an annotation type may be applicable are specified in JLS 9.6.4.1, and denoted in source code by enum constants of java.lang.annotation.ElementType.
If a @Target meta-annotation is not present on an annotation type T , then an annotation of type T may be written as a modifier for any declaration except a type parameter declaration.
If a @Target meta-annotation is present, the compiler will enforce the usage restrictions indicated by ElementType enum constants, in line with JLS 9.7.4.
7 months ago
OK, I figured out something...
The key was to find how what I am looking for is called Once you know that, you can search for more info easily.

What I was looking for is "composed annotations", sometimes referred to as "meta annotations":
JUnit5 Docs - Composed Annotations

----

I created the following:



Then, I was able to tag my tests with @CcrStandardTest and derive all the above annotations in an elegant way.

Initially, I tried without @Retention and @Target - but then the composed annotation was not resolved - tests were either not discovered for execution,or not compiling due to "missing" method source.
IDE still managed to see through that and complained when I used both my composed annotation and @Test (while I was investigating) but IDE isn't important here.
- Not sure what these two tags do exactly (I have a guess but I am not brave enough to share), as the JUnit doc doesn't elaborate...



7 months ago
A guy some time ago told me it's possible and while I really tried to RTFM and google, I couldn't get a clue.

The problem is that my unit tests each make use of a not-small JUnit annotation system, something like this:
@ParameterizedTest
@MethodSource("myorg.ccrtest.testlogic.DataProviders#standardDataProvider")
@Tags({@Tag("ccr"), @Tag("standard")})

This makes test authoring a little tedious, test code a little long and of course, when a change is needed, it's a chore!

Was wondering if I could create my own JUnit annotation: @CcrStandardTest, which would imply all of the tags above?

I also tried shifting the tag up in the class definition (hoping they would then apply to all methods of the class), but the compiler says no: "@ParameterizedTest is not applicable to type"
7 months ago

Tim Holloway wrote: I run a PCB design program that's in Java, for example.



Nice!
One day, when I feel I could shift some time over from learning Java to learning something that I enjoy - I will pick up electronics.
I even have my workstation almost set up: Lots of components, neatly sorted into grids of small boxes, a huge bucket of unneeded appliances waiting to become a project.
All I need is: Scope, good quality iron and a wave generator - and time!
7 months ago
On two occasions, I've been to a potential employer to interview for a C# job.
No idea how it slipped past my agent and the potential employer that my coding experience is mostly COBOL, some Java, no C#, .net or any MS programming.
Definitely a lot of C# in the UK.

My two best friends are both .net/C# guys (an Indian living in the UK and an Israeli living in Holland).

I think Azure definitely boosts C# a lot, because all sorts of DevOps stuff on Azure are automated with C# and DevOps is really hot right now.

Personally, I feel MS are going further and further away from what I like myself.

They have Windows going for them:
Windows XP had the most "user friendly" interface and Windows 7 solved XP being way too hackable
Plus, about 90% of the desktop software released will execute on those runtimes as a binary.

However, Windows 10 while really plugging the security holes to almost linux-like level, kinda ruined the interface (a destructive process that started with W8).
The runtime is still very inclusive but all those forced updates, forced telemetry and forced account-based access is a HUGE turn-off for me, as a user.

If linux could natively support applications compiled for the Windows runtime and their GUI had a more user-friendly front-end, sooner or later, they would
dominate Windows.
Mac is the most overrated linux distro out there. 10% of the applications I need are there and they are all "3/5 stars" apps that cost between 10-40 bucks...
I had a mac for two years (got duped by my boss) - more bugs than Ubuntu!
7 months ago
I thought you don't need to @Override a method implementing a body-less interface method?
7 months ago
For each file - yes. I've rarely seen an MP3 file compress at all. But across thousands of files, you start seeing some space economies
I did this right now at home, got 3% off on 1000 files - that's actually a lot less than I expected, as mp3 compression itself will interpolate some different (but similar to the ear) sounds into the same sound, which would then lend itself well to compression via reference...

Maybe if I had more pop music in my sample, it would compress better, as all pop music is pretty much the same!
7 months ago
Slavin, in your second example, why did you @Override?
7 months ago
I understand, in recent years, Python and C# have gained popularity and they are somewhat alternatives to Java.
Still, Java is in more than half of all coding jobs out there (well, in my area).
I estimate there may even be a MILLION java coders out there.

And yet... There are only a few, very small communities to discuss it?

I mean, don't get me wrong, I love everyone on this forum, who have spend SOOO much time trying to give me a hint.
But it feels like the active members are maybe 10-20 people. With occasional members joining just to get sorted on one issue, never to return again.

You'd think with so many users, this place would be almost impossible to cram a word in, sideways!

That being said, I do notice very few posts go unanswered, which is an epic accomplishment and I wished I could add in a good answer to someone, in the future!
7 months ago
What if the mp3 files are stored compressed? ;P
7 months ago
This is shocking news to me! I thought java code line execution order is "guaranteed"!

'this', in my constructor assigns the field of the current instance a reference to the instance.
My constructor just receives an object and assigns fields, extracting from the input object:



Again, the reason I am doing this (no pun intended) is because classes which MySession extends (MyChecks, which extends MyDsl, etc...) need to
all work on the same object, without all 40 methods defined in the same class.

Example:




I think in my particular case, so far, I am safe:
1. Any incomplete data will result in a failed connection, containing the explosion pretty soon
2. None of this is actually running in production. It's a test suite
3. I wrote a lot of defensive code - not because I understand Java's memory model and automatic multi-threaded optimization, but because I don't trust myself to have passed the data correctly in the first place
Any field I created and later rely upon will be tested and RunTimeComputerSaysNO will be raised, cutting off further work
7 months ago
I am trying to understand how these lines could execute out of order.

1. Is it only a problem for multi-threaded design?
I am not using multi-threading right now (but I might want to, in the far future)

2. What are the threads doing that can lead to this failure?

a) Are they "sharing" code lines, like:
Thread A: creates blank object, assigns fields Name and DoB
Thread B: assigns gender
Thread C: calls registerPupil


b) Or, is it a problem at the higher level, like:
Thread A: creates and starts to initialize fields
Thread B: school.getMaleFemaleRatio(); (reads all registered pupils, calculates a gender distribution = will produce a bad result, because the pupil in Thread A has a default Gender, not a correct gender)

I am hoping #1 is yes!
I am hoping #2 b!
Or else: this sounds like a total mess! How could one code ANYTHING when threads pick up random code?
7 months ago