Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

# Todor Kolev

Ranch Hand
since Sep 09, 2019
Todor likes ...
Cows and Likes
Cows
1
In last 30 days
0
Total given
0
Likes
6
0
Total given
7
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

## Recent posts by Todor Kolev

I want to get into machine learning.
However, the field currently seems to prefer Python.
While I would very much like to learn a new language, I have to learn so much stuff for work and my other hobbies, that I really prefer to use Java (which I *kinda* know...).

From what I see, there's nothing particularly special about python for ML, only that there are lots of libraries and worked-out examples...
I bet Java might even do better performance!

Question is, is it feasible for me to start a small ML project with Java or it's a dead-end road?

In particular, my half-study-half-useful project is about an approximation pathfinder for mental unit conversion ("APMUC").

For example, KG to Lbs:
KG x 2 + 10% (I found this myself, with pen and paper)
This is two (three actually) steps of simple mental arithmetic and yields a pretty useful result (-0.21% accuracy)

Rules:
1. Approximation should not yield results over a certain accuracy
2. Number of steps in the "found" path may not exceed the required number of steps
3. Only addition, subtraction, multiplication and division allowed (% also allowed)
4. Multiplication only by "easy" factors: 2, 3, 4, 5, 10
5. Division only by "easy divisors": 2, 10
6. Only "easy" percentages like: 1%, 10%...

Input:
Expected accuracy in absolute %
Exact factor (2.20462, in the above example)
Number of steps (should be 1-4, if we want to keep things memorable)

Process:
The ML will try to mix and match the rules to find any paths that cover the accuracy and step-number requriements

Output: a table of formulas (like: "<startingNumber> X 2 + 10%-of<startingNumber>"), with the "stepCount" and "accuracy" for each, for the user to pick the best approximation and use in daily life

I know there are various ML approaches to solving this but I guess anything that works will be fine.
Do you reckon I am likely to find the supporting libraries in Java or "the AI/ML train" has left the "java station"?

(yes, I know I can probably brute force this without ML, but I want to use this project to access ML knowledge a little bit, please!)
1 year ago
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?
2 years 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.
2 years 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)
2 years ago

@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.
2 years 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...

2 years 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"
2 years 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!
2 years 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!
2 years ago
I thought you don't need to @Override a method implementing a body-less interface method?
2 years 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!
2 years ago
Slavin, in your second example, why did you @Override?
2 years 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!
2 years ago
What if the mp3 files are stored compressed? ;P
2 years 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
2 years ago