I haven’t posted in a little while.
I’m mostly done with the next article I was supposed to post, which is about getting WebRTC working for video chats through the website. But before I could post it, I decided to redesign the whole site.
I’m partway through it right now, so I don’t have anything to show yet. I’ll write a series of posts about the redesign once it launches, but I’ll talk a little about the effort right now.
But I wrote the first line of Go code back in January when I started the project (before I even knew all the stuff I wanted to add) and have been rapidly adding features since. I’m at 155 releases/deployments since January, and the site is on version 6.6.2 (I try to stick to semver even for this, so major.minor.patch releases).
At this point, the code is a complete mess.
Bad project architecture
Here’s a breakdown of the lines of code1 for this web project:
Most of the code is in one big Go package called “handlers”. Out of the 9,565 lines of Go, 9,487 of them are in the handlers package. 😕
Not only are the Go files a mess, but there are 99 html files in the project. 98 of them are in one templates directory. 😕😕
And I didn’t really know Go template best practices at the time so there is NO code reuse or partials or anything like that.2
That part isn’t such a problem on the frontend, but the general design I’m using is.
When I started this in January, the only thing I knew for sure was that I was going to post articles and pictures. I hadn’t made the decision to do freelance development yet, I had no plans for user accounts, web tools, video chat, or anything else.
The design you’re seeing right now has been updated a lot this year, but the foundations are the same: A couple links at the top of the page, an ineffective list of “More Links” on the side of the home page, and a mostly one column layout for everything else.
But this design has existed through the introduction of the following features:
- Comments (and comment administration)
- Video chat (with chat requests from users)
- Liked posts
- Utils/Reference pages
- Web/IRC chat
- Freelancing services
- Notes/Link shortener service (these are just for me)
- User accounts and user management
- Financial contributions
Clearly a new design is needed.
Other Frontend Issues
- I really like the monochrome theme. It works well in both light and dark modes. But it’s time for some color and theme flexibility.
- I also like the animations on the site, but they aren’t good enough. This is a good opportunity to make them even better.
As of this writing, I’ve completely rewritten the backend (the page routes and queries and everything are the same, so functionality should HOPEFULLY be exactly the same) to be clearer, more organized, and more efficient.
Now I’m working through the frontend. I’m in the middle of rewriting pretty much every template files. And I basically deleted all of the CSS so I can start over.
Here are the lines of code right now:
Some interesting things I’ve noticed so far:
- Estimated cost to develop/people required3 hasn’t changed much (which makes sense considering the project size/effort is the same).
- Go code files went from 34 to 120(!!!), but the actual lines of code only increased by like 1,631 (8,271 to 9,902). This is good!! This means I’m using Go packages way more effectively.
- HTML files increased because I started adding partials and splitting up some of the files that were too big. But I didn’t finish actually using those partials so the actual lines of HTML haven’t changed much. I expect there to be a lot less HTML code when I’m done.
That’s it for now. I’ll write another breakdown closer to release. I’m gonna dive back in now and get this done.
Honestly, my Go template usage was disgusting. I wasn’t using any template functions at all, just passing blobs of string data. I have copied/pasted HTML all over the place. I wasn’t even caching the parsed templates. Ugh. ↩︎
I don’t know how this is calculated. I’m gonna read more about it after I publish this. It’s interesting though now that I’ve been freelancing and tracking (and charging for) my time, I’ve been thinking a lot about the many hours I put into this project and how much it actually costs. It’s nice to get a rough estimate. ↩︎