Debugging A Java App

Here are the steps to debugging a Serious Java Application.

  1. The ToeBoneBean is connected to the
  2. FootBoneImpl.isConnectedTo()
  3. AbstractAnkleBone.checkConnection()
  4. ShinBoneFactory.makeConnection()
  5. CompositeKneeBone.connect()
  6. StaticThighBoneBuilder.buildConnection()
  7. HipBoneService.comeUpWithAnotherWayToSayConnect()
  8. BackBoneQueryManager.manageConnection()
  9. NeckBoneDao.executeConnection()
  10. Which leads you to the SQL you were looking for in the first place.

In all seriousness, I am not one of those people who hates Java. It’s just frustrating going to a meetup and hearing about all these great things in Java 8 like lambdas (and yes, I know Java 8 has been out a while) or seeing all the wonderful things that you can do with Spring Boot, and then I go to my job and it’s like the past ten years never happened.

And before any Scala people feel superior, something like _{}\+= is not much better. We did Perl way back when. Not too interested in going back.

You’re welcome.

2018-05-06 Update

I have watched part of the twitter retriever code review. I did make some changes based on what he said.

I am also going through the videos on Purely Functional. I am also working on Clojure For the Brave and True. I am on chapter 4.

I started changing my workouts. I wonder if that is taking energy away from Clojure. There is a lot to learn. I have been working on and off on a post about why I am interested in Clojure. I don’t think I have written a post yet about why Clojure and Lisp in general interests me.

You’re welcome.

(not) and its (complement)

Here is a quick look at the Clojure functions (not) and (complement):

 

 

You’re welcome.

2018-04-22 Update

I am still slowly going through Clojure For the Brave and True. I will keep going for the time being until inspiration hits.

I did try another app that uses the WordPress API. It is called WP-API v2 Java Client. I was not able to get this to work either. I thought (briefly) about making a direct SQL call to insert the post. I turned on SQL logging and decided it might be a bad idea. I have heard that many SQL experts are not impressed with WordPress’s schema. Plus I would either have to refactor (slightly) to use MySQL, or figure out how to use two connections.

Eric Normand of Purely Functional put up his code review of twitter-retriever. Take a look and let me know if it was good. He also has a channel where he talks about functional programming in general. He does these in his backyard.

You’re welcome.

More Collection Functions

I am going through Clojure For The Brave and True, and I have included some of the functions that I encounter while reading the book.

 

You’re welcome.

2018-04-08 Update

I think I am done for the time being with the Twitter-retriever.

As of now, it can get the last 3200 tweets of a user (excluding retweets) and capture any tweets going forward. It prints them out in HTML to a file with each tweet in enclosing “li” tags.

I tried to get the WordPress REST API working. I installed WordPress on my laptop, but I had a hard time getting anything to work with the POST command. GET was easy. It is the authentication that stumped me. I got a couple to work with curl, but no POST commands to work with clj-http. I might try again later, but for now I am done. It seemed to be a rabbit-hole of google searches, adding yet another plugin, editing the .htaccess file, etc, etc. For now, what I have is good enough.

I might look into an alternative to environ, but for the time being I think it will do.

I don’t know what I will work on next. I might get back to Simply Scheme. I might go back to coding examples for the Clojure API. I might go through some lessons at Purely Functional. Maybe TensorFlow (like with guildsman or clojure-tensorflow or tensorflow-clj). Maybe Luminus. As of right now, I have not decided.

You’re welcome.

2018-04-01 Update

I am still working on the twitter retriever.

I am almost ready to start looking at the wordpress API. I think I will start a local instance so I can work with the REST API and not clutter up this site.

I also looked a bit more at the Clojure library environ. What I like about it is that it gets all the environment variables at start time, and any old time you want you just call the env function, and it works. No fuss, no getting files in every namespace. But I am not so sure if it would work in a production environment. There are a lot of pages from people saying that putting usernames and passwords in the environment is a bad idea, and I am leaning that way too. I have not been able to get my app to use environment variables in .lein-env, profiles.clj or .boot-env when I run it with “lein run”.

I also found out that (after some trial and error) that I cannot compile my app with “lein uberjar”. I use environ for my database creds, and it looks for them during the uberjar process. I was not able to use the profiles.clj or .boot-env for this either. I had to put the database variables into the environment when I compile. (So maybe there is not security risk during production after all.)  Here is what I did in bash:

That is not a production database, so no big deal if the creds are here. But that seemed to do the trick. I was able to use the uberjar in another window without any problems (from what I remember).

Also: Eric Normand from Purely Functional got back to me. I told him I was nowhere near done. Partially due to not spending as much time as I should, partially parsing the infamous error messages, partially due to find and trying out libraries as I get this up and running. He wants to do a code review. I think I will clean up a few things before I say yes.

Before I do, I would like to copy and paste in here a few functions for the sake of posterity:

Those should parse a string with a timestamp like “Tue Feb 11 15:03:45 +0000 2014” and convert it to “2014-02-11_15:03:45”. I then found clj-time.

I also think I found a couple of function calls you can try in the REPL to interactively work on regular expressions:

I know those are pretty wide, but I found it helpful.

Here is just a little let:

 

You’re welcome.

2018-03-25 Update

I am still working on the Twitter retriever. There is not much too else to tell right now. I am just working on some tests.

You’re welcome.

Addendum:

I got this message in the tests:

I had a var called “result-str”, and I had misstyped “result-string” in the comparison. Usually that is what the cause when you get a stack trace with “clojure.lang.Var$Unbound” in it somewhere.

I do agree that sometimes the stack traces can be hard to read.

2018-03-18 Update

The “due date” for my Clojure project is tomorrow. I am not done.

Part of it is because I did not get started until a week into it. And I have been using “Organic-Oriented Development” (a new form of OOD): I did not plan a whole lot out ahead of time. I have just been trying different APIs and libraries to see what they do. I looked at propertied, but I don’t think I will wind up using it. I may use environ, but I have not decided.

I am working on some of the tests now. The author of the Twitter API library tells you to set his API keys as environment variables and run the tests against one of his Twitter accounts. I am not a TDD-purist, but I think that is not the best way to go. Running a database for tests I have no problem with, but needing something external to be live is a big no-no to me. On the other hand, I don’t think I know enough about any Clojure testing APIs to say what is a better way to do it. Maybe the author is correct.

I have not looked at the WordPress JSON API. I think for the time being I will just write the tweets in HTML format to a file, and copy and paste.

I have also started getting back into meditation, so perhaps that will help me to be more disciplined.

I did mention this to one of the organizers of the Austin Clojure group. I did not volunteer, but I should probably have something working by then in case they need someone to present.

You’re welcome.