Tag: JavaScript

  • JS journey retrospect

    Last year I “wondered if MVC was even the best design for a chess game,” but if I had taken the time to read about the Universal Chess Interface (UCI) I would have seen that MVC is a common design for online chess. If I had built to UCI specs and selected a full-stack framework instead of trying to write backend from the ground up in Node, I might not have given up and resorted to just writing frontend for a platform service.

    Sure, online chess is a solved problem, but I was reinventing the wheel for learning’s sake.

  • Server actions debate

    So i return to PHP practice and unfortunately fall into a habit of writing a page or form response src like i did in 2019, one script inside html, and the script does both PDO to get data and uses that data in the render of html.

    Later in my regular doomscrolling on Twitter I find this screenshot of a presentation slide that has started a big conversation, the slide depicts a React component in Next.js that does exactly what my quick fix php does, access data and render in the same script, only all in JS. And the upshot of the conversation is this, these backend frontend scripts aren’t following best practices for architecture, e.g. MVC.

    So, mission accepted, no more quick fix scripts, and time for me to work on a real MVC project and see it through, unlike in 2021 where I thought I could create an MVC SPA without using any frameworks, just JS libraries Node and jQuery.

  • JavaScript journey

    Making a chess game has been the pet project nearest and dearest to my heart. Through making a chess game, I built up my HTML, CSS, and JavaScript skills, tried out several styling aids such as Bootstrap, Sass, and Bulma, learned about MVC architecture, and did a deep dive into writing elegant/efficient solutions in the problem domain. MDN Web Docs were my JavaScript and Web API reference of choice, and I was appreciative of hints into the problem domain offered by sites like Chess Programming Wiki without giving away specific “code spoilers,” speaking of which, I know there are existing, proven solutions out there for chess engines and frontends: Stockfish, GNU Chess, Lichess, etc., and reinventing the wheel was just my way of teaching myself to code with something that interested me.

    I first attempted MVC with the UI and the data-generating backend modules both coded in vanilla JS, with a NodeJS simple server. It was a challenge to avoid antipatterns and ensure SoC without writing within a framework, and sometimes I wondered if MVC was even the best design for a chess game, so I was pleased to
    finally refactor the code into the React framework, creating a working UI in much less time than it took for me to code vanilla MVC View objects!

  • Regex groove

    Once I decided to get over my fear-of-the-learning-curve of regex and try it for solving problems, I saw how handy JavaScript’s String.prototype.match and String.prototype.search can be and started using regex all the time, and got in a lot of regex practice.