Win a copy of Rust Web Development this week in the Other Languages forum!

Andrzej Zahorski

Ranch Hand
+ Follow
since Oct 11, 2017
Andrzej likes ...
IntelliJ IDE Python Linux
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andrzej Zahorski

Jesse Silverman wrote:Hi Tim:

I am thinking the OP may have used the word "warning" somewhat carelessly.

I definitely have seen this as an actual warning in other languages I need to work in, including when it was like "warning -- this very bad thing you should never do just happened".  The code compiled (depending on settings) and you were playing the slot machines to find out what would happen at runtime (also often dependent upon compile settings).

But as far as I recall, this message is always associated with a compile failure in Java since way back.

There are warning class messages, usually about type-unsafe operations or deprecated usages, I don't think this was ever one of those.



Sorry it is my mistake and yes, it fails to compile, so it is definitely not a warning. I was so focused on "might" so I just wrote everything else without much consideration which generated confusion.
2 months ago
Thanks, I wanted to give it a bit of a character

You can send me your github account with Purple Mooseage ;)

It doesn't really matter that much which topic would you choose as long it has coherent narration, it tackles programming and it might be useful for other people.
Personally I have planned:
  • Core Java
  • More advanced stuff like networking features of Java
  • Spring
  • Maven
  • Basics of algorithms
  • Core Python
  • Django (not sure tho)
  • HTML + CSS + JS
  • Intro to Linux and DevOps
  • 2 months ago
    Thank you for posting this reference it will be nice addition to official tutorial and books.
    This issue is not a regular path of my learning process, I derailed off it, because I simply thought that word "might" sounds quite mysterious and it stands out ;).

    My learning method is to create general topic like "what is an object" and fill that void with knowledge from various different sources and if I bump into something new, that demands explanation, I create empty page for it that will be taken into consideration when I will be in the nearest possible topic to this new occurrence.

    Off-topic:  in terms of fun, I started sharing my (small) experience (I am strong proponent of the idea that knowledge and technology should be open to everyone) and I created github webpage: https://codenotes.dev.
    It is early work in progress, but if you wish to share your programming interests, I can add you to the repo
    Everything is written in Markdown with addition of Mermaid and MathJax (and some other goodies like links in Roam-Research style, admonitions, but it is optional). Page itself is generated by Python mkdocs which soon be automated to github workflow so aspect of maintenance will be simplified to just editing the documents.
    2 months ago

    Tim Cooke wrote:Giving an example of when you saw this warning might give a bit of context for your question. Otherwise the best I can offer is "it depends".



    I just thought about it when explaining references with simple example:


    As far as I know  and with taking into account good examples from previous answer, there is no possibility of having iniitialized variable that might be not initialized and it is just the wording that is not deterministic enough.
    2 months ago
    Hi, I am curious about wording when having warning about uninitialized variables.
    Java tells that variable might not be initiialized instead it is not initialized.
    Is there a case in which variable is initialized and Java still throws this runtime error or is it just a word and I should just move on with my life?
    2 months ago

    Campbell Ritchie wrote:Note the above classes are all mutable. It should be possible to envisage a scenario where the classes are immutable.



    Thank you for your response  and examples, they provide valuable insight and I wanted to point out two especially cool things:
  • Taking into account the lowest possible temperature
  • Objects.requireNonNull() - I didn't know about this method



  • Anyway, I just thought maybe what Bruce Eckel had it mind is the idea of "patching" the solution to allow new interactions, even if the end result is not the prettiest one, because when you just look at diagram it looks like someone hadn't idea about the future of the interface and text I quoted might support that point of view.

    Thank you again for taking your time and providing  the elaborate answer, especially because I asked this question on Discord and I bumped into dead silence there, and now, I feel like thermostat of my heart turned on the heater indeed

    If you would care to take a look, I could send you my copy/fragment of the book, because I am not sure I have enough experience to value it in terms of the information content, so it would be helpful too.
    2 months ago
    Hi, I am reading  "On Java 8" by Bruce Eckel and he writes such thing:

    Sometimes you add new interface elements to a derived type, thus extending the interface. The new type can still substitute for the base type, but the substitution isn’t perfect because your new methods are not accessible from the base type. This can be described as an is-like-a relationship (my term). The new type has the interface of the old type but it also contains other methods, so you can’t really say it’s exactly the same. For example, consider an air conditioner. Suppose your house is wired with all the controls for cooling; that is, it has an interface that to control cooling. Imagine that the air conditioner breaks down and you replace it with a heat pump, which can both heat and cool. The heat pump is-like-an air conditioner, but it can do more.
    Because the control system of your house is designed only to control cooling, it is restricted to communication with the cooling part of the new object. The interface of the new object is extended, and the existing system only knows about the original interface. Once you see this design it becomes clear that the base class “cooling system” is not general enough, and should be renamed to “temperature control system” so it can also include heating—at which point the substitution principle will work. However, this diagram shows what can happen with design in the real world.
    When you see the substitution principle it’s easy to feel like this approach (pure substitution) is the only way to do things, and in fact it is nice if your design works out that way. But you’ll find there are times when it’s equally clear you must add new methods to the interface of a derived class (extension). With inspection both cases should be reasonably obvious



    And here is diagram of his design of the problem:

    image doesn't display: here is direct link: https://imgur.com/a/KilhSBO

    I am not sure but I feel like this design is kinda ugly and I came up with such idea:



    Which concept is better and why?
    2 months ago
    I got to this point:


    But printing every iteration is not efficient, because I am creating multiple Strings in String Pool at this moment I've got no idea how to append it so I will get this inside stringBuilder (example size = 5):
    7 months ago

    Campbell Ritchie wrote:A Stream‑based solution might be eminently suitable for beginners, but we shall have to make them do it the hard way with a loop (‍) because these exercises are for teaching people how to use loops.


    I thought about using Stream API, but it is out of scope for explaining it (I am doing it for another person and he just started learning Java) , but  would you mind sharing Stream solution?
    7 months ago
    Hi,
    Is it possible to create triangle with one instance of StringBuilder in one loop?
    This is example of shape of triangle I am  writing about:


    I know it is possible to do it with two loops, but I wish to reduce number of iterations.
    7 months ago
    I do. Hmm, interesting, however if I run program in terminal (not embedded in IntelliJ):


    1 year ago
    I have problem with reading order which is nothing like what I have in my file.
    Could you explain me why is it so?

    Here is the beginning of the .csv I am reading:


    Here is program that reads it (don't worry about returning null, this is still work in progress, as I need to process that file further on the road)


    Here is the output:


    However if redirect output of the console to the file - everything looks fine:



    1 year ago
    I'm trying to write fully functional and optional method that maps optional String -> optional natural number (let suppose natural numbers begin with 0)
    This is what I wrote so far:



    However my intuition tells me that it is possible to write this function with using only interfaces from Functional library instead using if statements.
    1 year ago
    Okay, I wrote something like this:


    It seems to work.
    1 year ago

    Campbell Ritchie wrote:You can't iterate a Map. only one of the three sets you can get out of it. You can get access to those three sets via three of the Map's methods. You can use the map() mathod to take the price and count and produce a number. If you have the price as a primitive you may be able to get a Stream of primitives with a method called mapToXYZ() and use its sum() method, otherwise you would have to write a Collector with its three parts yourself, or use the reduce() method which you will find examples of in the package documentation.
    Show us what you have tried and tell us how it is going. This is one of the circumstances where it is much easier to use an IDE than the command line.




    I was thinking about something like this, however I couldn't put it in code

    1 year ago